OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_INTEGRATION_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_INTEGRATION_SERVICE_H_ |
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_INTEGRATION_SERVICE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_INTEGRATION_SERVICE_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 static DriveIntegrationService* FindForProfile(Profile* profile); | 201 static DriveIntegrationService* FindForProfile(Profile* profile); |
202 | 202 |
203 // Same as FindForProfile. TODO(hidehiko): Remove this. | 203 // Same as FindForProfile. TODO(hidehiko): Remove this. |
204 static DriveIntegrationService* FindForProfileRegardlessOfStates( | 204 static DriveIntegrationService* FindForProfileRegardlessOfStates( |
205 Profile* profile); | 205 Profile* profile); |
206 | 206 |
207 // Returns the DriveIntegrationServiceFactory instance. | 207 // Returns the DriveIntegrationServiceFactory instance. |
208 static DriveIntegrationServiceFactory* GetInstance(); | 208 static DriveIntegrationServiceFactory* GetInstance(); |
209 | 209 |
210 // Sets a factory function for tests. | 210 // Sets a factory function for tests. |
211 static void SetFactoryForTest(const FactoryCallback& factory_for_test); | 211 // NOTE: Call SetFactoryForTest(NULL) during your test TearDown so you don't |
212 // pollute the next test. | |
213 static void SetFactoryForTest(FactoryCallback* factory_for_test); | |
xiyuan
2014/01/09 17:53:22
nit: How about making this private and use a Scope
| |
212 | 214 |
213 private: | 215 private: |
214 friend struct DefaultSingletonTraits<DriveIntegrationServiceFactory>; | 216 friend struct DefaultSingletonTraits<DriveIntegrationServiceFactory>; |
215 | 217 |
216 DriveIntegrationServiceFactory(); | 218 DriveIntegrationServiceFactory(); |
217 virtual ~DriveIntegrationServiceFactory(); | 219 virtual ~DriveIntegrationServiceFactory(); |
218 | 220 |
219 // BrowserContextKeyedServiceFactory: | 221 // BrowserContextKeyedServiceFactory: |
220 virtual BrowserContextKeyedService* BuildServiceInstanceFor( | 222 virtual BrowserContextKeyedService* BuildServiceInstanceFor( |
221 content::BrowserContext* context) const OVERRIDE; | 223 content::BrowserContext* context) const OVERRIDE; |
222 | 224 |
223 FactoryCallback factory_for_test_; | 225 // This is static so it can be set without instantiating the factory. This |
226 // allows factory creation to be delayed until it normally happens (on profile | |
227 // creation) rather than when tests are set up. DriveIntegrationServiceFactory | |
228 // transitively depends on ExtensionSystemFactory which crashes if created too | |
229 // soon (i.e. before the BrowserProcess exists). | |
230 static FactoryCallback* factory_for_test_; | |
224 }; | 231 }; |
225 | 232 |
226 } // namespace drive | 233 } // namespace drive |
227 | 234 |
228 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_INTEGRATION_SERVICE_H_ | 235 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_INTEGRATION_SERVICE_H_ |
OLD | NEW |