Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upChunked ReadFile from file manager #12577
Conversation
highfive
commented
Jul 24, 2016
|
Heads up! This PR modifies the following files:
|
|
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. |
|
really O_o? I will use another one |
|
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.
This comment has been minimized.
| @@ -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.
This comment has been minimized.
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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
izgzhen
Jul 25, 2016
Author
Contributor
As I can find it is 512 bytes to several KB:
- https://dxr.mozilla.org/mozilla-central/source/modules/libjar/zipwriter/nsZipDataStream.cpp#164
- https://dxr.mozilla.org/mozilla-central/source/xpcom/tests/gtest/TestCloneInputStream.cpp#149
- https://dxr.mozilla.org/mozilla-central/source/netwerk/streamconv/test/Converters.cpp#41
- https://dxr.mozilla.org/mozilla-central/source/netwerk/protocol/http/nsHttpConnection.cpp#608
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.
This comment has been minimized.
| panic!("Invalid FileManager reply"); | ||
| } | ||
| ReadFileProgress::Partial(mut bytes_in) => { | ||
| bytes.append(&mut bytes_in); |
This comment has been minimized.
This comment has been minimized.
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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
This comment has been minimized.
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.
This comment has been minimized.
|
Minor nits, overall lgtm. |
|
What's the source of the new image? |
|
@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) |
|
Yeah, any photo you took is okay. Otherwise find something public domain on commons.wikimedia.org |
|
I changed the picture to a photo taken by me (plus all other nits). |
|
@bors-servo r+ |
|
|
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 -->
|
|
highfive
commented
Jul 26, 2016
|
|
@ConnorGBrewster that passing test looks unrelated -- any idea what's going on here? |
|
@bors-servo: retry |
|
|
|
|
izgzhen commentedJul 24, 2016
•
edited by larsbergstrom
ReadFileProgresssender in theReadFilemsg to file manager, and implement the related I/O operationstests/unit/net/test.jpegfrom 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 -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is