| // Copyright 2017 The Chromium Authors |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| module network.mojom; |
| |
| import "mojo/public/mojom/base/file.mojom"; |
| import "mojo/public/mojom/base/file_path.mojom"; |
| import "mojo/public/mojom/base/memory_pressure_level.mojom"; |
| import "mojo/public/mojom/base/time.mojom"; |
| import "services/network/public/mojom/address_list.mojom"; |
| import "services/network/public/mojom/host_resolver.mojom"; |
| import "services/network/public/mojom/network_change_manager.mojom"; |
| import "services/network/public/mojom/network_interface_change_listener.mojom"; |
| import "services/network/public/mojom/network_param.mojom"; |
| import "services/network/public/mojom/network_types.mojom"; |
| import "services/network/public/mojom/http_cache_backend_file_operations.mojom"; |
| import "services/network/public/mojom/ip_endpoint.mojom"; |
| import "services/network/public/mojom/transferable_socket.mojom"; |
| |
| // Maps to net::RuleBasedHostResolverProc::Rule::ResolverType. |
| // |
| // TODO(crbug.com/40822747) Deduplicate this enum's definition. |
| enum ResolverType { |
| kResolverTypeFail, |
| kResolverTypeFailTimeout, |
| kResolverTypeSystem, |
| kResolverTypeIPLiteral, |
| kResolverTypeDirectLookup, |
| }; |
| |
| // `dns_aliases` is a list of aliases read from DNS records, e.g. CNAME |
| // aliases, and is intended to preserve the alias chain in reverse, from |
| // canonical name (i.e. address record name) through to query name. |
| struct Rule { |
| ResolverType resolver_type; |
| string host_pattern; |
| string replacement; |
| int32 host_resolver_flags; |
| array<string> dns_aliases; |
| }; |
| |
| // An entry in the "simple" backend of an HTTP cache. |
| interface SimpleCacheEntry { |
| // Writes data into the entry. See disk_cache::Entry::WriteData for details. |
| WriteData(int32 index, |
| int32 offset, |
| array<uint8> data, |
| bool truncate) => (int32 result); |
| |
| // Reads data from the entry. See disk_cache::Entry::ReadData for details. |
| ReadData(int32 index, |
| int32 offset, |
| uint32 length) => (array<uint8> data, int32 result); |
| |
| // Writes data into the entry. See disk_cache::Entry::WriteSparseData for |
| // details. |
| WriteSparseData(int32 offset, array<uint8> data) => (int32 result); |
| |
| // Reads data from the entry. See disk_cache::Entry::ReadSparseData for |
| // details. |
| ReadSparseData(int32 offset, |
| uint32 length) => (array<uint8> data, int32 result); |
| |
| // Closes the entry. |
| Close() => (); |
| }; |
| |
| // Represents the result of opening an entry. |
| struct SimpleCacheOpenEntryResult { |
| // Represents the status of the open operation. |
| int32 error; |
| |
| // The key of the entry. This is set if and only if `error` is net::OK. |
| string key; |
| |
| // An remote pointer to the opened entry. Non-null if and only if `error` is |
| // net::OK. |
| pending_remote<SimpleCacheEntry>? entry; |
| }; |
| |
| // An interface to enumerate entries in a SimpleCache. |
| interface SimpleCacheEntryEnumerator { |
| // Returns the next entry. `result.error` is net::ERR_FAILED at the end of |
| // the enumeration. |
| GetNext() => (SimpleCacheOpenEntryResult result); |
| }; |
| |
| // The "simple" backend of an HTTP cache. |
| interface SimpleCache { |
| // Creates a new entry. |
| CreateEntry(string key) => |
| (pending_remote<SimpleCacheEntry>? entry, int32 error); |
| |
| // Opens an entry. |
| OpenEntry(string key) => |
| (pending_remote<SimpleCacheEntry>? entry, int32 error); |
| |
| // Marks the entry for deletion. |
| DoomEntry(string key) => (int32 result); |
| |
| // Marks all the entries for deletion. |
| DoomAllEntries() => (int32 result); |
| |
| // Enumerate entries in the backend. |
| EnumerateEntries(pending_receiver<SimpleCacheEntryEnumerator> receiver); |
| |
| // Detaches the cache backend. Once this is called, no methods can be |
| // called in the future. This also flushes tasks in the worker pool. |
| // You do NOT need to call this - the cache backend is automatically detached |
| // when the remote endpoint is detached. This is to ensure that all the tasks |
| // (e.g., writing to the index) are done. |
| Detach() => (); |
| }; |
| |
| // Testing interface to the network service. |
| // Methods are sometimes synchronous to avoid race conditions since this test |
| // interface is on a different pipe than interfaces which are impacted. |
| interface NetworkServiceTest { |
| // Adds the given host resolver rules in the process where the network service |
| // is running. |
| [Sync] |
| AddRules(array<Rule> rules) => (); |
| |
| // Simulates a network connection type change. The new connection type will be |
| // updated to |type| and broadcasts will be sent to |
| // NetworkConnectionManagerClient implementations. |
| SimulateNetworkChange(ConnectionType type) => (); |
| |
| // Simulates a network quality change. The new effective connection type will |
| // be updated to |type| and broadcasts will be sent to |
| // NetworkQualityEstimatorManagerClient implementations. |
| SimulateNetworkQualityChange(EffectiveConnectionType type) => (); |
| |
| // Let NetworkQualityEstimator reports NetworkChangeNotifier::CONNECTION_WIFI |
| // as EFFECTIVE_CONNECTION_TYPE_SLOW_2G since EffectiveConnectionType and |
| // the production receivers doesn't notice Wifi. |
| ForceNetworkQualityEstimatorReportWifiAsSlow2G() => (); |
| |
| // Crash the process where network service is running. |
| SimulateCrash(); |
| |
| // These methods mirror the net::MockCertVerifier interface. |
| [Sync] |
| MockCertVerifierSetDefaultResult(int32 default_result) => (); |
| |
| [Sync] |
| MockCertVerifierAddResultForCertAndHost( |
| X509Certificate cert, |
| string host_pattern, |
| CertVerifyResult verify_result, |
| int32 rv) => (); |
| |
| // Set the global transport security state preloaded static data source to |
| // the unittest_default source, if `enable_unittest_source` is true. |
| // If `enable_unittest_source` is false, the source will be reset to |
| // the default. |
| SetTransportSecurityStateTestSource(bool enable_unittest_source) => (); |
| |
| // Allow host resolutions to reach the network. Since going to the network |
| // can be a source of flakiness, this should only be called in tests that |
| // can tolerate this, such as those run manually or on an FYI bot. |
| [Sync] |
| SetAllowNetworkAccessToHostResolutions() => (); |
| |
| // Replace the system DNS configuration with a basic, single-server, |
| // localhost-only configuration and ignore any future changes to the real |
| // configuration. |
| [Sync] |
| ReplaceSystemDnsConfig() => (); |
| |
| // Set the DoH configuration to be used during tests. |
| [Sync] |
| SetTestDohConfig(SecureDnsMode secure_dns_mode, |
| DnsOverHttpsConfig doh_config) => (); |
| |
| // Causes the next host resolve to the given hostname to crash the process. |
| CrashOnResolveHost(string host); |
| |
| // Causes the next CookieManager::GetCookieList call to crash. |
| CrashOnGetCookieList(); |
| |
| // Gets the latest memory pressure level reported by the |
| // MemoryPressureListener. |
| [Sync] |
| GetLatestMemoryPressureLevel() |
| => (mojo_base.mojom.MemoryPressureLevel memory_pressure_level); |
| |
| // Gets the current count of peer to peer connections that may require low |
| // latency. |
| [Sync] |
| GetPeerToPeerConnectionsCountChange() |
| => (uint32 connection_count); |
| |
| // Returns the value of an environment variable in the network service's |
| // process, or an empty string if it's not set. |
| [Sync] |
| GetEnvironmentVariableValue(string name) => (string value); |
| |
| // Logs the given string in the network service. This is used to test log |
| // redirection. |
| [Sync] |
| Log(string message) => (); |
| |
| // Activates the specified field trial. Intended for use verifying that the |
| // network service informs the main process when a field trial is activated. |
| ActivateFieldTrial(string field_trial_name); |
| |
| // Set how long of an initial delay should be used for exponential backoff in |
| // SCT auditing retries. Setting the delay to nullopt will reset to the |
| // default. |
| [Sync] |
| SetSCTAuditingRetryDelay(mojo_base.mojom.TimeDelta? delay) => (); |
| |
| // Opens a file with the given `path`, and returns whether it is valid. |
| OpenFile(mojo_base.mojom.FilePath path) => (bool result); |
| |
| // Enumerate files in the specified directory. |
| EnumerateFiles(mojo_base.mojom.FilePath path, |
| pending_remote<HttpCacheBackendFileOperationsFactory> factory) |
| => (array<FileEnumerationEntry> entries, bool error); |
| |
| // Creates a "simple" backend for an HTTP cache. |
| // Returns the created cache if succeeded, and null otherwise. When `reset` is |
| // true, this cleans up the cache directory before creating a cache backend. |
| CreateSimpleCache( |
| pending_remote<HttpCacheBackendFileOperationsFactory> factory, |
| mojo_base.mojom.FilePath path, |
| bool reset) |
| => (pending_remote<SimpleCache>? backend); |
| |
| // Make a HTTP 1.0 GET request for / to `endpoint` using connected socket `s`. |
| // Returns true if request was successfully sent. Intended for use verifying |
| // that a TransferableSocket can be transferred between processes. |
| MakeRequestToServer(TransferableSocket s, IPEndPoint endpoint) |
| => (bool result); |
| |
| // Resolves the machine's own hostname with net::HostResolverSystemTask. |
| ResolveOwnHostnameWithSystemDns() |
| => (network.mojom.AddressList addr_list, int32 os_error, int32 net_error); |
| |
| // Sets the last IPv6 probe result. |
| SetIPv6ProbeResult(bool success) => (); |
| |
| // Get the network service's cached AddressMap, which contains a list of |
| // network interfaces on the user's machine. |
| [Sync, EnableIf=use_network_interface_change_listener] |
| GetAddressMapCacheLinux() |
| => (network.mojom.AddressMap addr_map, network.mojom.OnlineLinks links); |
| |
| // Returns true if the network service is allowed to load a GSSAPI library. |
| // Only relevant on ChromeOS and Linux. |
| [Sync] |
| AllowsGSSAPILibraryLoad() => (bool allow_gssapi_library_load); |
| |
| // Disable exclusive locking of the cookie database for testing. |
| // TODO(crbug.com/377940976): Remove this once the background sequence runner |
| // can be fully drained of tasks during network context shutdown. |
| [EnableIf=is_win] |
| DisableExclusiveCookieDatabaseLockingForTesting() => (); |
| |
| // Returns true if the HappyEyeballs V3 is enabled for testing. |
| IsHappyEyeballsV3Enabled() => (bool is_happy_eyeballs_v3_enabled); |
| }; |