From bc2c7bd5e19e680f00dcba42588fafae09fe02fc Mon Sep 17 00:00:00 2001 From: Aneesh Agrawal Date: Fri, 10 Apr 2015 07:41:54 -0500 Subject: [PATCH] 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 --- servo/components/compositing/constellation.rs | 3 +-- servo/components/net/image_cache_task.rs | 12 ------------ servo/components/net_traits/image_cache_task.rs | 12 ++++++++++++ servo/tests/unit/net/image_cache_task.rs | 2 +- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/servo/components/compositing/constellation.rs b/servo/components/compositing/constellation.rs index 7485f21e5bff..9f0e98e2e309 100644 --- a/servo/components/compositing/constellation.rs +++ b/servo/components/compositing/constellation.rs @@ -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; diff --git a/servo/components/net/image_cache_task.rs b/servo/components/net/image_cache_task.rs index 5897ee50fb2b..a97d29b8d660 100644 --- a/servo/components/net/image_cache_task.rs +++ b/servo/components/net/image_cache_task.rs @@ -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: F) -> Sender where F: FnOnce(Receiver) + Send + 'static, A: Send + 'static diff --git a/servo/components/net_traits/image_cache_task.rs b/servo/components/net_traits/image_cache_task.rs index 2ce4d78dbf41..3dfbed3fde69 100644 --- a/servo/components/net_traits/image_cache_task.rs +++ b/servo/components/net_traits/image_cache_task.rs @@ -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, ()> { let (response_chan, response_port) = channel(); resource_task.send(ControlMsg::Load(LoadData::new(url.clone(), response_chan))).unwrap(); diff --git a/servo/tests/unit/net/image_cache_task.rs b/servo/tests/unit/net/image_cache_task.rs index a57b0361e6c7..c384411fb99f 100644 --- a/servo/tests/unit/net/image_cache_task.rs +++ b/servo/tests/unit/net/image_cache_task.rs @@ -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};