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 upPut Blob URL online #12440
Put Blob URL online #12440
Conversation
highfive
commented
Jul 14, 2016
|
Heads up! This PR modifies the following files:
|
|
Still WIP, welcome comments! (esp. about "long-live") |
| let _ = sender.send(Err(BlobURLStoreError::InvalidOrigin)); | ||
| } | ||
| // Check origin format correctness | ||
| if Url::parse(&origin).is_ok() || origin == "file://" { |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
izgzhen
Jul 14, 2016
Author
Contributor
Because Url::parse is not happy with an origin equal to file://. It is kinda a hack (related to get_blob_origin, parse_blob_url etc. as well)
This comment has been minimized.
This comment has been minimized.
| origin: origin.clone(), | ||
| file_impl: FileImpl::Memory(blob_buf), | ||
| refs: AtomicUsize::new(1), | ||
| // Valid here since PromoteMemory implies URL creation |
This comment has been minimized.
This comment has been minimized.
Manishearth
Jul 14, 2016
Member
Not necessarily, yes? What if a child blob promotes the parent in-memory blob when it is converted to a URL?
We should have validity be a bool option on this function. Call it "valid_as_url" or something
| if ref_url.scheme() == "blob" { | ||
| let msg = FileManagerThreadMsg::LoadBlob(load_data, | ||
| LoadConsumer::Listener(response_target)); | ||
| self.resource_threads.send(msg).unwrap(); // XXX: unwrap?! |
This comment has been minimized.
This comment has been minimized.
| pub fn get_blob_origin(url: &Url) -> FileOrigin { | ||
| if url.scheme() == "file" { | ||
| // NOTE: by default this is "null" (Opaque), which is not ideal | ||
| "file://".to_string() |
This comment has been minimized.
This comment has been minimized.
Manishearth
Jul 14, 2016
Member
Aren't file URIs supposed to be considered opaque origin? What's wrong with using the opaque origin in the blob?
This comment has been minimized.
This comment has been minimized.
izgzhen
Jul 14, 2016
Author
Contributor
Well, FileOrigin is still a unicode-serialization of url::Origin, which, when it is file://, turned into "null"
This comment has been minimized.
This comment has been minimized.
izgzhen
Jul 14, 2016
Author
Contributor
A lot of things can be null, including file://, so I am trying to make this case more special here. (not a elegant solution though)
This comment has been minimized.
This comment has been minimized.
| core_resource_thread.send(Fetch(init, action_sender)).unwrap(); | ||
|
|
||
| if init.url.scheme() == "blob" { | ||
| resource_threads.send(FileManagerThreadMsg::Fetch(init, action_sender)).unwrap(); // XXX: unwrap? |
This comment has been minimized.
This comment has been minimized.
| @@ -368,6 +373,11 @@ impl XMLHttpRequestMethods for XMLHttpRequest { | |||
| // Step 11 - abort existing requests | |||
| self.terminate_ongoing_fetch(); | |||
|
|
|||
| // See WPT test: FileAPI/blob/Blob-XHR-revoke.html | |||
This comment has been minimized.
This comment has been minimized.
Manishearth
Jul 14, 2016
Member
So this is wrong. I think you're aware of this since you've marked it as a hack
The correct behavior is that XHR queries for validity during open(), and is allowed to access the blob even after the URL validity expires, provided that it was allowed to during open(). Firefox returns an error on invalid blob URIs in open() (for both existing-but-revoked URIs and nonexistant URIs)
We should have a second refcount, which counts the number of XHRs holding on to this. When xhr calls open(), it should send a special message that checks validity and bumps this refcount if still valid; and the message will respond with the validity state (which is now just a bool). When the XHR gets a response or error, it un-bumps the refcount. Deleting an entry from the store is done when the refcounts and validity state are null. HTTP fetches will not fetch URLs with a false validity. New XHR requests will also fail on open() for invalid URIs. Existing XHRs will work fine.
The spec says nothing about this, however
for now, don't include this hack, have a simple validity state and let the test fail. We'll work on clearing up the spec and only then implement it.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Manishearth
Jul 14, 2016
Member
Feel free to make a PR to wpt to remove this test, too, since it's unspecced and inconsistent across browsers. If this gets specced and/or becomes consistent, we can add it again.
We should probably create an issue on a spec somewhere, but right now I'm discussing with baku and we'll figure out which spec we care about.
This comment has been minimized.
This comment has been minimized.
| let msg = FileManagerThreadMsg::LoadBlob(net_load_data, LoadConsumer::Listener(response_target)); | ||
| self.resource_threads.send(msg).unwrap(); | ||
| } else { | ||
| let msg = CoreResourceMsg::Load(net_load_data, LoadConsumer::Listener(response_target), None); |
This comment has been minimized.
This comment has been minimized.
Manishearth
Jul 14, 2016
Member
The CoreResource handler should be doing the delegation to the file manager thread, not script_task
This comment has been minimized.
This comment has been minimized.
izgzhen
Jul 14, 2016
Author
Contributor
Yep, that is one way. But I remembered that we discussed this before and thought CoreResource thread handler might be too busy thus clogged?
This comment has been minimized.
This comment has been minimized.
Manishearth
Jul 14, 2016
Member
No, it shouldn't get clogged easily since it just spawns threads for each message.
It could get clogged in cases where we pool, but in that case we shouldn't be giving File fetches any priority over other fetches anyway.
This comment has been minimized.
This comment has been minimized.
izgzhen
Jul 14, 2016
Author
Contributor
I see. But that will incur some broader restructuring over net process interface so I wonder if I should do it here (since we split filemanagermsg out from core one before)
| <body> | ||
| <img src="test.jpg" id="image"> | ||
| <input type="file" id="file-input""> | ||
| </body> |
This comment has been minimized.
This comment has been minimized.
5a10e14
to
fef71bd
| @@ -548,6 +554,7 @@ impl CoreResourceManager { | |||
| }, | |||
| "data" => from_factory(data_loader::factory), | |||
| "about" => from_factory(about_loader::factory), | |||
| "blob" => blob_loader::factory(self.filemanager_chan.clone()), | |||
This comment has been minimized.
This comment has been minimized.
| None, name.as_bytes().to_vec()) | ||
| ] | ||
| }); | ||
| pub fn factory(filemanager_chan: IpcSender<FileManagerThreadMsg>) |
This comment has been minimized.
This comment has been minimized.
Manishearth
Jul 15, 2016
Member
Perhaps we should take a reference (arc) to the file store instead?
Then again, we already have a filemanager thread, so meh.
This comment has been minimized.
This comment has been minimized.
izgzhen
Jul 15, 2016
Author
Contributor
Maybe handle the msg to FileManager will make resource_thread.rs look less formidable
| if let Ok(chan) = | ||
| start_sending_sniffed_opt(start_chan, metadata, classifier, | ||
| &blob_buf.bytes, load_data.context.clone()) { | ||
| let _ = chan.send(Payload(blob_buf.bytes)); |
This comment has been minimized.
This comment has been minimized.
Manishearth
Jul 15, 2016
Member
This sends the payload twice, start_sending_sniffed_opt already does this
This comment has been minimized.
This comment has been minimized.
izgzhen
Jul 15, 2016
Author
Contributor
But partial_body is only used to classify the content as I can tell from the code :/
This comment has been minimized.
This comment has been minimized.
|
One small issue, then update test expectations, and should be good to go. |
|
@bors-servo try There should be some new tests passing |
Put Blob URL online This PR connects the resource requests with file manager thread, including: + `script_thread` load request + `image_cache_thread` load request + XHR load request (the responding part code yet not implemented due to unfamiliarity with fetch standard, but the infra is here) One notable change is the introduction of "long-live validity", to handle the case specified in WPT test FileAPI/blob/Blob-XHR-revoke.html. 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] These changes fix #10539 - [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/12440) <!-- Reviewable:end -->
|
@Manishearth Actually I first thought it will send the Payload for me and didn't write that line code. Should I file an issue on this potentially misleading naming? |
|
|
Put Blob URL online This PR connects the resource requests with file manager thread, including: + `script_thread` load request + `image_cache_thread` load request + XHR load request (the responding part code yet not implemented due to unfamiliarity with fetch standard, but the infra is here) One notable change is the introduction of "long-live validity", to handle the case specified in WPT test FileAPI/blob/Blob-XHR-revoke.html. 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] These changes fix #10539 - [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/12440) <!-- Reviewable:end -->
|
|
|
@bors-servo try Fixed tidy (Feeling like homu would come to GMT 0800 and bite me) |
Put Blob URL online This PR connects the resource requests with file manager thread, including: + `script_thread` load request + `image_cache_thread` load request + XHR load request (the responding part code yet not implemented due to unfamiliarity with fetch standard, but the infra is here) One notable change is the introduction of "long-live validity", to handle the case specified in WPT test FileAPI/blob/Blob-XHR-revoke.html. 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] These changes fix #10539 - [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/12440) <!-- Reviewable:end -->
|
|
highfive
commented
Jul 15, 2016
|
|
@bors-servo try WPT tests updated |
Put Blob URL online This PR connects the resource requests with file manager thread, including: + `script_thread` load request + `image_cache_thread` load request + XHR load request (the responding part code yet not implemented due to unfamiliarity with fetch standard, but the infra is here) One notable change is the introduction of "long-live validity", to handle the case specified in WPT test FileAPI/blob/Blob-XHR-revoke.html. 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] These changes fix #10539 - [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/12440) <!-- Reviewable:end -->
|
|
|
@bors-servo r+ Now that most of the functionality exists, could you go through the list of tests that still fail and ensure that there aren't any tests there that shouldn't be (tests which should pass in Servo but fail)? I'm a bit concerned by the small number of fixed tests in each PR, but it looks like WPT has very few File tests to begin with Perhaps we should add more. |
|
|
Put Blob URL online This PR connects the resource requests with file manager thread, including: + `script_thread` load request + `image_cache_thread` load request + XHR load request (the responding part code yet not implemented due to unfamiliarity with fetch standard, but the infra is here) One notable change is the introduction of "long-live validity", to handle the case specified in WPT test FileAPI/blob/Blob-XHR-revoke.html. 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] These changes fix #10539 - [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/12440) <!-- Reviewable:end -->
|
@Manishearth as I peeked a few days ago, most of the failed tests are due to |
|
|
|
Would be great to explain why the file manager now needs to be passed to |
izgzhen commentedJul 14, 2016
•
edited
This PR connects the resource requests with file manager thread, including:
script_threadload requestimage_cache_threadload requestOne notable change is the introduction of "long-live validity", to handle the case specified in WPT test FileAPI/blob/Blob-XHR-revoke.html.
r? @Manishearth
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is