Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the dependency of fetch on filemanager_thread::UIProvider. #14275

Merged
merged 5 commits into from Nov 22, 2016

Factor out FileManager::promote_memory().

  • Loading branch information
Ms2ger committed Nov 21, 2016
commit f672bf9eabdfcf2eca4305c577599900fbb77ea9
@@ -150,6 +150,17 @@ impl<UI: 'static + UIProvider> FileManager<UI> {
})
}

pub fn promote_memory(&self,
blob_buf: BlobBuf,
set_valid: bool,
sender: IpcSender<Result<Uuid, BlobURLStoreError>>,
origin: FileOrigin) {
let store = self.store.clone();
spawn_named("transfer memory".to_owned(), move || {
store.promote_memory(blob_buf, set_valid, sender, origin);
})
}

/// Message handler
pub fn handle(&self, msg: FileManagerThreadMsg, cancel_listener: Option<CancellationListener>) {
match msg {
@@ -171,10 +182,7 @@ impl<UI: 'static + UIProvider> FileManager<UI> {
self.read_file(sender, id, check_url_validity, origin, cancel_listener);
}
FileManagerThreadMsg::PromoteMemory(blob_buf, set_valid, sender, origin) => {
let store = self.store.clone();
spawn_named("transfer memory".to_owned(), move || {
store.promote_memory(blob_buf, set_valid, sender, origin);
})
self.promote_memory(blob_buf, set_valid, sender, origin);
}
FileManagerThreadMsg::AddSlicedURLEntry(id, rel_pos, sender, origin) =>{
self.store.add_sliced_url_entry(id, rel_pos, sender, origin);
@@ -98,7 +98,6 @@ fn test_fetch_aboutblank() {
fn test_fetch_blob() {
use ipc_channel::ipc;
use net_traits::blob_url_store::BlobBuf;
use net_traits::filemanager_thread::FileManagerThreadMsg;

let context = new_fetch_context(None);

@@ -113,8 +112,7 @@ fn test_fetch_blob() {
let origin = ServoUrl::parse("http://www.example.org/").unwrap();

let (sender, receiver) = ipc::channel().unwrap();
let message = FileManagerThreadMsg::PromoteMemory(blob_buf, true, sender, "http://www.example.org".into());
context.filemanager.handle(message, None);
context.filemanager.promote_memory(blob_buf, true, sender, "http://www.example.org".into());
let id = receiver.recv().unwrap().unwrap();
let url = ServoUrl::parse(&format!("blob:{}{}", origin.as_str(), id.simple())).unwrap();

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.