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 #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 Loading... | |
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 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { | |
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 Loading... | |
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::ClearCache() { | |
108 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
109 | |
110 RemoveDriveMountPoint(); | |
111 docs_service()->CancelAll(); | |
112 cache_->ClearAllOnUIThread( | |
113 base::Bind(&GDataSystemService::AddBackDriveMountPoint, | |
114 weak_ptr_factory_.GetWeakPtr())); | |
115 } | |
116 | |
117 void GDataSystemService::AddBackDriveMountPoint( | |
118 GDataFileError error, const FilePath& file_path) { | |
119 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
120 | |
121 // TODO(yoshiki): Notify to user when |error| != GDATA_FILE_OK. | |
satorux1
2012/08/02 01:03:21
Hmm, would it be difficult to do this now?
yoshiki
2012/08/02 07:12:11
We need to think how to notify the failure to JS-s
| |
122 AddDriveMountPoint(); | |
123 } | |
124 | |
106 void GDataSystemService::AddDriveMountPoint() { | 125 void GDataSystemService::AddDriveMountPoint() { |
107 if (!gdata::util::IsGDataAvailable(profile_)) | 126 if (!gdata::util::IsGDataAvailable(profile_)) |
108 return; | 127 return; |
109 | 128 |
110 const FilePath mount_point = gdata::util::GetGDataMountPointPath(); | 129 const FilePath mount_point = gdata::util::GetGDataMountPointPath(); |
111 fileapi::ExternalFileSystemMountPointProvider* provider = | 130 fileapi::ExternalFileSystemMountPointProvider* provider = |
112 BrowserContext::GetFileSystemContext(profile_)->external_provider(); | 131 BrowserContext::GetFileSystemContext(profile_)->external_provider(); |
113 if (provider && !provider->HasMountPoint(mount_point)) { | 132 if (provider && !provider->HasMountPoint(mount_point)) { |
114 provider->AddRemoteMountPoint( | 133 provider->AddRemoteMountPoint( |
115 mount_point, | 134 mount_point, |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 g_test_cache_root ? FilePath(*g_test_cache_root) : | 203 g_test_cache_root ? FilePath(*g_test_cache_root) : |
185 GDataCache::GetCacheRootPath(profile); | 204 GDataCache::GetCacheRootPath(profile); |
186 delete g_test_cache_root; | 205 delete g_test_cache_root; |
187 g_test_cache_root = NULL; | 206 g_test_cache_root = NULL; |
188 | 207 |
189 service->Initialize(documents_service, cache_root); | 208 service->Initialize(documents_service, cache_root); |
190 return service; | 209 return service; |
191 } | 210 } |
192 | 211 |
193 } // namespace gdata | 212 } // namespace gdata |
OLD | NEW |