mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
Auto merge of #12268 - izgzhen:fm-spawn, r=Manishearth
Spawn threads for requests in file manager r? @Manishearth --- <!-- 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 <!-- Either: --> - [x] There are tests for these changes OR <!-- 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="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12268) <!-- Reviewable:end -->
This commit is contained in:
commit
c2a22bd05e
6 changed files with 217 additions and 164 deletions
|
@ -13,6 +13,7 @@ use dom::bindings::str::{DOMString, USVString};
|
|||
use dom::blob::Blob;
|
||||
use dom::urlhelper::UrlHelper;
|
||||
use dom::urlsearchparams::URLSearchParams;
|
||||
use ipc_channel::ipc;
|
||||
use net_traits::IpcSend;
|
||||
use net_traits::blob_url_store::parse_blob_url;
|
||||
use net_traits::filemanager_thread::{SelectedFileId, FileManagerThreadMsg};
|
||||
|
@ -142,17 +143,16 @@ impl URL {
|
|||
*/
|
||||
let origin = global.get_url().origin().unicode_serialization();
|
||||
|
||||
match Url::parse(&url) {
|
||||
Ok(url) => match parse_blob_url(&url) {
|
||||
Some((id, _)) => {
|
||||
let filemanager = global.resource_threads().sender();
|
||||
let id = SelectedFileId(id.simple().to_string());
|
||||
let msg = FileManagerThreadMsg::DecRef(id, origin);
|
||||
let _ = filemanager.send(msg);
|
||||
}
|
||||
None => {}
|
||||
},
|
||||
Err(_) => {}
|
||||
if let Ok(url) = Url::parse(&url) {
|
||||
if let Some((id, _)) = parse_blob_url(&url) {
|
||||
let filemanager = global.resource_threads().sender();
|
||||
let id = SelectedFileId(id.simple().to_string());
|
||||
let (tx, rx) = ipc::channel().unwrap();
|
||||
let msg = FileManagerThreadMsg::DecRef(id, origin, tx);
|
||||
let _ = filemanager.send(msg);
|
||||
|
||||
let _ = rx.recv().unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue