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

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

Issue 10823125: Drive: add a method to clear all local cache. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: review fix Created 8 years, 4 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
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 21 matching lines...) Expand all
32 namespace { 32 namespace {
33 33
34 // Used in test to setup system service. 34 // Used in test to setup system service.
35 DocumentsServiceInterface* g_test_documents_service = NULL; 35 DocumentsServiceInterface* g_test_documents_service = NULL;
36 const std::string* g_test_cache_root = NULL; 36 const std::string* g_test_cache_root = NULL;
37 37
38 } // namespace 38 } // namespace
39 39
40 GDataSystemService::GDataSystemService(Profile* profile) 40 GDataSystemService::GDataSystemService(Profile* profile)
41 : profile_(profile), 41 : profile_(profile),
42 cache_(NULL) { 42 cache_(NULL),
43 weak_ptr_factory_(this) {
satorux1 2012/08/01 21:56:31 ALLOW_THIS_IN_INITIALIZER_LISt
yoshiki 2012/08/01 23:07:59 Done.
43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 44 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
44 base::SequencedWorkerPool* blocking_pool = BrowserThread::GetBlockingPool(); 45 base::SequencedWorkerPool* blocking_pool = BrowserThread::GetBlockingPool();
45 blocking_task_runner_ = blocking_pool->GetSequencedTaskRunner( 46 blocking_task_runner_ = blocking_pool->GetSequencedTaskRunner(
46 blocking_pool->GetSequenceToken()); 47 blocking_pool->GetSequenceToken());
47 } 48 }
48 49
49 GDataSystemService::~GDataSystemService() { 50 GDataSystemService::~GDataSystemService() {
50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 51 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
51 cache_->DestroyOnUIThread(); 52 cache_->DestroyOnUIThread();
52 } 53 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // Shut down the member objects in the reverse order of creation. 97 // Shut down the member objects in the reverse order of creation.
97 contacts_service_.reset(); 98 contacts_service_.reset();
98 sync_client_.reset(); 99 sync_client_.reset();
99 download_observer_.reset(); 100 download_observer_.reset();
100 file_system_.reset(); 101 file_system_.reset();
101 webapps_registry_.reset(); 102 webapps_registry_.reset();
102 uploader_.reset(); 103 uploader_.reset();
103 documents_service_.reset(); 104 documents_service_.reset();
104 } 105 }
105 106
107 void GDataSystemService::ClearCacheAndResetOnUIThread() {
108 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
satorux1 2012/08/01 21:56:31 add a blank like after DCHECK
yoshiki 2012/08/01 23:07:59 Done.
109 RemoveDriveMountPoint();
110 docs_service()->CancelAll();
111 cache_->ClearAllOnUIThread(
112 base::Bind(&GDataSystemService::AddBackDrivemountPoint,
113 weak_ptr_factory_.GetWeakPtr()));
114 }
115
116 void GDataSystemService::AddBackDrivemountPoint(
117 GDataFileError error, const FilePath& file_path) {
118 DCHECK(error);
119 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
satorux1 2012/08/01 21:56:31 please swap the order of DCHECKs, and add a blank
yoshiki 2012/08/01 23:07:59 Done.
120 AddDriveMountPoint();
121 }
122
106 void GDataSystemService::AddDriveMountPoint() { 123 void GDataSystemService::AddDriveMountPoint() {
107 if (!gdata::util::IsGDataAvailable(profile_)) 124 if (!gdata::util::IsGDataAvailable(profile_))
108 return; 125 return;
109 126
110 const FilePath mount_point = gdata::util::GetGDataMountPointPath(); 127 const FilePath mount_point = gdata::util::GetGDataMountPointPath();
111 fileapi::ExternalFileSystemMountPointProvider* provider = 128 fileapi::ExternalFileSystemMountPointProvider* provider =
112 BrowserContext::GetFileSystemContext(profile_)->external_provider(); 129 BrowserContext::GetFileSystemContext(profile_)->external_provider();
113 if (provider && !provider->HasMountPoint(mount_point)) { 130 if (provider && !provider->HasMountPoint(mount_point)) {
114 provider->AddRemoteMountPoint( 131 provider->AddRemoteMountPoint(
115 mount_point, 132 mount_point,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 g_test_cache_root ? FilePath(*g_test_cache_root) : 201 g_test_cache_root ? FilePath(*g_test_cache_root) :
185 GDataCache::GetCacheRootPath(profile); 202 GDataCache::GetCacheRootPath(profile);
186 delete g_test_cache_root; 203 delete g_test_cache_root;
187 g_test_cache_root = NULL; 204 g_test_cache_root = NULL;
188 205
189 service->Initialize(documents_service, cache_root); 206 service->Initialize(documents_service, cache_root);
190 return service; 207 return service;
191 } 208 }
192 209
193 } // namespace gdata 210 } // namespace gdata
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698