| Index: chrome/browser/chromeos/gdata/gdata_system_service.cc
|
| diff --git a/chrome/browser/chromeos/gdata/gdata_system_service.cc b/chrome/browser/chromeos/gdata/gdata_system_service.cc
|
| index 777ee9c964ef9859d9c2bac41025aaa197207670..58a25aa79701f9dd378c81158f37faf304eeca57 100644
|
| --- a/chrome/browser/chromeos/gdata/gdata_system_service.cc
|
| +++ b/chrome/browser/chromeos/gdata/gdata_system_service.cc
|
| @@ -53,12 +53,13 @@ GDataSystemService::~GDataSystemService() {
|
| }
|
|
|
| void GDataSystemService::Initialize(
|
| - DocumentsServiceInterface* documents_service) {
|
| + DocumentsServiceInterface* documents_service,
|
| + const FilePath& cache_root) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| documents_service_.reset(documents_service);
|
| cache_ = GDataCache::CreateGDataCacheOnUIThread(
|
| - GDataCache::GetCacheRootPath(profile_),
|
| + cache_root,
|
| GetTaskRunner(sequence_token_));
|
| uploader_.reset(new GDataUploader(docs_service()));
|
| webapps_registry_.reset(new DriveWebAppsRegistry);
|
| @@ -153,28 +154,40 @@ GDataSystemServiceFactory::~GDataSystemServiceFactory() {
|
| }
|
|
|
| // static
|
| -ProfileKeyedService* GDataSystemServiceFactory::CreateInstance(
|
| - Profile* profile) {
|
| - return new GDataSystemService(profile);
|
| +void GDataSystemServiceFactory::set_documents_service_for_test(
|
| + DocumentsServiceInterface* documents_service) {
|
| + if (test_documents_service_)
|
| + delete test_documents_service_;
|
| + test_documents_service_ = documents_service;
|
| }
|
|
|
| -GDataSystemService*
|
| -GDataSystemServiceFactory::GetWithCustomDocumentsServiceForTesting(
|
| - Profile* profile,
|
| - DocumentsServiceInterface* documents_service) {
|
| - GDataSystemService* service =
|
| - static_cast<GDataSystemService*>(GetInstance()->SetTestingFactoryAndUse(
|
| - profile,
|
| - &GDataSystemServiceFactory::CreateInstance));
|
| - service->Initialize(documents_service);
|
| - return service;
|
| +// static
|
| +void GDataSystemServiceFactory::set_cache_root_for_test(
|
| + const char* cache_root) {
|
| + test_cache_root_ = cache_root;
|
| }
|
|
|
| ProfileKeyedService* GDataSystemServiceFactory::BuildServiceInstanceFor(
|
| Profile* profile) const {
|
| GDataSystemService* service = new GDataSystemService(profile);
|
| - service->Initialize(new DocumentsService);
|
| +
|
| + DocumentsServiceInterface* documents_service =
|
| + test_documents_service_ ? test_documents_service_ :
|
| + new DocumentsService();
|
| + test_documents_service_ = NULL;
|
| + FilePath cache_root =
|
| + test_cache_root_ ? FilePath(test_cache_root_) :
|
| + GDataCache::GetCacheRootPath(profile);
|
| +
|
| + service->Initialize(documents_service, cache_root);
|
| return service;
|
| }
|
|
|
| +// static
|
| +DocumentsServiceInterface* GDataSystemServiceFactory::test_documents_service_ =
|
| + NULL;
|
| +
|
| +// static
|
| +const char* GDataSystemServiceFactory::test_cache_root_ = NULL;
|
| +
|
| } // namespace gdata
|
|
|