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

Unified Diff: chrome/browser/net/system_network_context_manager.h

Issue 2968293002: Introduce SystemNetworkContextManager. (Closed)
Patch Set: Fix windows non-component build (??) 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..6ee9fe60a5ef78a070c6e175326dd7eb3c583568
--- /dev/null
+++ b/chrome/browser/net/system_network_context_manager.h
@@ -0,0 +1,73 @@
+// 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 (If the OOP NetworkService is disabled) or
jam 2017/07/08 01:30:08 nit: here and below, I think OOP is not necessary
mmenke 2017/07/10 15:52:22 I've removed all instances of OOP (I now refer to
+// be an independent NetworkContext in the OOP NetworkService.
+//
+// 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 an OOP NetworkService.
+class SystemNetworkContextManager {
+ public:
+ // Initializes |network_context_params| as needed to set up a system
+ // NetworkContext. If the OOP NetworkService 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
+ // |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 Initialize().
kinuko 2017/07/10 08:10:33 Wasn't sure what this Initialize points to, do you
mmenke 2017/07/10 15:52:22 Done, thanks (Renamed the method itself once I mov
+ 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 OOP
+ // NetworkService 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 OOP NetworkService 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