mirror of
https://github.com/servo/servo.git
synced 2025-08-02 04:00:32 +01:00
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 -->
This commit is contained in:
commit
6f9016cf3e
7 changed files with 100 additions and 73 deletions
|
@ -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]
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue