storage: Move shared functionality to base (#39419)

Part of #39418. See that PR for a full description.

Moves:
- `read_json_from_file`
- `write_json_to_file`
- `IpcSendResult`
- `IpcSend`

Renames:
- `CoreResourceThreadPool` to `ThreadPool` (shorter and more
descriptive, as we use it for more than the core resource thread now)

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
This commit is contained in:
Ashwin Naren 2025-09-22 06:59:36 -07:00 committed by GitHub
parent ba208b19cc
commit f766b66a97
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 254 additions and 98 deletions

View file

@ -6,6 +6,7 @@ use std::borrow::Cow;
use std::collections::VecDeque;
use std::rc::Rc;
use base::IpcSend;
use base::id::CookieStoreId;
use cookie::{Cookie, SameSite};
use dom_struct::dom_struct;
@ -16,7 +17,7 @@ use ipc_channel::router::ROUTER;
use itertools::Itertools;
use js::jsval::NullValue;
use net_traits::CookieSource::NonHTTP;
use net_traits::{CookieAsyncResponse, CookieData, CoreResourceMsg, IpcSend};
use net_traits::{CookieAsyncResponse, CookieData, CoreResourceMsg};
use script_bindings::script_runtime::CanGc;
use servo_url::ServoUrl;

View file

@ -6,6 +6,7 @@ use std::sync::Arc;
use std::sync::atomic::AtomicBool;
use std::thread::{self, JoinHandle};
use base::IpcSend;
use base::id::{BrowsingContextId, PipelineId, WebViewId};
use constellation_traits::{WorkerGlobalScopeInit, WorkerScriptLoadOrigin};
use crossbeam_channel::{Receiver, Sender, unbounded};
@ -18,13 +19,13 @@ use ipc_channel::router::ROUTER;
use js::jsapi::{Heap, JS_AddInterruptCallback, JSContext, JSObject};
use js::jsval::UndefinedValue;
use js::rust::{CustomAutoRooter, CustomAutoRooterGuard, HandleValue};
use net_traits::Metadata;
use net_traits::image_cache::ImageCache;
use net_traits::policy_container::PolicyContainer;
use net_traits::request::{
CredentialsMode, Destination, InsecureRequestsPolicy, ParserMetadata, Referrer, RequestBuilder,
RequestMode,
};
use net_traits::{IpcSend, Metadata};
use servo_rand::random;
use servo_url::{ImmutableOrigin, ServoUrl};
use style::thread_state::{self, ThreadState};

View file

@ -14,7 +14,7 @@ use std::time::Duration;
use base::cross_process_instant::CrossProcessInstant;
use base::id::WebViewId;
use base::{Epoch, generic_channel};
use base::{Epoch, IpcSend, generic_channel};
use canvas_traits::canvas::CanvasId;
use canvas_traits::webgl::{WebGLContextId, WebGLMsg};
use chrono::Local;
@ -41,7 +41,7 @@ use net_traits::policy_container::PolicyContainer;
use net_traits::pub_domains::is_pub_domain;
use net_traits::request::{InsecureRequestsPolicy, RequestBuilder};
use net_traits::response::HttpsState;
use net_traits::{FetchResponseListener, IpcSend, ReferrerPolicy};
use net_traits::{FetchResponseListener, ReferrerPolicy};
use percent_encoding::percent_decode;
use profile_traits::ipc as profile_ipc;
use profile_traits::time::TimerMetadataFrameType;

View file

@ -14,6 +14,7 @@ use std::thread::JoinHandle;
use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
use std::{mem, ptr};
use base::IpcSend;
use base::id::{
BlobId, BroadcastChannelRouterId, MessagePortId, MessagePortRouterId, PipelineId,
ServiceWorkerId, ServiceWorkerRegistrationId, WebViewId,
@ -52,8 +53,8 @@ use net_traits::policy_container::PolicyContainer;
use net_traits::request::{InsecureRequestsPolicy, Referrer, RequestBuilder};
use net_traits::response::HttpsState;
use net_traits::{
CoreResourceMsg, CoreResourceThread, FetchResponseListener, IpcSend, ReferrerPolicy,
ResourceThreads, fetch_async,
CoreResourceMsg, CoreResourceThread, FetchResponseListener, ReferrerPolicy, ResourceThreads,
fetch_async,
};
use profile_traits::{ipc as profile_ipc, mem as profile_mem, time as profile_time};
use rustc_hash::{FxBuildHasher, FxHashMap};

View file

@ -5,6 +5,7 @@
use std::cell::Cell;
use std::cmp::Ordering;
use base::IpcSend;
use base::id::HistoryStateId;
use constellation_traits::{
ScriptToConstellationMessage, StructuredSerializedData, TraversalDirection,
@ -13,7 +14,7 @@ use dom_struct::dom_struct;
use js::jsapi::Heap;
use js::jsval::{JSVal, NullValue, UndefinedValue};
use js::rust::{HandleValue, MutableHandleValue};
use net_traits::{CoreResourceMsg, IpcSend};
use net_traits::CoreResourceMsg;
use profile_traits::ipc;
use profile_traits::ipc::channel;
use servo_url::ServoUrl;

View file

@ -11,7 +11,7 @@ use std::ptr::NonNull;
use std::str::FromStr;
use std::{f64, ptr};
use base::generic_channel;
use base::{IpcSend, generic_channel};
use dom_struct::dom_struct;
use embedder_traits::{
EmbedderMsg, FilterPattern, FormControl as EmbedderFormControl, InputMethodType, RgbColor,
@ -26,9 +26,9 @@ use js::jsapi::{
use js::jsval::UndefinedValue;
use js::rust::wrappers::{CheckRegExpSyntax, ExecuteRegExpNoStatics, ObjectIsRegExp};
use js::rust::{HandleObject, MutableHandleObject};
use net_traits::CoreResourceMsg;
use net_traits::blob_url_store::get_blob_origin;
use net_traits::filemanager_thread::{FileManagerResult, FileManagerThreadMsg};
use net_traits::{CoreResourceMsg, IpcSend};
use script_bindings::codegen::GenericBindings::CharacterDataBinding::CharacterDataMethods;
use script_bindings::codegen::GenericBindings::DocumentBinding::DocumentMethods;
use servo_config::pref;

View file

@ -4,9 +4,9 @@
use std::cell::Cell;
use base::IpcSend;
use dom_struct::dom_struct;
use ipc_channel::ipc::IpcSender;
use net_traits::IpcSend;
use net_traits::indexeddb_thread::{IndexedDBThreadMsg, KeyPath, SyncOperation};
use profile_traits::ipc;
use stylo_atoms::Atom;

View file

@ -2,11 +2,11 @@
* 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 base::IpcSend;
use dom_struct::dom_struct;
use js::gc::MutableHandleValue;
use js::jsval::NullValue;
use js::rust::HandleValue;
use net_traits::IpcSend;
use net_traits::indexeddb_thread::{
AsyncOperation, AsyncReadOnlyOperation, AsyncReadWriteOperation, IndexedDBKeyType,
IndexedDBThreadMsg, SyncOperation,

View file

@ -2,11 +2,11 @@
* 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 base::IpcSend;
use dom_struct::dom_struct;
use ipc_channel::router::ROUTER;
use js::jsval::UndefinedValue;
use js::rust::HandleValue;
use net_traits::IpcSend;
use net_traits::indexeddb_thread::{BackendResult, IndexedDBThreadMsg, SyncOperation};
use profile_traits::ipc;
use script_bindings::conversions::SafeToJSValConvertible;

View file

@ -5,12 +5,12 @@
use std::cell::Cell;
use std::iter::repeat_n;
use base::IpcSend;
use dom_struct::dom_struct;
use ipc_channel::router::ROUTER;
use js::jsapi::Heap;
use js::jsval::{DoubleValue, JSVal, ObjectValue, UndefinedValue};
use js::rust::HandleValue;
use net_traits::IpcSend;
use net_traits::indexeddb_thread::{
AsyncOperation, AsyncReadOnlyOperation, BackendError, BackendResult, IndexedDBKeyType,
IndexedDBRecord, IndexedDBThreadMsg, IndexedDBTxnMode, PutItemResult,

View file

@ -5,9 +5,9 @@
use std::cell::Cell;
use std::collections::HashMap;
use base::IpcSend;
use dom_struct::dom_struct;
use ipc_channel::ipc::IpcSender;
use net_traits::IpcSend;
use net_traits::indexeddb_thread::{IndexedDBThreadMsg, KeyPath, SyncOperation};
use profile_traits::ipc;
use script_bindings::codegen::GenericUnionTypes::StringOrStringSequence;

View file

@ -7,6 +7,7 @@ use std::sync::atomic::AtomicBool;
use std::thread::{self, JoinHandle};
use std::time::{Duration, Instant};
use base::IpcSend;
use base::generic_channel::GenericSender;
use base::id::PipelineId;
use constellation_traits::{
@ -20,10 +21,10 @@ use ipc_channel::ipc::IpcReceiver;
use ipc_channel::router::ROUTER;
use js::jsapi::{JS_AddInterruptCallback, JSContext};
use js::jsval::UndefinedValue;
use net_traits::CustomResponseMediator;
use net_traits::request::{
CredentialsMode, Destination, InsecureRequestsPolicy, ParserMetadata, Referrer, RequestBuilder,
};
use net_traits::{CustomResponseMediator, IpcSend};
use servo_config::pref;
use servo_rand::random;
use servo_url::ServoUrl;

View file

@ -5,6 +5,7 @@
use std::cell::{Cell, RefCell};
use std::ops::Deref;
use base::IpcSend;
use base::id::{PipelineId, WebViewId};
use html5ever::buffer_queue::BufferQueue;
use html5ever::tokenizer::states::RawKind;
@ -18,7 +19,7 @@ use net_traits::policy_container::PolicyContainer;
use net_traits::request::{
CorsSettings, CredentialsMode, Destination, InsecureRequestsPolicy, ParserMetadata, Referrer,
};
use net_traits::{CoreResourceMsg, FetchChannels, IpcSend, ReferrerPolicy, ResourceThreads};
use net_traits::{CoreResourceMsg, FetchChannels, ReferrerPolicy, ResourceThreads};
use servo_url::{ImmutableOrigin, ServoUrl};
use crate::dom::bindings::reflector::DomGlobal;

View file

@ -4,11 +4,12 @@
use std::default::Default;
use base::IpcSend;
use dom_struct::dom_struct;
use js::rust::HandleObject;
use net_traits::CoreResourceMsg;
use net_traits::blob_url_store::{get_blob_origin, parse_blob_url};
use net_traits::filemanager_thread::FileManagerThreadMsg;
use net_traits::{CoreResourceMsg, IpcSend};
use profile_traits::ipc;
use servo_url::ServoUrl;
use uuid::Uuid;

View file

@ -9,6 +9,7 @@ use std::sync::Arc;
use std::sync::atomic::{AtomicBool, Ordering};
use std::time::Duration;
use base::IpcSend;
use base::cross_process_instant::CrossProcessInstant;
use base::id::{PipelineId, PipelineNamespace};
use constellation_traits::WorkerGlobalScopeInit;
@ -21,12 +22,12 @@ use ipc_channel::ipc::IpcSender;
use js::jsval::UndefinedValue;
use js::panic::maybe_resume_unwind;
use js::rust::{HandleValue, MutableHandleValue, ParentRuntime};
use net_traits::ReferrerPolicy;
use net_traits::policy_container::PolicyContainer;
use net_traits::request::{
CredentialsMode, Destination, InsecureRequestsPolicy, ParserMetadata,
RequestBuilder as NetRequestInit,
};
use net_traits::{IpcSend, ReferrerPolicy};
use profile_traits::mem::{ProcessReports, perform_memory_report};
use servo_url::{MutableOrigin, ServoUrl};
use timers::TimerScheduler;

View file

@ -18,12 +18,12 @@ use std::sync::Arc;
use std::sync::atomic::{AtomicIsize, Ordering};
use std::thread;
use base::IpcSend;
use base::id::PipelineId;
use crossbeam_channel::{Receiver, Sender, unbounded};
use dom_struct::dom_struct;
use js::jsapi::{GCReason, JS_GC, JS_GetGCParameter, JSGCParamKey, JSTracer};
use malloc_size_of::malloc_size_of_is_0;
use net_traits::IpcSend;
use net_traits::request::{Destination, RequestBuilder, RequestMode};
use rustc_hash::FxHashMap;
use servo_url::{ImmutableOrigin, ServoUrl};

View file

@ -6,6 +6,7 @@ use std::collections::{HashMap, HashSet};
use std::ffi::CString;
use std::ptr::NonNull;
use base::IpcSend;
use base::generic_channel::GenericSender;
use base::id::{BrowsingContextId, PipelineId};
use cookie::Cookie;
@ -27,7 +28,6 @@ use net_traits::CookieSource::{HTTP, NonHTTP};
use net_traits::CoreResourceMsg::{
DeleteCookie, DeleteCookies, GetCookiesDataForUrl, SetCookieForUrl,
};
use net_traits::IpcSend;
use script_bindings::codegen::GenericBindings::ShadowRootBinding::ShadowRootMethods;
use script_bindings::conversions::is_array_like;
use script_bindings::num::Finite;