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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_system_service.cc

Issue 10805034: Fix flakiness in RemoteFileSystemExtensionApiTests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_system_service.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" 5 #include "chrome/browser/chromeos/gdata/gdata_system_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h" 10 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h"
(...skipping 11 matching lines...) Expand all
22 #include "content/public/browser/browser_context.h" 22 #include "content/public/browser/browser_context.h"
23 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
24 #include "webkit/fileapi/file_system_context.h" 24 #include "webkit/fileapi/file_system_context.h"
25 #include "webkit/fileapi/file_system_mount_point_provider.h" 25 #include "webkit/fileapi/file_system_mount_point_provider.h"
26 26
27 using content::BrowserContext; 27 using content::BrowserContext;
28 using content::BrowserThread; 28 using content::BrowserThread;
29 29
30 namespace { 30 namespace {
31 31
32 // Used in test to setup system service.
33 gdata::DocumentsServiceInterface* g_test_documents_service = NULL;
34 const std::string* g_test_cache_root = NULL;
35
32 scoped_refptr<base::SequencedTaskRunner> GetTaskRunner( 36 scoped_refptr<base::SequencedTaskRunner> GetTaskRunner(
33 const base::SequencedWorkerPool::SequenceToken& sequence_token) { 37 const base::SequencedWorkerPool::SequenceToken& sequence_token) {
34 return BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( 38 return BrowserThread::GetBlockingPool()->GetSequencedTaskRunner(
35 sequence_token); 39 sequence_token);
36 } 40 }
37 41
38 } // nemaspace 42 } // nemaspace
39 43
40 namespace gdata { 44 namespace gdata {
41 45
42 //===================== GDataSystemService ==================================== 46 //===================== GDataSystemService ====================================
43 GDataSystemService::GDataSystemService(Profile* profile) 47 GDataSystemService::GDataSystemService(Profile* profile)
44 : profile_(profile), 48 : profile_(profile),
45 sequence_token_(BrowserThread::GetBlockingPool()->GetSequenceToken()), 49 sequence_token_(BrowserThread::GetBlockingPool()->GetSequenceToken()),
46 cache_(NULL) { 50 cache_(NULL) {
47 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 51 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
48 } 52 }
49 53
50 GDataSystemService::~GDataSystemService() { 54 GDataSystemService::~GDataSystemService() {
51 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 55 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
52 cache_->DestroyOnUIThread(); 56 cache_->DestroyOnUIThread();
53 } 57 }
54 58
55 void GDataSystemService::Initialize( 59 void GDataSystemService::Initialize(
56 DocumentsServiceInterface* documents_service) { 60 DocumentsServiceInterface* documents_service,
61 const FilePath& cache_root) {
57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 62 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
58 63
59 documents_service_.reset(documents_service); 64 documents_service_.reset(documents_service);
60 cache_ = GDataCache::CreateGDataCacheOnUIThread( 65 cache_ = GDataCache::CreateGDataCacheOnUIThread(
61 GDataCache::GetCacheRootPath(profile_), 66 cache_root,
62 GetTaskRunner(sequence_token_)); 67 GetTaskRunner(sequence_token_));
63 uploader_.reset(new GDataUploader(docs_service())); 68 uploader_.reset(new GDataUploader(docs_service()));
64 webapps_registry_.reset(new DriveWebAppsRegistry); 69 webapps_registry_.reset(new DriveWebAppsRegistry);
65 file_system_.reset(new GDataFileSystem(profile_, 70 file_system_.reset(new GDataFileSystem(profile_,
66 cache(), 71 cache(),
67 docs_service(), 72 docs_service(),
68 uploader(), 73 uploader(),
69 webapps_registry(), 74 webapps_registry(),
70 GetTaskRunner(sequence_token_))); 75 GetTaskRunner(sequence_token_)));
71 download_observer_.reset(new GDataDownloadObserver(uploader(), 76 download_observer_.reset(new GDataDownloadObserver(uploader(),
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 GDataSystemServiceFactory::GDataSystemServiceFactory() 151 GDataSystemServiceFactory::GDataSystemServiceFactory()
147 : ProfileKeyedServiceFactory("GDataSystemService", 152 : ProfileKeyedServiceFactory("GDataSystemService",
148 ProfileDependencyManager::GetInstance()) { 153 ProfileDependencyManager::GetInstance()) {
149 DependsOn(DownloadServiceFactory::GetInstance()); 154 DependsOn(DownloadServiceFactory::GetInstance());
150 } 155 }
151 156
152 GDataSystemServiceFactory::~GDataSystemServiceFactory() { 157 GDataSystemServiceFactory::~GDataSystemServiceFactory() {
153 } 158 }
154 159
155 // static 160 // static
156 ProfileKeyedService* GDataSystemServiceFactory::CreateInstance( 161 void GDataSystemServiceFactory::set_documents_service_for_test(
157 Profile* profile) { 162 DocumentsServiceInterface* documents_service) {
158 return new GDataSystemService(profile); 163 if (g_test_documents_service)
164 delete g_test_documents_service;
165 g_test_documents_service = documents_service;
159 } 166 }
160 167
161 GDataSystemService* 168 // static
162 GDataSystemServiceFactory::GetWithCustomDocumentsServiceForTesting( 169 void GDataSystemServiceFactory::set_cache_root_for_test(
163 Profile* profile, 170 const std::string& cache_root) {
164 DocumentsServiceInterface* documents_service) { 171 if (g_test_cache_root)
165 GDataSystemService* service = 172 delete g_test_cache_root;
166 static_cast<GDataSystemService*>(GetInstance()->SetTestingFactoryAndUse( 173 g_test_cache_root = !cache_root.empty() ? new std::string(cache_root) : NULL;
167 profile,
168 &GDataSystemServiceFactory::CreateInstance));
169 service->Initialize(documents_service);
170 return service;
171 } 174 }
172 175
173 ProfileKeyedService* GDataSystemServiceFactory::BuildServiceInstanceFor( 176 ProfileKeyedService* GDataSystemServiceFactory::BuildServiceInstanceFor(
174 Profile* profile) const { 177 Profile* profile) const {
175 GDataSystemService* service = new GDataSystemService(profile); 178 GDataSystemService* service = new GDataSystemService(profile);
176 service->Initialize(new DocumentsService); 179
180 DocumentsServiceInterface* documents_service =
181 g_test_documents_service ? g_test_documents_service :
182 new DocumentsService();
183 g_test_documents_service = NULL;
184
185 FilePath cache_root =
186 g_test_cache_root ? FilePath(*g_test_cache_root) :
187 GDataCache::GetCacheRootPath(profile);
188 delete g_test_cache_root;
189 g_test_cache_root = NULL;
190
191 service->Initialize(documents_service, cache_root);
177 return service; 192 return service;
178 } 193 }
179 194
180 } // namespace gdata 195 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_system_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698