Files
servo/components/storage/storage_thread.rs
Taym Haddadi 628c9c1170 storage: construct and shut down public/private thread groups independently (#43147)
This PR makes public and private storage thread groups independent.

previously, `new_storage_threads()` returned two `StorageThreads`
handles, but both handles were backed by the same underlying storage
worker group. this meant Servo carried a public/private distinction
through the API and wiring layers, while both sides still talked to the
same storage backend threads.


Testing: Added shutdown_storage_group test, and should not effect WTP
test.

---------

Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
2026-03-13 10:03:30 +00:00

47 lines
1.7 KiB
Rust

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use std::path::PathBuf;
use base::generic_channel::GenericSender;
use profile_traits::mem::ProfilerChan as MemProfilerChan;
use storage_traits::StorageThreads;
use storage_traits::client_storage::ClientStorageThreadMessage;
use storage_traits::indexeddb::IndexedDBThreadMsg;
use storage_traits::webstorage_thread::WebStorageThreadMsg;
use crate::{ClientStorageThreadFactory, IndexedDBThreadFactory, WebStorageThreadFactory};
fn new_storage_thread_group(
mem_profiler_chan: MemProfilerChan,
config_dir: Option<PathBuf>,
label: &str,
) -> StorageThreads {
let client_storage: GenericSender<ClientStorageThreadMessage> =
ClientStorageThreadFactory::new(config_dir.clone());
let idb: GenericSender<IndexedDBThreadMsg> = IndexedDBThreadFactory::new(
config_dir.clone(),
mem_profiler_chan.clone(),
format!("indexedDB-reporter-{label}"),
);
let web_storage: GenericSender<WebStorageThreadMsg> = WebStorageThreadFactory::new(
config_dir,
mem_profiler_chan,
format!("storage-reporter-{label}"),
);
StorageThreads::new(client_storage, idb, web_storage)
}
pub fn new_storage_threads(
mem_profiler_chan: MemProfilerChan,
config_dir: Option<PathBuf>,
) -> (StorageThreads, StorageThreads) {
let private_storage_threads =
new_storage_thread_group(mem_profiler_chan.clone(), config_dir.clone(), "private");
let public_storage_threads = new_storage_thread_group(mem_profiler_chan, config_dir, "public");
(private_storage_threads, public_storage_threads)
}