mirror of
https://github.com/servo/servo.git
synced 2025-06-25 09:34:32 +01:00
Auto merge of #12898 - izgzhen:burn-selected-file-id, r=Manishearth
Burn SelectedFileId in fire r? @Manishearth --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors <!-- 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/12898) <!-- Reviewable:end -->
This commit is contained in:
commit
43d4a459c0
12 changed files with 76 additions and 105 deletions
|
@ -39,7 +39,7 @@ time = "0.1.17"
|
||||||
unicase = "1.4.0"
|
unicase = "1.4.0"
|
||||||
url = {version = "1.2", features = ["heap_size", "rustc-serialize"]}
|
url = {version = "1.2", features = ["heap_size", "rustc-serialize"]}
|
||||||
util = {path = "../util"}
|
util = {path = "../util"}
|
||||||
uuid = {version = "0.3", features = ["v4"]}
|
uuid = {version = "0.3.1", features = ["v4"]}
|
||||||
websocket = "0.17"
|
websocket = "0.17"
|
||||||
|
|
||||||
[dependencies.webrender_traits]
|
[dependencies.webrender_traits]
|
||||||
|
|
|
@ -12,7 +12,7 @@ use mime::{Mime, Attr};
|
||||||
use mime_classifier::MimeClassifier;
|
use mime_classifier::MimeClassifier;
|
||||||
use net_traits::ProgressMsg::{Payload, Done};
|
use net_traits::ProgressMsg::{Payload, Done};
|
||||||
use net_traits::blob_url_store::parse_blob_url;
|
use net_traits::blob_url_store::parse_blob_url;
|
||||||
use net_traits::filemanager_thread::{FileManagerThreadMsg, SelectedFileId, ReadFileProgress};
|
use net_traits::filemanager_thread::{FileManagerThreadMsg, ReadFileProgress};
|
||||||
use net_traits::response::HttpsState;
|
use net_traits::response::HttpsState;
|
||||||
use net_traits::{LoadConsumer, LoadData, Metadata, NetworkError};
|
use net_traits::{LoadConsumer, LoadData, Metadata, NetworkError};
|
||||||
use resource_thread::CancellationListener;
|
use resource_thread::CancellationListener;
|
||||||
|
@ -40,7 +40,6 @@ fn load_blob<UI: 'static + UIProvider>
|
||||||
cancel_listener: CancellationListener) {
|
cancel_listener: CancellationListener) {
|
||||||
let (chan, recv) = ipc::channel().unwrap();
|
let (chan, recv) = ipc::channel().unwrap();
|
||||||
if let Ok((id, origin, _fragment)) = parse_blob_url(&load_data.url.clone()) {
|
if let Ok((id, origin, _fragment)) = parse_blob_url(&load_data.url.clone()) {
|
||||||
let id = SelectedFileId(id.simple().to_string());
|
|
||||||
let check_url_validity = true;
|
let check_url_validity = true;
|
||||||
let msg = FileManagerThreadMsg::ReadFile(chan, id, check_url_validity, origin);
|
let msg = FileManagerThreadMsg::ReadFile(chan, id, check_url_validity, origin);
|
||||||
let _ = filemanager.handle(msg, Some(cancel_listener));
|
let _ = filemanager.handle(msg, Some(cancel_listener));
|
||||||
|
|
|
@ -6,8 +6,7 @@ use ipc_channel::ipc::IpcSender;
|
||||||
use mime_guess::guess_mime_type_opt;
|
use mime_guess::guess_mime_type_opt;
|
||||||
use net_traits::blob_url_store::{BlobBuf, BlobURLStoreError};
|
use net_traits::blob_url_store::{BlobBuf, BlobURLStoreError};
|
||||||
use net_traits::filemanager_thread::{FileManagerThreadMsg, FileManagerResult, FilterPattern, FileOrigin};
|
use net_traits::filemanager_thread::{FileManagerThreadMsg, FileManagerResult, FilterPattern, FileOrigin};
|
||||||
use net_traits::filemanager_thread::{SelectedFile, RelativePos, FileManagerThreadError};
|
use net_traits::filemanager_thread::{SelectedFile, RelativePos, FileManagerThreadError, ReadFileProgress};
|
||||||
use net_traits::filemanager_thread::{SelectedFileId, ReadFileProgress};
|
|
||||||
use resource_thread::CancellationListener;
|
use resource_thread::CancellationListener;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
@ -157,31 +156,19 @@ impl<UI: 'static + UIProvider> FileManager<UI> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
FileManagerThreadMsg::DecRef(id, origin, sender) => {
|
FileManagerThreadMsg::DecRef(id, origin, sender) => {
|
||||||
if let Ok(id) = Uuid::parse_str(&id.0) {
|
|
||||||
spawn_named("dec ref".to_owned(), move || {
|
spawn_named("dec ref".to_owned(), move || {
|
||||||
let _ = sender.send(store.dec_ref(&id, &origin));
|
let _ = sender.send(store.dec_ref(&id, &origin));
|
||||||
})
|
})
|
||||||
} else {
|
|
||||||
let _ = sender.send(Err(BlobURLStoreError::InvalidFileID));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
FileManagerThreadMsg::RevokeBlobURL(id, origin, sender) => {
|
FileManagerThreadMsg::RevokeBlobURL(id, origin, sender) => {
|
||||||
if let Ok(id) = Uuid::parse_str(&id.0) {
|
|
||||||
spawn_named("revoke blob url".to_owned(), move || {
|
spawn_named("revoke blob url".to_owned(), move || {
|
||||||
let _ = sender.send(store.set_blob_url_validity(false, &id, &origin));
|
let _ = sender.send(store.set_blob_url_validity(false, &id, &origin));
|
||||||
})
|
})
|
||||||
} else {
|
|
||||||
let _ = sender.send(Err(BlobURLStoreError::InvalidFileID));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
FileManagerThreadMsg::ActivateBlobURL(id, sender, origin) => {
|
FileManagerThreadMsg::ActivateBlobURL(id, sender, origin) => {
|
||||||
if let Ok(id) = Uuid::parse_str(&id.0) {
|
|
||||||
spawn_named("activate blob url".to_owned(), move || {
|
spawn_named("activate blob url".to_owned(), move || {
|
||||||
let _ = sender.send(store.set_blob_url_validity(true, &id, &origin));
|
let _ = sender.send(store.set_blob_url_validity(true, &id, &origin));
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
let _ = sender.send(Err(BlobURLStoreError::InvalidFileID));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -245,10 +232,9 @@ impl <UI: 'static + UIProvider> FileManagerStore<UI> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_sliced_url_entry(&self, parent_id: SelectedFileId, rel_pos: RelativePos,
|
fn add_sliced_url_entry(&self, parent_id: Uuid, rel_pos: RelativePos,
|
||||||
sender: IpcSender<Result<SelectedFileId, BlobURLStoreError>>,
|
sender: IpcSender<Result<Uuid, BlobURLStoreError>>,
|
||||||
origin_in: FileOrigin) {
|
origin_in: FileOrigin) {
|
||||||
if let Ok(parent_id) = Uuid::parse_str(&parent_id.0) {
|
|
||||||
match self.inc_ref(&parent_id, &origin_in) {
|
match self.inc_ref(&parent_id, &origin_in) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
let new_id = Uuid::new_v4();
|
let new_id = Uuid::new_v4();
|
||||||
|
@ -262,15 +248,12 @@ impl <UI: 'static + UIProvider> FileManagerStore<UI> {
|
||||||
});
|
});
|
||||||
|
|
||||||
// We assume that the returned id will be held by BlobImpl::File
|
// We assume that the returned id will be held by BlobImpl::File
|
||||||
let _ = sender.send(Ok(SelectedFileId(new_id.simple().to_string())));
|
let _ = sender.send(Ok(new_id));
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
let _ = sender.send(Err(e));
|
let _ = sender.send(Err(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
let _ = sender.send(Err(BlobURLStoreError::InvalidFileID));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn select_file(&self, patterns: Vec<FilterPattern>,
|
fn select_file(&self, patterns: Vec<FilterPattern>,
|
||||||
|
@ -374,7 +357,7 @@ impl <UI: 'static + UIProvider> FileManagerStore<UI> {
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(SelectedFile {
|
Ok(SelectedFile {
|
||||||
id: SelectedFileId(id.simple().to_string()),
|
id: id,
|
||||||
filename: filename_path.to_path_buf(),
|
filename: filename_path.to_path_buf(),
|
||||||
modified: modified_epoch,
|
modified: modified_epoch,
|
||||||
size: file_size,
|
size: file_size,
|
||||||
|
@ -446,11 +429,9 @@ impl <UI: 'static + UIProvider> FileManagerStore<UI> {
|
||||||
|
|
||||||
// Convenient wrapper over get_blob_buf
|
// Convenient wrapper over get_blob_buf
|
||||||
fn try_read_file(&self, sender: IpcSender<FileManagerResult<ReadFileProgress>>,
|
fn try_read_file(&self, sender: IpcSender<FileManagerResult<ReadFileProgress>>,
|
||||||
id: SelectedFileId, check_url_validity: bool, origin_in: FileOrigin,
|
id: Uuid, check_url_validity: bool, origin_in: FileOrigin,
|
||||||
cancel_listener: Option<CancellationListener>) -> Result<(), BlobURLStoreError> {
|
cancel_listener: Option<CancellationListener>) -> Result<(), BlobURLStoreError> {
|
||||||
let id = try!(Uuid::parse_str(&id.0).map_err(|_| BlobURLStoreError::InvalidFileID));
|
self.get_blob_buf(sender, &id, &origin_in, RelativePos::full_range(), check_url_validity, cancel_listener)
|
||||||
self.get_blob_buf(sender, &id, &origin_in, RelativePos::full_range(),
|
|
||||||
check_url_validity, cancel_listener)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dec_ref(&self, id: &Uuid, origin_in: &FileOrigin) -> Result<(), BlobURLStoreError> {
|
fn dec_ref(&self, id: &Uuid, origin_in: &FileOrigin) -> Result<(), BlobURLStoreError> {
|
||||||
|
@ -494,7 +475,7 @@ impl <UI: 'static + UIProvider> FileManagerStore<UI> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn promote_memory(&self, blob_buf: BlobBuf, set_valid: bool,
|
fn promote_memory(&self, blob_buf: BlobBuf, set_valid: bool,
|
||||||
sender: IpcSender<Result<SelectedFileId, BlobURLStoreError>>, origin: FileOrigin) {
|
sender: IpcSender<Result<Uuid, BlobURLStoreError>>, origin: FileOrigin) {
|
||||||
match Url::parse(&origin) { // parse to check sanity
|
match Url::parse(&origin) { // parse to check sanity
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
let id = Uuid::new_v4();
|
let id = Uuid::new_v4();
|
||||||
|
@ -505,7 +486,7 @@ impl <UI: 'static + UIProvider> FileManagerStore<UI> {
|
||||||
is_valid_url: AtomicBool::new(set_valid),
|
is_valid_url: AtomicBool::new(set_valid),
|
||||||
});
|
});
|
||||||
|
|
||||||
let _ = sender.send(Ok(SelectedFileId(id.simple().to_string())));
|
let _ = sender.send(Ok(id));
|
||||||
}
|
}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
let _ = sender.send(Err(BlobURLStoreError::InvalidOrigin));
|
let _ = sender.send(Err(BlobURLStoreError::InvalidOrigin));
|
||||||
|
|
|
@ -25,5 +25,5 @@ serde = "0.8"
|
||||||
serde_macros = "0.8"
|
serde_macros = "0.8"
|
||||||
url = {version = "1.2", features = ["heap_size"]}
|
url = {version = "1.2", features = ["heap_size"]}
|
||||||
websocket = "0.17"
|
websocket = "0.17"
|
||||||
uuid = { version = "0.3", features = ["v4", "serde"] }
|
uuid = { version = "0.3.1", features = ["v4", "serde"] }
|
||||||
cookie = {version = "0.2.5", features = ["serialize-rustc"]}
|
cookie = {version = "0.2.5", features = ["serialize-rustc"]}
|
||||||
|
|
|
@ -8,6 +8,7 @@ use num_traits::ToPrimitive;
|
||||||
use std::cmp::{max, min};
|
use std::cmp::{max, min};
|
||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
// HACK: Not really process-safe now, we should send Origin
|
// HACK: Not really process-safe now, we should send Origin
|
||||||
// directly instead of this in future, blocked on #11722
|
// directly instead of this in future, blocked on #11722
|
||||||
|
@ -98,15 +99,10 @@ impl RelativePos {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX: We should opt to Uuid once it implements `Deserialize` and `Serialize`
|
|
||||||
/// FileID used in inter-process message
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
|
||||||
pub struct SelectedFileId(pub String);
|
|
||||||
|
|
||||||
/// Response to file selection request
|
/// Response to file selection request
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct SelectedFile {
|
pub struct SelectedFile {
|
||||||
pub id: SelectedFileId,
|
pub id: Uuid,
|
||||||
pub filename: PathBuf,
|
pub filename: PathBuf,
|
||||||
pub modified: u64,
|
pub modified: u64,
|
||||||
pub size: u64,
|
pub size: u64,
|
||||||
|
@ -128,24 +124,24 @@ pub enum FileManagerThreadMsg {
|
||||||
SelectFiles(Vec<FilterPattern>, IpcSender<FileManagerResult<Vec<SelectedFile>>>, FileOrigin, Option<Vec<String>>),
|
SelectFiles(Vec<FilterPattern>, IpcSender<FileManagerResult<Vec<SelectedFile>>>, FileOrigin, Option<Vec<String>>),
|
||||||
|
|
||||||
/// Read FileID-indexed file in chunks, optionally check URL validity based on boolean flag
|
/// Read FileID-indexed file in chunks, optionally check URL validity based on boolean flag
|
||||||
ReadFile(IpcSender<FileManagerResult<ReadFileProgress>>, SelectedFileId, bool, FileOrigin),
|
ReadFile(IpcSender<FileManagerResult<ReadFileProgress>>, Uuid, bool, FileOrigin),
|
||||||
|
|
||||||
/// Add an entry as promoted memory-based blob and send back the associated FileID
|
/// Add an entry as promoted memory-based blob and send back the associated FileID
|
||||||
/// as part of a valid/invalid Blob URL depending on the boolean flag
|
/// as part of a valid/invalid Blob URL depending on the boolean flag
|
||||||
PromoteMemory(BlobBuf, bool, IpcSender<Result<SelectedFileId, BlobURLStoreError>>, FileOrigin),
|
PromoteMemory(BlobBuf, bool, IpcSender<Result<Uuid, BlobURLStoreError>>, FileOrigin),
|
||||||
|
|
||||||
/// Add a sliced entry pointing to the parent FileID, and send back the associated FileID
|
/// Add a sliced entry pointing to the parent FileID, and send back the associated FileID
|
||||||
/// as part of a valid Blob URL
|
/// as part of a valid Blob URL
|
||||||
AddSlicedURLEntry(SelectedFileId, RelativePos, IpcSender<Result<SelectedFileId, BlobURLStoreError>>, FileOrigin),
|
AddSlicedURLEntry(Uuid, RelativePos, IpcSender<Result<Uuid, BlobURLStoreError>>, FileOrigin),
|
||||||
|
|
||||||
/// Decrease reference count and send back the acknowledgement
|
/// Decrease reference count and send back the acknowledgement
|
||||||
DecRef(SelectedFileId, FileOrigin, IpcSender<Result<(), BlobURLStoreError>>),
|
DecRef(Uuid, FileOrigin, IpcSender<Result<(), BlobURLStoreError>>),
|
||||||
|
|
||||||
/// Activate an internal FileID so it becomes valid as part of a Blob URL
|
/// Activate an internal FileID so it becomes valid as part of a Blob URL
|
||||||
ActivateBlobURL(SelectedFileId, IpcSender<Result<(), BlobURLStoreError>>, FileOrigin),
|
ActivateBlobURL(Uuid, IpcSender<Result<(), BlobURLStoreError>>, FileOrigin),
|
||||||
|
|
||||||
/// Revoke Blob URL and send back the acknowledgement
|
/// Revoke Blob URL and send back the acknowledgement
|
||||||
RevokeBlobURL(SelectedFileId, FileOrigin, IpcSender<Result<(), BlobURLStoreError>>),
|
RevokeBlobURL(Uuid, FileOrigin, IpcSender<Result<(), BlobURLStoreError>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
|
|
@ -70,7 +70,7 @@ style = {path = "../style"}
|
||||||
time = "0.1.12"
|
time = "0.1.12"
|
||||||
url = {version = "1.2", features = ["heap_size", "query_encoding"]}
|
url = {version = "1.2", features = ["heap_size", "query_encoding"]}
|
||||||
util = {path = "../util"}
|
util = {path = "../util"}
|
||||||
uuid = {version = "0.3", features = ["v4"]}
|
uuid = {version = "0.3.1", features = ["v4"]}
|
||||||
websocket = "0.17"
|
websocket = "0.17"
|
||||||
xml5ever = {version = "0.1.2", features = ["unstable"]}
|
xml5ever = {version = "0.1.2", features = ["unstable"]}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ use js::jsval::JSVal;
|
||||||
use js::rust::Runtime;
|
use js::rust::Runtime;
|
||||||
use libc;
|
use libc;
|
||||||
use msg::constellation_msg::{FrameType, PipelineId, SubpageId, WindowSizeType, ReferrerPolicy};
|
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::base::{Image, ImageMetadata};
|
||||||
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread};
|
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread};
|
||||||
use net_traits::request::Request;
|
use net_traits::request::Request;
|
||||||
|
@ -333,7 +333,6 @@ no_jsmanaged_fields!(USVString);
|
||||||
no_jsmanaged_fields!(ReferrerPolicy);
|
no_jsmanaged_fields!(ReferrerPolicy);
|
||||||
no_jsmanaged_fields!(ResourceThreads);
|
no_jsmanaged_fields!(ResourceThreads);
|
||||||
no_jsmanaged_fields!(SystemTime);
|
no_jsmanaged_fields!(SystemTime);
|
||||||
no_jsmanaged_fields!(SelectedFileId);
|
|
||||||
no_jsmanaged_fields!(RelativePos);
|
no_jsmanaged_fields!(RelativePos);
|
||||||
no_jsmanaged_fields!(OpaqueStyleAndLayoutData);
|
no_jsmanaged_fields!(OpaqueStyleAndLayoutData);
|
||||||
no_jsmanaged_fields!(PathBuf);
|
no_jsmanaged_fields!(PathBuf);
|
||||||
|
|
|
@ -15,7 +15,7 @@ use encoding::all::UTF_8;
|
||||||
use encoding::types::{EncoderTrap, Encoding};
|
use encoding::types::{EncoderTrap, Encoding};
|
||||||
use ipc_channel::ipc;
|
use ipc_channel::ipc;
|
||||||
use net_traits::blob_url_store::{BlobBuf, get_blob_origin};
|
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 net_traits::{CoreResourceMsg, IpcSend};
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
@ -26,7 +26,7 @@ use uuid::Uuid;
|
||||||
/// File-based blob
|
/// File-based blob
|
||||||
#[derive(JSTraceable)]
|
#[derive(JSTraceable)]
|
||||||
pub struct FileBlob {
|
pub struct FileBlob {
|
||||||
id: SelectedFileId,
|
id: Uuid,
|
||||||
name: Option<PathBuf>,
|
name: Option<PathBuf>,
|
||||||
cache: DOMRefCell<Option<Vec<u8>>>,
|
cache: DOMRefCell<Option<Vec<u8>>>,
|
||||||
size: u64,
|
size: u64,
|
||||||
|
@ -56,7 +56,7 @@ impl BlobImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Construct file-backed BlobImpl from File ID
|
/// 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 {
|
BlobImpl::File(FileBlob {
|
||||||
id: file_id,
|
id: file_id,
|
||||||
name: Some(name),
|
name: Some(name),
|
||||||
|
@ -167,7 +167,7 @@ impl Blob {
|
||||||
|
|
||||||
/// Get a FileID representing the Blob content,
|
/// Get a FileID representing the Blob content,
|
||||||
/// used by URL.createObjectURL
|
/// 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() {
|
let opt_sliced_parent = match *self.blob_impl.borrow() {
|
||||||
BlobImpl::Sliced(ref parent, ref rel_pos) => {
|
BlobImpl::Sliced(ref parent, ref rel_pos) => {
|
||||||
Some((parent.promote(/* set_valid is */ false), rel_pos.clone(), parent.Size()))
|
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
|
/// 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
|
/// Depending on set_valid, the returned FileID can be part of
|
||||||
/// valid or invalid Blob URL.
|
/// valid or invalid Blob URL.
|
||||||
fn promote(&self, set_valid: bool) -> SelectedFileId {
|
fn promote(&self, set_valid: bool) -> Uuid {
|
||||||
let mut bytes = vec![];
|
let mut bytes = vec![];
|
||||||
|
|
||||||
match *self.blob_impl.borrow_mut() {
|
match *self.blob_impl.borrow_mut() {
|
||||||
BlobImpl::Sliced(_, _) => {
|
BlobImpl::Sliced(_, _) => {
|
||||||
debug!("Sliced can't have a sliced parent");
|
debug!("Sliced can't have a sliced parent");
|
||||||
// Return dummy id
|
// Return dummy id
|
||||||
return SelectedFileId(Uuid::new_v4().simple().to_string());
|
return Uuid::new_v4();
|
||||||
}
|
}
|
||||||
BlobImpl::File(ref f) => {
|
BlobImpl::File(ref f) => {
|
||||||
if set_valid {
|
if set_valid {
|
||||||
|
@ -207,7 +207,7 @@ impl Blob {
|
||||||
match rx.recv().unwrap() {
|
match rx.recv().unwrap() {
|
||||||
Ok(_) => return f.id.clone(),
|
Ok(_) => return f.id.clone(),
|
||||||
// Return a dummy id on error
|
// Return a dummy id on error
|
||||||
Err(_) => return SelectedFileId(Uuid::new_v4().simple().to_string())
|
Err(_) => return Uuid::new_v4(),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// no need to activate
|
// no need to activate
|
||||||
|
@ -233,7 +233,6 @@ impl Blob {
|
||||||
|
|
||||||
match rx.recv().unwrap() {
|
match rx.recv().unwrap() {
|
||||||
Ok(id) => {
|
Ok(id) => {
|
||||||
let id = SelectedFileId(id.0);
|
|
||||||
*self.blob_impl.borrow_mut() = BlobImpl::File(FileBlob {
|
*self.blob_impl.borrow_mut() = BlobImpl::File(FileBlob {
|
||||||
id: id.clone(),
|
id: id.clone(),
|
||||||
name: None,
|
name: None,
|
||||||
|
@ -243,13 +242,13 @@ impl Blob {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
// Dummy id
|
// Dummy id
|
||||||
Err(_) => SelectedFileId(Uuid::new_v4().simple().to_string()),
|
Err(_) => Uuid::new_v4(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get a FileID representing sliced parent-blob content
|
/// Get a FileID representing sliced parent-blob content
|
||||||
fn create_sliced_url_id(&self, parent_id: &SelectedFileId,
|
fn create_sliced_url_id(&self, parent_id: &Uuid,
|
||||||
rel_pos: &RelativePos, parent_len: u64) -> SelectedFileId {
|
rel_pos: &RelativePos, parent_len: u64) -> Uuid {
|
||||||
let global = self.global();
|
let global = self.global();
|
||||||
|
|
||||||
let origin = get_blob_origin(&global.r().get_url());
|
let origin = get_blob_origin(&global.r().get_url());
|
||||||
|
@ -261,8 +260,6 @@ impl Blob {
|
||||||
self.send_to_file_manager(msg);
|
self.send_to_file_manager(msg);
|
||||||
match rx.recv().expect("File manager thread is down") {
|
match rx.recv().expect("File manager thread is down") {
|
||||||
Ok(new_id) => {
|
Ok(new_id) => {
|
||||||
let new_id = SelectedFileId(new_id.0);
|
|
||||||
|
|
||||||
*self.blob_impl.borrow_mut() = BlobImpl::File(FileBlob {
|
*self.blob_impl.borrow_mut() = BlobImpl::File(FileBlob {
|
||||||
id: new_id.clone(),
|
id: new_id.clone(),
|
||||||
name: None,
|
name: None,
|
||||||
|
@ -275,7 +272,7 @@ impl Blob {
|
||||||
}
|
}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
// Return dummy id
|
// 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 resource_threads = global.resource_threads();
|
||||||
let (chan, recv) = ipc::channel().map_err(|_|())?;
|
let (chan, recv) = ipc::channel().map_err(|_|())?;
|
||||||
let origin = get_blob_origin(&global.get_url());
|
let origin = get_blob_origin(&global.get_url());
|
||||||
|
|
|
@ -15,7 +15,7 @@ use dom::urlhelper::UrlHelper;
|
||||||
use dom::urlsearchparams::URLSearchParams;
|
use dom::urlsearchparams::URLSearchParams;
|
||||||
use ipc_channel::ipc;
|
use ipc_channel::ipc;
|
||||||
use net_traits::blob_url_store::{get_blob_origin, parse_blob_url};
|
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 net_traits::{IpcSend, CoreResourceMsg};
|
||||||
use std::borrow::ToOwned;
|
use std::borrow::ToOwned;
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
|
@ -121,13 +121,13 @@ impl URL {
|
||||||
|
|
||||||
if blob.IsClosed() {
|
if blob.IsClosed() {
|
||||||
// Generate a dummy id
|
// 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));
|
return DOMString::from(URL::unicode_serialization_blob_url(&origin, &id));
|
||||||
}
|
}
|
||||||
|
|
||||||
let id = blob.get_blob_url_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
|
// https://w3c.github.io/FileAPI/#dfn-revokeObjectURL
|
||||||
|
@ -146,7 +146,6 @@ impl URL {
|
||||||
if let Ok(url) = Url::parse(&url) {
|
if let Ok(url) = Url::parse(&url) {
|
||||||
if let Ok((id, _, _)) = parse_blob_url(&url) {
|
if let Ok((id, _, _)) = parse_blob_url(&url) {
|
||||||
let resource_threads = global.resource_threads();
|
let resource_threads = global.resource_threads();
|
||||||
let id = SelectedFileId(id.simple().to_string());
|
|
||||||
let (tx, rx) = ipc::channel().unwrap();
|
let (tx, rx) = ipc::channel().unwrap();
|
||||||
let msg = FileManagerThreadMsg::RevokeBlobURL(id, origin, tx);
|
let msg = FileManagerThreadMsg::RevokeBlobURL(id, origin, tx);
|
||||||
let _ = resource_threads.send(CoreResourceMsg::ToFileManager(msg));
|
let _ = resource_threads.send(CoreResourceMsg::ToFileManager(msg));
|
||||||
|
@ -157,7 +156,7 @@ impl URL {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://w3c.github.io/FileAPI/#unicodeSerializationOfBlobURL
|
// 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
|
// Step 1, 2
|
||||||
let mut result = "blob:".to_string();
|
let mut result = "blob:".to_string();
|
||||||
|
|
||||||
|
@ -168,7 +167,7 @@ impl URL {
|
||||||
result.push('/');
|
result.push('/');
|
||||||
|
|
||||||
// Step 5
|
// Step 5
|
||||||
result.push_str(id);
|
result.push_str(&id.simple().to_string());
|
||||||
|
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
12
components/servo/Cargo.lock
generated
12
components/servo/Cargo.lock
generated
|
@ -1063,7 +1063,7 @@ dependencies = [
|
||||||
"libc 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"uuid 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"uuid 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1420,7 +1420,7 @@ dependencies = [
|
||||||
"unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"util 0.0.1",
|
"util 0.0.1",
|
||||||
"uuid 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"uuid 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"webrender_traits 0.5.1 (git+https://github.com/servo/webrender)",
|
"webrender_traits 0.5.1 (git+https://github.com/servo/webrender)",
|
||||||
"websocket 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"websocket 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
@ -1478,7 +1478,7 @@ dependencies = [
|
||||||
"serde_macros 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_macros 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"util 0.0.1",
|
"util 0.0.1",
|
||||||
"uuid 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"uuid 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"websocket 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"websocket 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1939,7 +1939,7 @@ dependencies = [
|
||||||
"tinyfiledialogs 0.1.0 (git+https://github.com/jdm/tinyfiledialogs)",
|
"tinyfiledialogs 0.1.0 (git+https://github.com/jdm/tinyfiledialogs)",
|
||||||
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"util 0.0.1",
|
"util 0.0.1",
|
||||||
"uuid 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"uuid 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"webrender_traits 0.5.1 (git+https://github.com/servo/webrender)",
|
"webrender_traits 0.5.1 (git+https://github.com/servo/webrender)",
|
||||||
"websocket 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"websocket 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"xml5ever 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"xml5ever 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -2471,7 +2471,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uuid"
|
name = "uuid"
|
||||||
version = "0.3.0"
|
version = "0.3.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -2572,7 +2572,7 @@ dependencies = [
|
||||||
"script_traits 0.0.1",
|
"script_traits 0.0.1",
|
||||||
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"util 0.0.1",
|
"util 0.0.1",
|
||||||
"uuid 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"uuid 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"webdriver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"webdriver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,6 @@ rustc-serialize = "0.3.4"
|
||||||
script_traits = {path = "../script_traits"}
|
script_traits = {path = "../script_traits"}
|
||||||
url = {version = "1.2", features = ["heap_size"]}
|
url = {version = "1.2", features = ["heap_size"]}
|
||||||
util = {path = "../util"}
|
util = {path = "../util"}
|
||||||
uuid = { version = "0.3", features = ["v4"] }
|
uuid = { version = "0.3.1", features = ["v4"] }
|
||||||
webdriver = "0.9"
|
webdriver = "0.9"
|
||||||
cookie = {version = "0.2.5", features = ["serialize-rustc"]}
|
cookie = {version = "0.2.5", features = ["serialize-rustc"]}
|
||||||
|
|
12
ports/cef/Cargo.lock
generated
12
ports/cef/Cargo.lock
generated
|
@ -971,7 +971,7 @@ dependencies = [
|
||||||
"libc 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"uuid 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"uuid 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1321,7 +1321,7 @@ dependencies = [
|
||||||
"unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"util 0.0.1",
|
"util 0.0.1",
|
||||||
"uuid 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"uuid 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"webrender_traits 0.5.1 (git+https://github.com/servo/webrender)",
|
"webrender_traits 0.5.1 (git+https://github.com/servo/webrender)",
|
||||||
"websocket 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"websocket 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
@ -1357,7 +1357,7 @@ dependencies = [
|
||||||
"serde_macros 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_macros 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"util 0.0.1",
|
"util 0.0.1",
|
||||||
"uuid 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"uuid 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"websocket 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"websocket 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1791,7 +1791,7 @@ dependencies = [
|
||||||
"tinyfiledialogs 0.1.0 (git+https://github.com/jdm/tinyfiledialogs)",
|
"tinyfiledialogs 0.1.0 (git+https://github.com/jdm/tinyfiledialogs)",
|
||||||
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"util 0.0.1",
|
"util 0.0.1",
|
||||||
"uuid 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"uuid 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"webrender_traits 0.5.1 (git+https://github.com/servo/webrender)",
|
"webrender_traits 0.5.1 (git+https://github.com/servo/webrender)",
|
||||||
"websocket 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"websocket 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"xml5ever 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"xml5ever 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -2331,7 +2331,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uuid"
|
name = "uuid"
|
||||||
version = "0.3.0"
|
version = "0.3.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -2432,7 +2432,7 @@ dependencies = [
|
||||||
"script_traits 0.0.1",
|
"script_traits 0.0.1",
|
||||||
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"util 0.0.1",
|
"util 0.0.1",
|
||||||
"uuid 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"uuid 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"webdriver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"webdriver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue