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

Unified Diff: content/network/network_context.cc

Issue 2960843005: Revert of NetworkService: Destroy NetworkContexts on NetworkService teardown. (Closed)
Patch Set: 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.h ('k') | content/network/network_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/network/network_context.cc
diff --git a/content/network/network_context.cc b/content/network/network_context.cc
index ea81b5ca2d8fa20ea9e6e82b18bafcd1ee97cb96..5862ea67d5b17977c9f4bac18390441b8c77a485 100644
--- a/content/network/network_context.cc
+++ b/content/network/network_context.cc
@@ -9,7 +9,6 @@
#include "base/strings/string_number_conversions.h"
#include "components/network_session_configurator/common/network_switches.h"
#include "content/network/cache_url_loader.h"
-#include "content/network/network_service.h"
#include "content/network/network_service_url_loader_factory_impl.h"
#include "content/network/url_loader_impl.h"
#include "content/public/common/content_client.h"
@@ -87,17 +86,11 @@
} // namespace
-NetworkContext::NetworkContext(NetworkService* network_service,
- mojom::NetworkContextRequest request,
+NetworkContext::NetworkContext(mojom::NetworkContextRequest request,
mojom::NetworkContextParamsPtr params)
- : network_service_(network_service),
- url_request_context_(MakeURLRequestContext()),
+ : url_request_context_(MakeURLRequestContext()),
params_(std::move(params)),
- binding_(this, std::move(request)) {
- network_service_->RegisterNetworkContext(this);
- binding_.set_connection_error_handler(
- base::Bind(&NetworkContext::OnConnectionError, base::Unretained(this)));
-}
+ binding_(this, std::move(request)) {}
NetworkContext::~NetworkContext() {
// Call each URLLoaderImpl and ask it to release its net::URLRequest, as the
@@ -106,10 +99,6 @@
// so have to be careful.
while (!url_loaders_.empty())
(*url_loaders_.begin())->Cleanup();
-
- // May be nullptr in tests.
- if (network_service_)
- network_service_->DeregisterNetworkContext(this);
}
std::unique_ptr<NetworkContext> NetworkContext::CreateForTesting() {
@@ -139,22 +128,8 @@
StartCacheURLLoader(url, url_request_context_.get(), std::move(client));
}
-void NetworkContext::Cleanup() {
- // The NetworkService is going away, so have to destroy the
- // net::URLRequestContext held by this NetworkContext.
- delete this;
-}
-
NetworkContext::NetworkContext()
- : network_service_(nullptr),
- url_request_context_(MakeURLRequestContext()),
+ : url_request_context_(MakeURLRequestContext()),
binding_(this) {}
-void NetworkContext::OnConnectionError() {
- // Don't delete |this| in response to connection errors when it was created by
- // CreateForTesting.
- if (network_service_)
- delete this;
-}
-
} // namespace content
« no previous file with comments | « content/network/network_context.h ('k') | content/network/network_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698