aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/url.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-07-04 09:15:23 -0700
committerGitHub <noreply@github.com>2016-07-04 09:15:23 -0700
commit36974f0746261b971c93ed7dfb9bd726675ccf69 (patch)
tree6c23db8f78110400a8257b5670dfba955c417c0f /components/script/dom/url.rs
parent1e2b9773d693b19d0c804d16098d15d0945cdd79 (diff)
parent14d68968edc936fe67a226840af4c10ff0aea350 (diff)
downloadservo-36974f0746261b971c93ed7dfb9bd726675ccf69.tar.gz
servo-36974f0746261b971c93ed7dfb9bd726675ccf69.zip
Auto merge of #11875 - izgzhen:file-manager-backend, r=Manishearth
Integration and improvements of File API backends Basically three major changes: 1. More complete origin check in `FileManagerThreadMsg` 2. Add reference counting logic to file manage store and script API 3. Integrate the support of slicing 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 - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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/11875) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/url.rs')
-rw-r--r--components/script/dom/url.rs40
1 files changed, 8 insertions, 32 deletions
diff --git a/components/script/dom/url.rs b/components/script/dom/url.rs
index 2a41f7c7bae..9a47be034f8 100644
--- a/components/script/dom/url.rs
+++ b/components/script/dom/url.rs
@@ -13,10 +13,9 @@ 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::{BlobURLStoreEntry, BlobURLStoreMsg, parse_blob_url};
-use net_traits::filemanager_thread::FileManagerThreadMsg;
+use net_traits::blob_url_store::parse_blob_url;
+use net_traits::filemanager_thread::{SelectedFileId, FileManagerThreadMsg};
use std::borrow::ToOwned;
use std::default::Default;
use url::quirks::domain_to_unicode;
@@ -125,34 +124,9 @@ impl URL {
return DOMString::from(URL::unicode_serialization_blob_url(&origin, &id));
}
- let filemanager = global.resource_threads().sender();
+ let id = blob.get_id();
- let slice = blob.get_slice_or_empty();
- let bytes = slice.get_bytes();
-
- let entry = BlobURLStoreEntry {
- type_string: blob.Type().to_string(),
- filename: None, // XXX: the filename is currently only in File object now
- size: blob.Size(),
- bytes: bytes.to_vec(),
- };
-
- let (tx, rx) = ipc::channel().unwrap();
-
- let msg = BlobURLStoreMsg::AddEntry(entry, origin.clone(), tx);
-
- let _ = filemanager.send(FileManagerThreadMsg::BlobURLStoreMsg(msg));
-
- match rx.recv().unwrap() {
- Ok(id) => {
- DOMString::from(URL::unicode_serialization_blob_url(&origin, &id))
- }
- Err(_) => {
- // Generate a dummy id
- let id = Uuid::new_v4().simple().to_string();
- DOMString::from(URL::unicode_serialization_blob_url(&origin, &id))
- }
- }
+ DOMString::from(URL::unicode_serialization_blob_url(&origin, &id.0))
}
// https://w3c.github.io/FileAPI/#dfn-revokeObjectURL
@@ -166,13 +140,15 @@ impl URL {
NOTE: The first step is unnecessary, since closed blobs do not exist in the store
*/
+ 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 msg = BlobURLStoreMsg::DeleteEntry(id.simple().to_string());
- let _ = filemanager.send(FileManagerThreadMsg::BlobURLStoreMsg(msg));
+ let id = SelectedFileId(id.simple().to_string());
+ let msg = FileManagerThreadMsg::DecRef(id, origin);
+ let _ = filemanager.send(msg);
}
None => {}
},