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::client_storage::ClientStorageThreadMessage;
12use storage_traits::indexeddb::IndexedDBThreadMsg;
13use storage_traits::webstorage_thread::WebStorageThreadMsg;
14
15use crate::{ClientStorageThreadFactory, IndexedDBThreadFactory, WebStorageThreadFactory};
16
17#[allow(clippy::too_many_arguments)]
18pub fn new_storage_threads(
19    mem_profiler_chan: MemProfilerChan,
20    config_dir: Option<PathBuf>,
21) -> (StorageThreads, StorageThreads) {
22    let client_storage: GenericSender<ClientStorageThreadMessage> =
23        ClientStorageThreadFactory::new(config_dir.clone());
24    let idb: IpcSender<IndexedDBThreadMsg> = IndexedDBThreadFactory::new(config_dir.clone());
25    let web_storage: GenericSender<WebStorageThreadMsg> =
26        WebStorageThreadFactory::new(config_dir, mem_profiler_chan);
27    (
28        StorageThreads::new(client_storage.clone(), idb.clone(), web_storage.clone()),
29        StorageThreads::new(client_storage, idb, web_storage),
30    )
31}