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

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

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.h
diff --git a/chrome/browser/chromeos/drive/drive_integration_service.h b/chrome/browser/chromeos/drive/drive_integration_service.h
index 2f6dd45c30978893135fd32ad38f00d939e039d9..cce345499e57f0f173921fe173b67277d0a2159f 100644
--- a/chrome/browser/chromeos/drive/drive_integration_service.h
+++ b/chrome/browser/chromeos/drive/drive_integration_service.h
@@ -188,6 +188,14 @@ class DriveIntegrationServiceFactory
typedef base::Callback<DriveIntegrationService*(Profile* profile)>
FactoryCallback;
+ // Sets and resets a factory function for tests. See below for why we can't
+ // use BrowserContextKeyedServiceFactory::SetTestingFactory().
+ class ScopedFactoryForTest {
+ public:
+ explicit ScopedFactoryForTest(FactoryCallback* factory_for_test);
+ ~ScopedFactoryForTest();
+ };
+
// Returns the DriveIntegrationService for |profile|, creating it if it is
// not yet created.
static DriveIntegrationService* GetForProfile(Profile* profile);
@@ -207,9 +215,6 @@ class DriveIntegrationServiceFactory
// Returns the DriveIntegrationServiceFactory instance.
static DriveIntegrationServiceFactory* GetInstance();
- // Sets a factory function for tests.
- static void SetFactoryForTest(const FactoryCallback& factory_for_test);
-
private:
friend struct DefaultSingletonTraits<DriveIntegrationServiceFactory>;
@@ -220,7 +225,12 @@ class DriveIntegrationServiceFactory
virtual BrowserContextKeyedService* BuildServiceInstanceFor(
content::BrowserContext* context) const OVERRIDE;
- FactoryCallback factory_for_test_;
+ // This is static so it can be set without instantiating the factory. This
+ // allows factory creation to be delayed until it normally happens (on profile
+ // creation) rather than when tests are set up. DriveIntegrationServiceFactory
+ // transitively depends on ExtensionSystemFactory which crashes if created too
+ // soon (i.e. before the BrowserProcess exists).
+ static FactoryCallback* factory_for_test_;
};
} // namespace drive
« no previous file with comments | « apps/shell/shell_extensions_browser_client.cc ('k') | chrome/browser/chromeos/drive/drive_integration_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698