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 profile_traits::mem::ProfilerChan as MemProfilerChan;
9use storage_traits::StorageThreads;
10use storage_traits::client_storage::ClientStorageThreadMessage;
11use storage_traits::indexeddb::IndexedDBThreadMsg;
12use storage_traits::webstorage_thread::WebStorageThreadMsg;
13
14use crate::{ClientStorageThreadFactory, IndexedDBThreadFactory, WebStorageThreadFactory};
15
16pub fn new_storage_threads(
17    mem_profiler_chan: MemProfilerChan,
18    config_dir: Option<PathBuf>,
19) -> (StorageThreads, StorageThreads) {
20    let client_storage: GenericSender<ClientStorageThreadMessage> =
21        ClientStorageThreadFactory::new(config_dir.clone());
22    let idb: GenericSender<IndexedDBThreadMsg> = IndexedDBThreadFactory::new(config_dir.clone());
23    let web_storage: GenericSender<WebStorageThreadMsg> =
24        WebStorageThreadFactory::new(config_dir, mem_profiler_chan);
25    (
26        StorageThreads::new(client_storage.clone(), idb.clone(), web_storage.clone()),
27        StorageThreads::new(client_storage, idb, web_storage),
28    )
29}