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

Unified Diff: ios/chrome/browser/application_context_impl.cc

Issue 1547403002: Move ownership of ChromeBrowserStateManager to ApplicationContext. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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: ios/chrome/browser/application_context_impl.cc
diff --git a/ios/chrome/browser/application_context_impl.cc b/ios/chrome/browser/application_context_impl.cc
index 5ca7d16a5d4f5cd08ab52e221de5bb4f0ca974cc..1d56841c07ce2a4f241d5dae1a2e1777b7c97a92 100644
--- a/ios/chrome/browser/application_context_impl.cc
+++ b/ios/chrome/browser/application_context_impl.cc
@@ -57,11 +57,9 @@
#include "net/url_request/url_request_context_getter.h"
namespace {
-
// Dummy flag because iOS does not support disabling background networking.
extern const char kDummyDisableBackgroundNetworking[] =
"dummy-disable-background-networking";
-
}
ApplicationContextImpl::ApplicationContextImpl(
@@ -135,9 +133,12 @@ void ApplicationContextImpl::StartTearDown() {
metrics_services_manager_.reset();
// Need to clear browser states before the IO thread.
- // TODO(crbug.com/560854): the ShutDown() method can be folded into the
- // destructor once ApplicationContextImpl owns ChromeBrowserStateManager.
- GetChromeBrowserStateManager()->ShutDown();
+ if (chrome_browser_state_manager_) {
+ // TODO(crbug.com/560854): the ShutDown() method can be folded into the
+ // destructor once ApplicationContextImpl owns ChromeBrowserStateManager.
+ chrome_browser_state_manager_->ShutDown();
+ chrome_browser_state_manager_.reset();
+ }
// PromoResourceService must be destroyed after the keyed services and before
// the IO thread.
@@ -240,7 +241,12 @@ const std::string& ApplicationContextImpl::GetApplicationLocale() {
ios::ChromeBrowserStateManager*
ApplicationContextImpl::GetChromeBrowserStateManager() {
DCHECK(thread_checker_.CalledOnValidThread());
- return ios::GetChromeBrowserProvider()->GetChromeBrowserStateManager();
+ if (!chrome_browser_state_manager_) {
+ chrome_browser_state_manager_ =
+ ios::GetChromeBrowserProvider()->CreateChromeBrowserStateManager();
+ DCHECK(chrome_browser_state_manager_.get());
+ }
+ return chrome_browser_state_manager_.get();
}
metrics_services_manager::MetricsServicesManager*
« no previous file with comments | « ios/chrome/browser/application_context_impl.h ('k') | ios/public/provider/chrome/browser/chrome_browser_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698