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

Unified Diff: content/network/network_service.h

Issue 2962693002: NetworkService: Destroy NetworkContexts on NetworkService teardown. (Closed)
Patch Set: Fix a couple comments Created 3 years, 6 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
« no previous file with comments | « content/network/network_context.cc ('k') | content/network/network_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/network/network_service.h
diff --git a/content/network/network_service.h b/content/network/network_service.h
index e139546dd91e0850db7c5bdc7f54cfcbfd620ccb..c945b9adb9b523a7a1ee4935668c24f9907b3cf2 100644
--- a/content/network/network_service.h
+++ b/content/network/network_service.h
@@ -8,6 +8,7 @@
#include <memory>
#include "base/macros.h"
+#include "content/common/content_export.h"
#include "content/common/network_service.mojom.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "services/service_manager/public/cpp/binder_registry.h"
@@ -15,6 +16,8 @@
namespace content {
+class NetworkContext;
+
class NetworkService : public service_manager::Service,
public mojom::NetworkService {
public:
@@ -22,9 +25,23 @@ class NetworkService : public service_manager::Service,
std::unique_ptr<service_manager::BinderRegistry> registry);
~NetworkService() override;
+ CONTENT_EXPORT static std::unique_ptr<NetworkService> CreateForTesting();
+
+ // These are called by NetworkContexts as they are being created and
+ // destroyed.
+ void RegisterNetworkContext(NetworkContext* network_context);
+ void DeregisterNetworkContext(NetworkContext* network_context);
+
+ // mojom::NetworkService implementation:
+ void CreateNetworkContext(mojom::NetworkContextRequest request,
+ mojom::NetworkContextParamsPtr params) override;
+
private:
class MojoNetLog;
+ // Used for tests.
+ NetworkService();
+
// service_manager::Service implementation.
void OnBindInterface(const service_manager::BindSourceInfo& source_info,
const std::string& interface_name,
@@ -33,16 +50,18 @@ class NetworkService : public service_manager::Service,
void Create(const service_manager::BindSourceInfo& source_info,
mojom::NetworkServiceRequest request);
- // mojom::NetworkService implementation:
- void CreateNetworkContext(mojom::NetworkContextRequest request,
- mojom::NetworkContextParamsPtr params) override;
-
std::unique_ptr<MojoNetLog> net_log_;
std::unique_ptr<service_manager::BinderRegistry> registry_;
mojo::Binding<mojom::NetworkService> binding_;
+ // NetworkContexts register themselves with the NetworkService so that they
+ // can be cleaned up when the NetworkService goes away. This is needed as
+ // NetworkContexts share global state with the NetworkService, so must be
+ // destroyed first.
+ std::set<NetworkContext*> network_contexts_;
+
DISALLOW_COPY_AND_ASSIGN(NetworkService);
};
« no previous file with comments | « content/network/network_context.cc ('k') | content/network/network_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698