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

Unified Diff: chrome/browser/chromeos/drive/drive_integration_service.cc

Issue 118043003: Fix app_shell shutdown crash due to BrowserContextKeyedServices (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ScopedFactoryForTest (shutdown_crash) Created 6 years, 11 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/chromeos/drive/drive_integration_service.cc
diff --git a/chrome/browser/chromeos/drive/drive_integration_service.cc b/chrome/browser/chromeos/drive/drive_integration_service.cc
index 08c9fc5f1dbb0ce7094fb1e13f5413ff7544cc06..250b2cdcceef87d6182c50b821ede615e6a11b30 100644
--- a/chrome/browser/chromeos/drive/drive_integration_service.cc
+++ b/chrome/browser/chromeos/drive/drive_integration_service.cc
@@ -540,6 +540,18 @@ void DriveIntegrationService::AvoidDriveAsDownloadDirecotryPreference() {
//===================== DriveIntegrationServiceFactory =======================
+DriveIntegrationServiceFactory::FactoryCallback*
+ DriveIntegrationServiceFactory::factory_for_test_ = NULL;
+
+DriveIntegrationServiceFactory::ScopedFactoryForTest::ScopedFactoryForTest(
+ FactoryCallback* factory_for_test) {
+ factory_for_test_ = factory_for_test;
+}
+
+DriveIntegrationServiceFactory::ScopedFactoryForTest::~ScopedFactoryForTest() {
+ factory_for_test_ = NULL;
+}
+
// static
DriveIntegrationService* DriveIntegrationServiceFactory::GetForProfile(
Profile* profile) {
@@ -573,12 +585,6 @@ DriveIntegrationServiceFactory* DriveIntegrationServiceFactory::GetInstance() {
return Singleton<DriveIntegrationServiceFactory>::get();
}
-// static
-void DriveIntegrationServiceFactory::SetFactoryForTest(
- const FactoryCallback& factory_for_test) {
- GetInstance()->factory_for_test_ = factory_for_test;
-}
-
DriveIntegrationServiceFactory::DriveIntegrationServiceFactory()
: BrowserContextKeyedServiceFactory(
"DriveIntegrationService",
@@ -597,7 +603,7 @@ DriveIntegrationServiceFactory::BuildServiceInstanceFor(
Profile* profile = Profile::FromBrowserContext(context);
DriveIntegrationService* service = NULL;
- if (factory_for_test_.is_null()) {
+ if (!factory_for_test_) {
DriveIntegrationService::PreferenceWatcher* preference_watcher = NULL;
if (chromeos::IsProfileAssociatedWithGaiaAccount(profile)) {
// Drive File System can be enabled.
@@ -608,7 +614,7 @@ DriveIntegrationServiceFactory::BuildServiceInstanceFor(
service = new DriveIntegrationService(profile, preference_watcher,
NULL, base::FilePath(), NULL);
} else {
- service = factory_for_test_.Run(profile);
+ service = factory_for_test_->Run(profile);
}
return service;

Powered by Google App Engine
This is Rietveld 408576698