diff options
Diffstat (limited to 'components/net')
-rw-r--r-- | components/net/Cargo.toml | 1 | ||||
-rw-r--r-- | components/net/image_cache.rs | 26 |
2 files changed, 25 insertions, 2 deletions
diff --git a/components/net/Cargo.toml b/components/net/Cargo.toml index 04ef7ac190c..9af310f32bc 100644 --- a/components/net/Cargo.toml +++ b/components/net/Cargo.toml @@ -75,6 +75,7 @@ webpki-roots = { workspace = true } webrender_api = { workspace = true } [dev-dependencies] +embedder_traits = { workspace = true, features = ["baked-default-resources"] } flate2 = "1" futures = { version = "0.3", features = ["compat"] } hyper = { workspace = true, features = ["full"] } diff --git a/components/net/image_cache.rs b/components/net/image_cache.rs index eab2f9c08fe..e3d31b11736 100644 --- a/components/net/image_cache.rs +++ b/components/net/image_cache.rs @@ -431,7 +431,7 @@ pub struct ImageCacheImpl { store: Arc<Mutex<ImageCacheStore>>, /// Thread pool for image decoding - thread_pool: CoreResourceThreadPool, + thread_pool: Arc<CoreResourceThreadPool>, } impl ImageCache for ImageCacheImpl { @@ -454,7 +454,10 @@ impl ImageCache for ImageCacheImpl { placeholder_url: ServoUrl::parse("chrome://resources/rippy.png").unwrap(), compositor_api, })), - thread_pool: CoreResourceThreadPool::new(thread_count, "ImageCache".to_string()), + thread_pool: Arc::new(CoreResourceThreadPool::new( + thread_count, + "ImageCache".to_string(), + )), } } @@ -651,6 +654,25 @@ impl ImageCache for ImageCacheImpl { }, } } + + fn create_new_image_cache( + &self, + compositor_api: CrossProcessCompositorApi, + ) -> Arc<dyn ImageCache> { + let store = self.store.lock().unwrap(); + let placeholder_image = store.placeholder_image.clone(); + let placeholder_url = store.placeholder_url.clone(); + Arc::new(ImageCacheImpl { + store: Arc::new(Mutex::new(ImageCacheStore { + pending_loads: AllPendingLoads::new(), + completed_loads: HashMap::new(), + placeholder_image, + placeholder_url, + compositor_api, + })), + thread_pool: self.thread_pool.clone(), + }) + } } impl ImageCacheImpl { |