storage/
storage_thread.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5use std::path::PathBuf;
6
7use base::generic_channel::GenericSender;
8use ipc_channel::ipc::IpcSender;
9use profile_traits::mem::ProfilerChan as MemProfilerChan;
10use storage_traits::StorageThreads;
11use storage_traits::indexeddb_thread::IndexedDBThreadMsg;
12use storage_traits::webstorage_thread::WebStorageThreadMsg;
13
14use crate::{IndexedDBThreadFactory, WebStorageThreadFactory};
15
16#[allow(clippy::too_many_arguments)]
17pub fn new_storage_threads(
18    mem_profiler_chan: MemProfilerChan,
19    config_dir: Option<PathBuf>,
20) -> (StorageThreads, StorageThreads) {
21    let idb: IpcSender<IndexedDBThreadMsg> = IndexedDBThreadFactory::new(config_dir.clone());
22    let web_storage: GenericSender<WebStorageThreadMsg> =
23        WebStorageThreadFactory::new(config_dir, mem_profiler_chan);
24    (
25        StorageThreads::new(web_storage.clone(), idb.clone()),
26        StorageThreads::new(web_storage, idb),
27    )
28}