Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chunked ReadFile from file manager #12577

Merged
merged 1 commit into from Jul 26, 2016
Merged

Chunked ReadFile from file manager #12577

merged 1 commit into from Jul 26, 2016

Conversation

@izgzhen
Copy link
Contributor

izgzhen commented Jul 24, 2016

  • Introduce a ReadFileProgress sender in the ReadFile msg to file manager, and implement the related I/O operations
  • Change tests/unit/net/test.jpeg from a 4.8K file to a 39K file to better test the chunked reading (Since one chunk is maximally 8129 Bytes).

r? @Manishearth


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • There are tests for these changes

This change is Reviewable

@highfive
Copy link

highfive commented Jul 24, 2016

Heads up! This PR modifies the following files:

  • @KiChjang: components/net/filemanager_thread.rs, components/net/blob_loader.rs, components/net_traits/filemanager_thread.rs, components/net_traits/filemanager_thread.rs, components/script/dom/blob.rs
@Ms2ger
Copy link
Contributor

Ms2ger commented Jul 24, 2016

I know Lenna is a common testing image, but it seems problematic both copyright-wise and in terms of its source and all that entails.

@izgzhen
Copy link
Contributor Author

izgzhen commented Jul 24, 2016

really O_o? I will use another one

@izgzhen izgzhen force-pushed the izgzhen:fm-chunked branch from 0566047 to 98e039f Jul 24, 2016
@izgzhen
Copy link
Contributor Author

izgzhen commented Jul 24, 2016

Done, only resolution of picture is changed.

})
}
}

fn load_blob(load_data: LoadData, start_chan: LoadConsumer,
classifier: Arc<MimeClassifier>,
filemanager_chan: IpcSender<FileManagerThreadMsg>) {
filemanager_chan: IpcSender<FileManagerThreadMsg>,
// XXX(izgzhen): we should utilize cancel_listener

This comment has been minimized.

Copy link
@Manishearth

Manishearth Jul 25, 2016

Member

file a bug for this and note the bug number

@@ -443,36 +447,31 @@ impl <UI: 'static + UIProvider> FileManagerStore<UI> {
.map_err(|e| BlobURLStoreError::External(e.to_string())));

if seeked_start == (range.start as u64) {

This comment has been minimized.

Copy link
@Manishearth

Manishearth Jul 25, 2016

Member

Why do we call the file a "handler" here? Perhaps just call it "file"?

@@ -563,3 +562,46 @@ fn select_files_pref_enabled() -> bool {
PREFS.get("dom.testing.htmlinputelement.select_files.enabled")
.as_boolean().unwrap_or(false)
}

const CHUNK_SIZE: usize = 8192;

This comment has been minimized.

Copy link
@Manishearth

Manishearth Jul 25, 2016

Member

What's the chunk size for other browsers?

This comment has been minimized.

Copy link
@izgzhen

izgzhen Jul 25, 2016

Author Contributor

As I can find it is 512 bytes to several KB:

But I can't find the exact number used for the same purpose here. By the way, 8192 is stolen from net/file_loader.rs. I once tried to reuse the code in it but found its code too specialized and hard to refactor.

}
}

// Send the rest chunks

This comment has been minimized.

Copy link
@Manishearth

Manishearth Jul 25, 2016

Member

s/rest/remaining

panic!("Invalid FileManager reply");
}
ReadFileProgress::Partial(mut bytes_in) => {
bytes.append(&mut bytes_in);

This comment has been minimized.

Copy link
@Manishearth

Manishearth Jul 25, 2016

Member

We should probably count the number of chunks and ensure that number doesn't change.

This comment has been minimized.

Copy link
@izgzhen

izgzhen Jul 25, 2016

Author Contributor

Why it should not change?

This comment has been minimized.

Copy link
@Manishearth

Manishearth Jul 25, 2016

Member

Because the chunk threshhold and the file being tested aren't changing 😄

(The number here can be updated if they do change)

This comment has been minimized.

Copy link
@izgzhen

izgzhen Jul 25, 2016

Author Contributor

Okay I see. In chunked_read, read is used, which I suppose means that, the length of real chunk we read might be different depending on the system status.

This comment has been minimized.

Copy link
@Manishearth

Manishearth Jul 25, 2016

Member

Oh, because it could be less than CHUNK_SIZE. Right.

@Manishearth
Copy link
Member

Manishearth commented Jul 25, 2016

Minor nits, overall lgtm.

@Manishearth
Copy link
Member

Manishearth commented Jul 25, 2016

What's the source of the new image?

@izgzhen
Copy link
Contributor Author

izgzhen commented Jul 25, 2016

@Manishearth Source is Google .... and should be a website like this http://tomatoz.ru/jmir/3340-ne-budite-muzhiki.html (but I can't find the exact one sorry). Well if this is also problematic maybe I should upload a cat picture taken by myself O_o (if the cat's lawyer is okay with it)

@Manishearth
Copy link
Member

Manishearth commented Jul 25, 2016

Yeah, any photo you took is okay. Otherwise find something public domain on commons.wikimedia.org 😄

@izgzhen izgzhen force-pushed the izgzhen:fm-chunked branch from 08ca28a to 9c8ebd3 Jul 25, 2016
@izgzhen
Copy link
Contributor Author

izgzhen commented Jul 25, 2016

I changed the picture to a photo taken by me (plus all other nits).

@Manishearth
Copy link
Member

Manishearth commented Jul 26, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Jul 26, 2016

📌 Commit 9c8ebd3 has been approved by Manishearth

@bors-servo
Copy link
Contributor

bors-servo commented Jul 26, 2016

Testing commit 9c8ebd3 with merge b41bf4f...

bors-servo added a commit that referenced this pull request Jul 26, 2016
Chunked ReadFile from file manager

+ Introduce a `ReadFileProgress` sender in the `ReadFile` msg to file manager, and implement the related I/O operations
+ Change `tests/unit/net/test.jpeg` from a 4.8K file to a 39K file to better test the chunked reading (Since one chunk is maximally 8129 Bytes).

r? @Manishearth

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] There are tests for these changes

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12577)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jul 26, 2016

💔 Test failed - linux-rel

@highfive
Copy link

highfive commented Jul 26, 2016

  ▶ Unexpected subtest result in /html/browsers/browsing-the-web/history-traversal/browsing_context_name.html:
  └ PASS [expected FAIL] Retaining window.name on history traversal
@Manishearth
Copy link
Member

Manishearth commented Jul 26, 2016

@ConnorGBrewster that passing test looks unrelated -- any idea what's going on here?

@jdm
Copy link
Member

jdm commented Jul 26, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Jul 26, 2016

Previous build results for android, arm32, arm64, linux-dev, mac-dev-unit, mac-rel-css, mac-rel-wpt, windows-dev are reusable. Rebuilding only linux-rel...

@bors-servo
Copy link
Contributor

bors-servo commented Jul 26, 2016

@bors-servo bors-servo merged commit 9c8ebd3 into servo:master Jul 26, 2016
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

6 participants
You can’t perform that action at this time.