diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-06-09 18:14:30 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-09 18:14:30 -0500 |
commit | 6f9016cf3edce828bf0edb5411b963d7c9f2d209 (patch) | |
tree | 3be1d020b5ab5220393e075bf7af0843d257c932 /components/script/dom | |
parent | ebb1cb30f758273ba3efbe1e1ae3a504faed8293 (diff) | |
parent | f8fa9aaf422d8bfca757d835bc073e769ed8e003 (diff) | |
download | servo-6f9016cf3edce828bf0edb5411b963d7c9f2d209.tar.gz servo-6f9016cf3edce828bf0edb5411b963d7c9f2d209.zip |
Auto merge of #11552 - izgzhen:add-testing-fix-filemanager, r=Manishearth
Improve implementation and add testing regarding file manager thread
First there is a more completed unit test. And in the test running, I found a runtime error `Serde(Custom("bincode does not support Deserializer::deserialize))` when reading response from file manage thread. I analyzed a bit and found that it is probably caused by the `Uuid` field. I temporarily work around it by making the `Id` essentially a string wrapped inside `SelectedFileId`.
Related to PR #11131.
<!-- 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
<!-- Either: -->
- [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="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11552)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom')
-rw-r--r-- | components/script/dom/bindings/trace.rs | 2 | ||||
-rw-r--r-- | components/script/dom/blob.rs | 9 |
2 files changed, 6 insertions, 5 deletions
diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index f33a8834a08..2a9f0e52134 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -57,6 +57,7 @@ use js::rust::Runtime; use layout_interface::LayoutRPC; use libc; use msg::constellation_msg::{FrameType, PipelineId, SubpageId, WindowSizeData, WindowSizeType, ReferrerPolicy}; +use net_traits::filemanager_thread::SelectedFileId; use net_traits::image::base::{Image, ImageMetadata}; use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread}; use net_traits::response::HttpsState; @@ -324,6 +325,7 @@ no_jsmanaged_fields!(USVString); no_jsmanaged_fields!(ReferrerPolicy); no_jsmanaged_fields!(ResourceThreads); no_jsmanaged_fields!(SystemTime); +no_jsmanaged_fields!(SelectedFileId); impl JSTraceable for Box<ScriptChan + Send> { #[inline] diff --git a/components/script/dom/blob.rs b/components/script/dom/blob.rs index b89aa3b9ac2..d8beec236a8 100644 --- a/components/script/dom/blob.rs +++ b/components/script/dom/blob.rs @@ -14,14 +14,13 @@ use dom::bindings::str::DOMString; use encoding::all::UTF_8; use encoding::types::{EncoderTrap, Encoding}; use ipc_channel::ipc; -use net_traits::filemanager_thread::FileManagerThreadMsg; +use net_traits::filemanager_thread::{FileManagerThreadMsg, SelectedFileId}; use num_traits::ToPrimitive; use std::ascii::AsciiExt; use std::borrow::ToOwned; use std::cell::Cell; use std::cmp::{max, min}; use std::sync::Arc; -use uuid::Uuid; #[derive(Clone, JSTraceable)] pub struct DataSlice { @@ -95,7 +94,7 @@ impl DataSlice { #[derive(Clone, JSTraceable)] pub enum BlobImpl { /// File-based, cached backend - File(Uuid, DOMRefCell<Option<DataSlice>>), + File(SelectedFileId, DOMRefCell<Option<DataSlice>>), /// Memory-based backend Memory(DataSlice), } @@ -107,7 +106,7 @@ impl BlobImpl { } /// Construct file-backed BlobImpl from File ID - pub fn new_from_file(file_id: Uuid) -> BlobImpl { + pub fn new_from_file(file_id: SelectedFileId) -> BlobImpl { BlobImpl::File(file_id, DOMRefCell::new(None)) } @@ -184,7 +183,7 @@ impl Blob { } } -fn read_file(global: GlobalRef, id: Uuid) -> Result<DataSlice, ()> { +fn read_file(global: GlobalRef, id: SelectedFileId) -> Result<DataSlice, ()> { let file_manager = global.filemanager_thread(); let (chan, recv) = ipc::channel().map_err(|_|())?; let _ = file_manager.send(FileManagerThreadMsg::ReadFile(chan, id)); |