servo: Merge #5558 - Remove compositor dependency on net crate (from aneeshusa:remove-compositor-dependency-on-net); r=jdm

Move the ImageCacheTaskClient trait and impl to net_traits. Fixes #5551.

Source-Repo: https://github.com/servo/servo
Source-Revision: 6903955b9835b7cfdff6378e4a547cdad1589443
This commit is contained in:
Aneesh Agrawal 2015-04-10 07:41:54 -05:00
Родитель c902be4787
Коммит bc2c7bd5e1
4 изменённых файлов: 14 добавлений и 15 удалений

Просмотреть файл

@ -20,9 +20,8 @@ use msg::constellation_msg::{IFrameSandboxState, MozBrowserEvent, NavigationDire
use msg::constellation_msg::{Key, KeyState, KeyModifiers, LoadData};
use msg::constellation_msg::{SubpageId, WindowSizeData};
use msg::constellation_msg::{self, ConstellationChan, Failure};
use net::image_cache_task::ImageCacheTaskClient;
use net_traits::{self, ResourceTask};
use net_traits::image_cache_task::ImageCacheTask;
use net_traits::image_cache_task::{ImageCacheTask, ImageCacheTaskClient};
use net_traits::storage_task::{StorageTask, StorageTaskMsg};
use profile::mem;
use profile::time;

Просмотреть файл

@ -395,18 +395,6 @@ impl ImageCache {
}
}
pub trait ImageCacheTaskClient {
fn exit(&self);
}
impl ImageCacheTaskClient for ImageCacheTask {
fn exit(&self) {
let (response_chan, response_port) = channel();
self.send(Msg::Exit(response_chan));
response_port.recv().unwrap();
}
}
pub fn spawn_listener<F, A>(f: F) -> Sender<A>
where F: FnOnce(Receiver<A>) + Send + 'static,
A: Send + 'static

Просмотреть файл

@ -70,6 +70,18 @@ impl ImageCacheTask {
}
}
pub trait ImageCacheTaskClient {
fn exit(&self);
}
impl ImageCacheTaskClient for ImageCacheTask {
fn exit(&self) {
let (response_chan, response_port) = channel();
self.send(Msg::Exit(response_chan));
response_port.recv().unwrap();
}
}
pub fn load_image_data(url: Url, resource_task: ResourceTask, placeholder: &[u8]) -> Result<Vec<u8>, ()> {
let (response_chan, response_port) = channel();
resource_task.send(ControlMsg::Load(LoadData::new(url.clone(), response_chan))).unwrap();

Просмотреть файл

@ -8,7 +8,7 @@ use net_traits::image_cache_task::Msg::*;
use net::resource_task::start_sending;
use net_traits::{ControlMsg, Metadata, ProgressMsg, ResourceTask};
use net_traits::image_cache_task::{ImageCacheTask, ImageResponseMsg, Msg};
use net_traits::image_cache_task::{ImageCacheTask, ImageCacheTaskClient, ImageResponseMsg, Msg};
use net_traits::ProgressMsg::{Payload, Done};
use profile::time;
use std::sync::mpsc::{Sender, channel, Receiver};