diff options
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/Cargo.toml | 2 | ||||
-rw-r--r-- | components/script/dom/bindings/trace.rs | 3 | ||||
-rw-r--r-- | components/script/dom/blob.rs | 27 | ||||
-rw-r--r-- | components/script/dom/url.rs | 11 |
4 files changed, 19 insertions, 24 deletions
diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index 34f1d33d678..4645d2ce419 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -70,7 +70,7 @@ style = {path = "../style"} time = "0.1.12" url = {version = "1.2", features = ["heap_size", "query_encoding"]} util = {path = "../util"} -uuid = {version = "0.3", features = ["v4"]} +uuid = {version = "0.3.1", features = ["v4"]} websocket = "0.17" xml5ever = {version = "0.1.2", features = ["unstable"]} diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index 89b3ab88e11..d6969f38d6c 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -57,7 +57,7 @@ use js::jsval::JSVal; use js::rust::Runtime; use libc; use msg::constellation_msg::{FrameType, PipelineId, SubpageId, WindowSizeType, ReferrerPolicy}; -use net_traits::filemanager_thread::{SelectedFileId, RelativePos}; +use net_traits::filemanager_thread::RelativePos; use net_traits::image::base::{Image, ImageMetadata}; use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread}; use net_traits::request::Request; @@ -333,7 +333,6 @@ no_jsmanaged_fields!(USVString); no_jsmanaged_fields!(ReferrerPolicy); no_jsmanaged_fields!(ResourceThreads); no_jsmanaged_fields!(SystemTime); -no_jsmanaged_fields!(SelectedFileId); no_jsmanaged_fields!(RelativePos); no_jsmanaged_fields!(OpaqueStyleAndLayoutData); no_jsmanaged_fields!(PathBuf); diff --git a/components/script/dom/blob.rs b/components/script/dom/blob.rs index 49eff910cd9..0e513081e10 100644 --- a/components/script/dom/blob.rs +++ b/components/script/dom/blob.rs @@ -15,7 +15,7 @@ use encoding::all::UTF_8; use encoding::types::{EncoderTrap, Encoding}; use ipc_channel::ipc; use net_traits::blob_url_store::{BlobBuf, get_blob_origin}; -use net_traits::filemanager_thread::{FileManagerThreadMsg, SelectedFileId, RelativePos, ReadFileProgress}; +use net_traits::filemanager_thread::{FileManagerThreadMsg, RelativePos, ReadFileProgress}; use net_traits::{CoreResourceMsg, IpcSend}; use std::cell::Cell; use std::mem; @@ -26,7 +26,7 @@ use uuid::Uuid; /// File-based blob #[derive(JSTraceable)] pub struct FileBlob { - id: SelectedFileId, + id: Uuid, name: Option<PathBuf>, cache: DOMRefCell<Option<Vec<u8>>>, size: u64, @@ -56,7 +56,7 @@ impl BlobImpl { } /// Construct file-backed BlobImpl from File ID - pub fn new_from_file(file_id: SelectedFileId, name: PathBuf, size: u64) -> BlobImpl { + pub fn new_from_file(file_id: Uuid, name: PathBuf, size: u64) -> BlobImpl { BlobImpl::File(FileBlob { id: file_id, name: Some(name), @@ -167,7 +167,7 @@ impl Blob { /// Get a FileID representing the Blob content, /// used by URL.createObjectURL - pub fn get_blob_url_id(&self) -> SelectedFileId { + pub fn get_blob_url_id(&self) -> Uuid { let opt_sliced_parent = match *self.blob_impl.borrow() { BlobImpl::Sliced(ref parent, ref rel_pos) => { Some((parent.promote(/* set_valid is */ false), rel_pos.clone(), parent.Size())) @@ -186,14 +186,14 @@ impl Blob { /// 2. File-based: If set_valid, then activate the FileID so it can serve as URL /// Depending on set_valid, the returned FileID can be part of /// valid or invalid Blob URL. - fn promote(&self, set_valid: bool) -> SelectedFileId { + fn promote(&self, set_valid: bool) -> Uuid { let mut bytes = vec![]; match *self.blob_impl.borrow_mut() { BlobImpl::Sliced(_, _) => { debug!("Sliced can't have a sliced parent"); // Return dummy id - return SelectedFileId(Uuid::new_v4().simple().to_string()); + return Uuid::new_v4(); } BlobImpl::File(ref f) => { if set_valid { @@ -207,7 +207,7 @@ impl Blob { match rx.recv().unwrap() { Ok(_) => return f.id.clone(), // Return a dummy id on error - Err(_) => return SelectedFileId(Uuid::new_v4().simple().to_string()) + Err(_) => return Uuid::new_v4(), } } else { // no need to activate @@ -233,7 +233,6 @@ impl Blob { match rx.recv().unwrap() { Ok(id) => { - let id = SelectedFileId(id.0); *self.blob_impl.borrow_mut() = BlobImpl::File(FileBlob { id: id.clone(), name: None, @@ -243,13 +242,13 @@ impl Blob { id } // Dummy id - Err(_) => SelectedFileId(Uuid::new_v4().simple().to_string()), + Err(_) => Uuid::new_v4(), } } /// Get a FileID representing sliced parent-blob content - fn create_sliced_url_id(&self, parent_id: &SelectedFileId, - rel_pos: &RelativePos, parent_len: u64) -> SelectedFileId { + fn create_sliced_url_id(&self, parent_id: &Uuid, + rel_pos: &RelativePos, parent_len: u64) -> Uuid { let global = self.global(); let origin = get_blob_origin(&global.r().get_url()); @@ -261,8 +260,6 @@ impl Blob { self.send_to_file_manager(msg); match rx.recv().expect("File manager thread is down") { Ok(new_id) => { - let new_id = SelectedFileId(new_id.0); - *self.blob_impl.borrow_mut() = BlobImpl::File(FileBlob { id: new_id.clone(), name: None, @@ -275,7 +272,7 @@ impl Blob { } Err(_) => { // Return dummy id - SelectedFileId(Uuid::new_v4().simple().to_string()) + Uuid::new_v4() } } } @@ -309,7 +306,7 @@ impl Drop for Blob { } } -fn read_file(global: GlobalRef, id: SelectedFileId) -> Result<Vec<u8>, ()> { +fn read_file(global: GlobalRef, id: Uuid) -> Result<Vec<u8>, ()> { let resource_threads = global.resource_threads(); let (chan, recv) = ipc::channel().map_err(|_|())?; let origin = get_blob_origin(&global.get_url()); diff --git a/components/script/dom/url.rs b/components/script/dom/url.rs index 768dabf1475..e42b3b7f1cd 100644 --- a/components/script/dom/url.rs +++ b/components/script/dom/url.rs @@ -15,7 +15,7 @@ use dom::urlhelper::UrlHelper; use dom::urlsearchparams::URLSearchParams; use ipc_channel::ipc; use net_traits::blob_url_store::{get_blob_origin, parse_blob_url}; -use net_traits::filemanager_thread::{SelectedFileId, FileManagerThreadMsg}; +use net_traits::filemanager_thread::FileManagerThreadMsg; use net_traits::{IpcSend, CoreResourceMsg}; use std::borrow::ToOwned; use std::default::Default; @@ -121,13 +121,13 @@ impl URL { if blob.IsClosed() { // Generate a dummy id - let id = Uuid::new_v4().simple().to_string(); + let id = Uuid::new_v4(); return DOMString::from(URL::unicode_serialization_blob_url(&origin, &id)); } let id = blob.get_blob_url_id(); - DOMString::from(URL::unicode_serialization_blob_url(&origin, &id.0)) + DOMString::from(URL::unicode_serialization_blob_url(&origin, &id)) } // https://w3c.github.io/FileAPI/#dfn-revokeObjectURL @@ -146,7 +146,6 @@ impl URL { if let Ok(url) = Url::parse(&url) { if let Ok((id, _, _)) = parse_blob_url(&url) { let resource_threads = global.resource_threads(); - let id = SelectedFileId(id.simple().to_string()); let (tx, rx) = ipc::channel().unwrap(); let msg = FileManagerThreadMsg::RevokeBlobURL(id, origin, tx); let _ = resource_threads.send(CoreResourceMsg::ToFileManager(msg)); @@ -157,7 +156,7 @@ impl URL { } // https://w3c.github.io/FileAPI/#unicodeSerializationOfBlobURL - fn unicode_serialization_blob_url(origin: &str, id: &str) -> String { + fn unicode_serialization_blob_url(origin: &str, id: &Uuid) -> String { // Step 1, 2 let mut result = "blob:".to_string(); @@ -168,7 +167,7 @@ impl URL { result.push('/'); // Step 5 - result.push_str(id); + result.push_str(&id.simple().to_string()); result } |