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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/net/system_network_context_manager.h
diff --git a/chrome/browser/net/system_network_context_manager.h b/chrome/browser/net/system_network_context_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..10f09d5adf4635777e4704b1a3720ab256c355a0
--- /dev/null
+++ b/chrome/browser/net/system_network_context_manager.h
@@ -0,0 +1,74 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_NET_SYSTEM_NETWORK_CONTEXT_MANAGER_H_
+#define CHROME_BROWSER_NET_SYSTEM_NETWORK_CONTEXT_MANAGER_H_
+
+#include <memory>
+
+#include "base/lazy_instance.h"
+#include "base/macros.h"
+#include "content/public/common/network_service.mojom.h"
+
+// Global object that lives on the UI thread. Responsible for creating and
+// managing access to the system NetworkContext. This NetworkContext is intended
+// for requests not associated with a profile. It stores no data on disk, and
+// has no HTTP cache, but it does have ephemeral cookie and channel ID stores.
+// It also does not have access to HTTP proxy auth information the user has
+// entered or that comes from extensions, and similarly, has no
+// extension-provided per-profile proxy configuration information.
+//
+// The "system" NetworkContext will either share a URLRequestContext with
+// IOThread's SystemURLRequestContext and be part of IOThread's NetworkService
+// (If the network service is disabled) or be an independent NetworkContext
+// using the actual network service.
+//
+// This class is intended to eventually replace IOThread. Handling the two cases
+// differently allows this to be used in production without breaking anything or
+// requiring two separate paths, while IOThread consumers slowly transition over
+// to being compatible with the network service.
+class SystemNetworkContextManager {
+ public:
+ // Initializes |network_context_params| as needed to set up a system
+ // NetworkContext. If the network service is disabled,
+ // |network_context_request| will be for the NetworkContext used by the
+ // SystemNetworkContextManager. Otherwise, this method can still be used to
+ // help set up the IOTHread's in-process URLRequestContext, and
kinuko 2017/07/11 08:26:41 nit: IOTHread -> IOThread
mmenke 2017/07/11 18:36:26 Done.
+ // |network_context_request| will still be populated, but the associated
+ // NetworkContext will not be used by the SystemNetworkContextManager.
+ //
+ // Must be called before the system NetworkContext is first used.
+ static void SetUp(
+ content::mojom::NetworkContextRequest* network_context_request,
+ content::mojom::NetworkContextParamsPtr* network_context_params);
+
+ // Returns the System NetworkContext. May only be called after SetUp().
+ static content::mojom::NetworkContext* Context();
+
+ private:
+ static SystemNetworkContextManager* GetInstance();
+
+ friend struct base::LazyInstanceTraitsBase<SystemNetworkContextManager>;
+
+ SystemNetworkContextManager();
+ ~SystemNetworkContextManager();
+
+ // Gets the system NetworkContext, creating it if needed.
+ content::mojom::NetworkContext* GetContext();
+
+ // The NetworkContext used by the |SystemNetworkContextManager|. If the
+ // network service is enabled, it's a NetworkContext using that
+ // NetworkService. If it's not enabled, it's a NetworkContext wrapping the
+ // IOThread's SystemURLRequestContext.
+ content::mojom::NetworkContextPtr system_network_context_;
+
+ // When the network service is enabled, this is a NetworkContext that wraps
+ // the IOThread's SystemURLRequestContext, and is never used after
+ // initialization. It's nullptr, otherwise.
+ content::mojom::NetworkContextPtr io_thread_network_context_;
+
+ DISALLOW_COPY_AND_ASSIGN(SystemNetworkContextManager);
+};
+
+#endif // CHROME_BROWSER_NET_SYSTEM_NETWORK_CONTEXT_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698