Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: chrome/browser/net/system_network_context_manager.h

Issue 2968293002: Introduce SystemNetworkContextManager. (Closed)
Patch Set: Response to comments Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/io_thread.cc ('k') | chrome/browser/net/system_network_context_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_NET_SYSTEM_NETWORK_CONTEXT_MANAGER_H_
6 #define CHROME_BROWSER_NET_SYSTEM_NETWORK_CONTEXT_MANAGER_H_
7
8 #include <memory>
9
10 #include "base/lazy_instance.h"
11 #include "base/macros.h"
12 #include "content/public/common/network_service.mojom.h"
13
14 // Global object that lives on the UI thread. Responsible for creating and
15 // managing access to the system NetworkContext. This NetworkContext is intended
16 // for requests not associated with a profile. It stores no data on disk, and
17 // has no HTTP cache, but it does have ephemeral cookie and channel ID stores.
18 // It also does not have access to HTTP proxy auth information the user has
19 // entered or that comes from extensions, and similarly, has no
20 // extension-provided per-profile proxy configuration information.
21 //
22 // The "system" NetworkContext will either share a URLRequestContext with
23 // IOThread's SystemURLRequestContext and be part of IOThread's NetworkService
24 // (If the network service is disabled) or be an independent NetworkContext
25 // using the actual network service.
26 //
27 // This class is intended to eventually replace IOThread. Handling the two cases
28 // differently allows this to be used in production without breaking anything or
29 // requiring two separate paths, while IOThread consumers slowly transition over
30 // to being compatible with the network service.
31 class SystemNetworkContextManager {
32 public:
33 // Initializes |network_context_params| as needed to set up a system
34 // NetworkContext. If the network service is disabled,
35 // |network_context_request| will be for the NetworkContext used by the
36 // SystemNetworkContextManager. Otherwise, this method can still be used to
37 // help set up the IOThread's in-process URLRequestContext, and
38 // |network_context_request| will still be populated, but the associated
39 // NetworkContext will not be used by the SystemNetworkContextManager.
40 //
41 // Must be called before the system NetworkContext is first used.
42 static void SetUp(
43 content::mojom::NetworkContextRequest* network_context_request,
44 content::mojom::NetworkContextParamsPtr* network_context_params);
45
46 // Returns the System NetworkContext. May only be called after SetUp().
47 static content::mojom::NetworkContext* Context();
48
49 private:
50 static SystemNetworkContextManager* GetInstance();
51
52 friend struct base::LazyInstanceTraitsBase<SystemNetworkContextManager>;
53
54 SystemNetworkContextManager();
55 ~SystemNetworkContextManager();
56
57 // Gets the system NetworkContext, creating it if needed.
58 content::mojom::NetworkContext* GetContext();
59
60 // NetworkContext using the network service, if the/ network service is
61 // enabled. nullptr, otherwise.
62 content::mojom::NetworkContextPtr network_service_network_context_;
63
64 // This is a NetworkContext that wraps the IOThread's SystemURLRequestContext.
65 // Always initialized in SetUp, but it's only returned by Context() when the
66 // network service is disabled.
67 content::mojom::NetworkContextPtr io_thread_network_context_;
68
69 DISALLOW_COPY_AND_ASSIGN(SystemNetworkContextManager);
70 };
71
72 #endif // CHROME_BROWSER_NET_SYSTEM_NETWORK_CONTEXT_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/io_thread.cc ('k') | chrome/browser/net/system_network_context_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698