blob: dadf7d8dd4e42bd1ac4fd4743ff68dc3b97bbc31 [file] [log] [blame]
Avi Drissman4e1b7bc32022-09-15 14:03:501// Copyright 2019 The Chromium Authors
John Abd-El-Malek984dc002019-05-29 01:26:592// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CONTENT_BROWSER_NETWORK_SERVICE_INSTANCE_IMPL_H_
6#define CONTENT_BROWSER_NETWORK_SERVICE_INSTANCE_IMPL_H_
7
Dan McArdle0c085b22024-07-12 14:15:238#include <stdint.h>
9
John Abd-El-Malek984dc002019-05-29 01:26:5910#include "base/callback_list.h"
Dan McArdle0c085b22024-07-12 14:15:2311#include "base/command_line.h"
Will Harris4c686ec2025-08-01 10:51:4712#include "base/files/file_path.h"
Avi Drissmanadac21992023-01-11 23:46:3913#include "base/functional/callback.h"
John Abd-El-Malek984dc002019-05-29 01:26:5914#include "content/common/content_export.h"
Matt Muellerf7839622023-11-13 20:23:1515#include "mojo/public/cpp/bindings/remote.h"
16#include "services/cert_verifier/public/mojom/cert_verifier_service_factory.mojom-forward.h"
John Abd-El-Malekf2592db2024-02-12 07:20:2317#include "services/network/public/mojom/cert_verifier_service_updater.mojom-forward.h"
Matt Muellerf7839622023-11-13 20:23:1518#include "services/network/public/mojom/network_context.mojom-forward.h"
John Abd-El-Malek984dc002019-05-29 01:26:5919
20namespace content {
21
Will Harris4c686ec2025-08-01 10:51:4722// A directory name that is created below the http cache path and passed to the
23// network context when creating a network context with cache enabled.
24// This must be a directory below the main cache path so operations such as
25// resetting the cache via HttpCacheParams.reset_cache can function correctly
26// as they rely on having access to the parent directory of the cache.
27inline constexpr base::FilePath::CharType kCacheDataDirectoryName[] =
28 FILE_PATH_LITERAL("Cache_Data");
29
John Abd-El-Malek984dc002019-05-29 01:26:5930// Creates the network::NetworkService object on the IO thread directly instead
31// of trying to go through the ServiceManager.
Matthew Denton09b7b4b52023-03-28 09:02:4932// This also calls ForceInProcessNetworkService().
John Abd-El-Malek984dc002019-05-29 01:26:5933CONTENT_EXPORT void ForceCreateNetworkServiceDirectlyForTesting();
34
Will Harris66b7f8a2025-07-18 17:56:4335// Sets whether or not the network service process will crash early in process
36// bootstrap, on the next launch, for testing.
37CONTENT_EXPORT void SetNetworkServiceCrashOnNextStartupImplForTesting();
38
John Abd-El-Malek984dc002019-05-29 01:26:5939// Resets the interface ptr to the network service.
40CONTENT_EXPORT void ResetNetworkServiceForTesting();
41
Matthew Denton095b6972023-11-02 21:56:1742using NetworkServiceProcessGoneHandler =
43 base::RepeatingCallback<void(bool crashed)>;
44
Julie Jeongeun Kima3471c62019-10-15 07:09:2445// Registers |handler| to run (on UI thread) after mojo::Remote<NetworkService>
Matthew Denton095b6972023-11-02 21:56:1746// encounters an error, in which case `crashed` will be true, or after the
47// NetworkService is purposely restarted by the browser, in which case `crashed`
48// will be false. Note that there are no ordering guarantees wrt error
Julie Jeongeun Kima3471c62019-10-15 07:09:2449// handlers for other interfaces (e.g. mojo::Remote<NetworkContext> and/or
Julie Jeongeun Kim2811b952019-10-24 00:36:1250// mojo::Remote<URLLoaderFactory>).
John Abd-El-Malek984dc002019-05-29 01:26:5951//
52// Can only be called on the UI thread. No-op if NetworkService is disabled.
Peter Kasting7ba9440c2020-11-22 01:49:0253CONTENT_EXPORT base::CallbackListSubscription
Matthew Denton095b6972023-11-02 21:56:1754RegisterNetworkServiceProcessGoneHandler(
55 NetworkServiceProcessGoneHandler handler);
John Abd-El-Malek984dc002019-05-29 01:26:5956
Christopher Thompson2a4c69e92019-08-21 16:29:1157constexpr char kSSLKeyLogFileHistogram[] = "Net.SSLKeyLogFileUse";
58
59// These values are persisted to logs. Entries should not be renumbered and
60// numeric values should never be reused.
61enum class SSLKeyLogFileAction {
62 kLogFileEnabled = 0,
63 kSwitchFound = 1,
64 kEnvVarFound = 2,
65 kMaxValue = kEnvVarFound,
66};
67
Ken Rockot91216c0f2019-10-11 20:38:1168// Shuts down the in-process network service or disconnects from the out-of-
69// process one, allowing it to shut down.
70CONTENT_EXPORT void ShutDownNetworkService();
71
Matthew Denton542c43c2023-08-18 07:32:1772// `on_restart` will be called at the end of every RestartNetworkService().
73CONTENT_EXPORT void OnRestartNetworkServiceForTesting(
74 base::RepeatingClosure on_restart);
75
Matt Muellerf7839622023-11-13 20:23:1576// Returns a CertVerifierParams that can be placed into a new
77// network::mojom::NetworkContextParams.
78//
79// Like |GetCertVerifierParams| but the |cert_verifier_updater_remote| pipe
80// passed in can be used to update the returned CertVerifierService with new
81// verification parameters.
82CONTENT_EXPORT network::mojom::CertVerifierServiceRemoteParamsPtr
83GetCertVerifierParamsWithUpdater(
84 cert_verifier::mojom::CertVerifierCreationParamsPtr
85 cert_verifier_creation_params,
86 mojo::PendingReceiver<cert_verifier::mojom::CertVerifierServiceUpdater>
87 cert_verifier_updater_remote);
88
Dan McArdle0c085b22024-07-12 14:15:2389CONTENT_EXPORT uint64_t GetNetLogMaximumFileSizeFromCommandLineForTesting(
90 const base::CommandLine& command_line);
John Abd-El-Malek984dc002019-05-29 01:26:5991} // namespace content
92
93#endif // CONTENT_BROWSER_NETWORK_SERVICE_INSTANCE_IMPL_H_