Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 // The NetworkContext used by the |SystemNetworkContextManager|. If the | |
| 61 // network service is enabled, it's a NetworkContext using that | |
| 62 // NetworkService. If it's not enabled, it's a NetworkContext wrapping the | |
| 63 // IOThread's SystemURLRequestContext. | |
|
asanka
2017/07/13 01:52:29
The fact that system_network_context_ is bound to
mmenke
2017/07/13 16:15:18
Done. I called it the network_service_network_con
| |
| 64 content::mojom::NetworkContextPtr system_network_context_; | |
| 65 | |
| 66 // When the network service is enabled, this is a NetworkContext that wraps | |
| 67 // the IOThread's SystemURLRequestContext, and is never used after | |
| 68 // initialization. It's nullptr, otherwise. | |
| 69 content::mojom::NetworkContextPtr io_thread_network_context_; | |
| 70 | |
| 71 DISALLOW_COPY_AND_ASSIGN(SystemNetworkContextManager); | |
| 72 }; | |
| 73 | |
| 74 #endif // CHROME_BROWSER_NET_SYSTEM_NETWORK_CONTEXT_MANAGER_H_ | |
| OLD | NEW |