| 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_sync_client.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_sync_client.h" |
| 6 | 6 |
| 7 #include <sys/types.h> | 7 #include <sys/types.h> |
| 8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
| 9 #include <unistd.h> | 9 #include <unistd.h> |
| 10 | 10 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 if (destination == FilePath::FromUTF8Unsafe("/dev/null")) { | 66 if (destination == FilePath::FromUTF8Unsafe("/dev/null")) { |
| 67 std::string resource_id = file_path.BaseName().AsUTF8Unsafe(); | 67 std::string resource_id = file_path.BaseName().AsUTF8Unsafe(); |
| 68 resource_ids->push_back(resource_id); | 68 resource_ids->push_back(resource_id); |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 } // namespace | 73 } // namespace |
| 74 | 74 |
| 75 GDataSyncClient::GDataSyncClient(Profile* profile, | 75 GDataSyncClient::GDataSyncClient(Profile* profile, |
| 76 GDataFileSystemInterface* file_system) | 76 GDataFileSystemInterface* file_system, |
| 77 GDataCache* cache) |
| 77 : profile_(profile), | 78 : profile_(profile), |
| 78 file_system_(file_system), | 79 file_system_(file_system), |
| 80 cache_(cache), |
| 79 registrar_(new PrefChangeRegistrar), | 81 registrar_(new PrefChangeRegistrar), |
| 80 fetch_loop_is_running_(false), | 82 fetch_loop_is_running_(false), |
| 81 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 83 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
| 82 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 84 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 83 } | 85 } |
| 84 | 86 |
| 85 GDataSyncClient::~GDataSyncClient() { | 87 GDataSyncClient::~GDataSyncClient() { |
| 86 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 88 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 87 if (file_system_) | 89 if (file_system_) |
| 88 file_system_->RemoveObserver(this); | 90 file_system_->RemoveObserver(this); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 113 void GDataSyncClient::StartInitialScan(const base::Closure& closure) { | 115 void GDataSyncClient::StartInitialScan(const base::Closure& closure) { |
| 114 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 116 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 115 DCHECK(!closure.is_null()); | 117 DCHECK(!closure.is_null()); |
| 116 | 118 |
| 117 // Start scanning the pinned directory in the cache. | 119 // Start scanning the pinned directory in the cache. |
| 118 std::vector<std::string>* resource_ids = new std::vector<std::string>; | 120 std::vector<std::string>* resource_ids = new std::vector<std::string>; |
| 119 const bool posted = | 121 const bool posted = |
| 120 BrowserThread::GetBlockingPool()->PostTaskAndReply( | 122 BrowserThread::GetBlockingPool()->PostTaskAndReply( |
| 121 FROM_HERE, | 123 FROM_HERE, |
| 122 base::Bind(&ScanPinnedDirectory, | 124 base::Bind(&ScanPinnedDirectory, |
| 123 file_system_->GetCacheDirectoryPath( | 125 cache_->GetCacheDirectoryPath( |
| 124 GDataCache::CACHE_TYPE_PINNED), | 126 GDataCache::CACHE_TYPE_PINNED), |
| 125 resource_ids), | 127 resource_ids), |
| 126 base::Bind(&GDataSyncClient::OnInitialScanComplete, | 128 base::Bind(&GDataSyncClient::OnInitialScanComplete, |
| 127 weak_ptr_factory_.GetWeakPtr(), | 129 weak_ptr_factory_.GetWeakPtr(), |
| 128 closure, | 130 closure, |
| 129 base::Owned(resource_ids))); | 131 base::Owned(resource_ids))); |
| 130 DCHECK(posted); | 132 DCHECK(posted); |
| 131 } | 133 } |
| 132 | 134 |
| 133 void GDataSyncClient::StartFetchLoop() { | 135 void GDataSyncClient::StartFetchLoop() { |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 const content::NotificationDetails& details) { | 270 const content::NotificationDetails& details) { |
| 269 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 271 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 270 | 272 |
| 271 // Resume the fetch loop if gdata preferences are changed. Note that we | 273 // Resume the fetch loop if gdata preferences are changed. Note that we |
| 272 // don't need to check the new values here as these will be checked in | 274 // don't need to check the new values here as these will be checked in |
| 273 // ShouldStopFetchLoop() as soon as the loop is resumed. | 275 // ShouldStopFetchLoop() as soon as the loop is resumed. |
| 274 StartFetchLoop(); | 276 StartFetchLoop(); |
| 275 } | 277 } |
| 276 | 278 |
| 277 } // namespace gdata | 279 } // namespace gdata |
| OLD | NEW |