| 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/sync_file_system/sync_file_system_service.h" | 5 #include "chrome/browser/sync_file_system/sync_file_system_service.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 class LocalSyncRunner : public SyncProcessRunner, | 143 class LocalSyncRunner : public SyncProcessRunner, |
| 144 public LocalFileSyncService::Observer { | 144 public LocalFileSyncService::Observer { |
| 145 public: | 145 public: |
| 146 LocalSyncRunner(const std::string& name, | 146 LocalSyncRunner(const std::string& name, |
| 147 SyncFileSystemService* sync_service) | 147 SyncFileSystemService* sync_service) |
| 148 : SyncProcessRunner(name, sync_service, | 148 : SyncProcessRunner(name, sync_service, |
| 149 nullptr, /* timer_helper */ | 149 nullptr, /* timer_helper */ |
| 150 1 /* max_parallel_task */), | 150 1 /* max_parallel_task */), |
| 151 factory_(this) {} | 151 factory_(this) {} |
| 152 | 152 |
| 153 virtual void StartSync(const SyncStatusCallback& callback) override { | 153 void StartSync(const SyncStatusCallback& callback) override { |
| 154 GetSyncService()->local_service_->ProcessLocalChange( | 154 GetSyncService()->local_service_->ProcessLocalChange( |
| 155 base::Bind(&LocalSyncRunner::DidProcessLocalChange, | 155 base::Bind(&LocalSyncRunner::DidProcessLocalChange, |
| 156 factory_.GetWeakPtr(), callback)); | 156 factory_.GetWeakPtr(), callback)); |
| 157 } | 157 } |
| 158 | 158 |
| 159 // LocalFileSyncService::Observer overrides. | 159 // LocalFileSyncService::Observer overrides. |
| 160 virtual void OnLocalChangeAvailable(int64 pending_changes) override { | 160 void OnLocalChangeAvailable(int64 pending_changes) override { |
| 161 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 161 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 162 | 162 |
| 163 OnChangesUpdated(pending_changes); | 163 OnChangesUpdated(pending_changes); |
| 164 | 164 |
| 165 // Kick other sync runners just in case they're not running. | 165 // Kick other sync runners just in case they're not running. |
| 166 GetSyncService()->RunForEachSyncRunners(&SyncProcessRunner::Schedule); | 166 GetSyncService()->RunForEachSyncRunners(&SyncProcessRunner::Schedule); |
| 167 } | 167 } |
| 168 | 168 |
| 169 private: | 169 private: |
| 170 void DidProcessLocalChange( | 170 void DidProcessLocalChange( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 189 RemoteSyncRunner(const std::string& name, | 189 RemoteSyncRunner(const std::string& name, |
| 190 SyncFileSystemService* sync_service, | 190 SyncFileSystemService* sync_service, |
| 191 RemoteFileSyncService* remote_service) | 191 RemoteFileSyncService* remote_service) |
| 192 : SyncProcessRunner(name, sync_service, | 192 : SyncProcessRunner(name, sync_service, |
| 193 nullptr, /* timer_helper */ | 193 nullptr, /* timer_helper */ |
| 194 1 /* max_parallel_task */), | 194 1 /* max_parallel_task */), |
| 195 remote_service_(remote_service), | 195 remote_service_(remote_service), |
| 196 last_state_(REMOTE_SERVICE_OK), | 196 last_state_(REMOTE_SERVICE_OK), |
| 197 factory_(this) {} | 197 factory_(this) {} |
| 198 | 198 |
| 199 virtual void StartSync(const SyncStatusCallback& callback) override { | 199 void StartSync(const SyncStatusCallback& callback) override { |
| 200 remote_service_->ProcessRemoteChange( | 200 remote_service_->ProcessRemoteChange( |
| 201 base::Bind(&RemoteSyncRunner::DidProcessRemoteChange, | 201 base::Bind(&RemoteSyncRunner::DidProcessRemoteChange, |
| 202 factory_.GetWeakPtr(), callback)); | 202 factory_.GetWeakPtr(), callback)); |
| 203 } | 203 } |
| 204 | 204 |
| 205 virtual SyncServiceState GetServiceState() override { | 205 SyncServiceState GetServiceState() override { |
| 206 return RemoteStateToSyncServiceState(last_state_); | 206 return RemoteStateToSyncServiceState(last_state_); |
| 207 } | 207 } |
| 208 | 208 |
| 209 // RemoteFileSyncService::Observer overrides. | 209 // RemoteFileSyncService::Observer overrides. |
| 210 virtual void OnRemoteChangeQueueUpdated(int64 pending_changes) override { | 210 void OnRemoteChangeQueueUpdated(int64 pending_changes) override { |
| 211 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 211 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 212 | 212 |
| 213 OnChangesUpdated(pending_changes); | 213 OnChangesUpdated(pending_changes); |
| 214 | 214 |
| 215 // Kick other sync runners just in case they're not running. | 215 // Kick other sync runners just in case they're not running. |
| 216 GetSyncService()->RunForEachSyncRunners(&SyncProcessRunner::Schedule); | 216 GetSyncService()->RunForEachSyncRunners(&SyncProcessRunner::Schedule); |
| 217 } | 217 } |
| 218 | 218 |
| 219 virtual void OnRemoteServiceStateUpdated( | 219 void OnRemoteServiceStateUpdated(RemoteServiceState state, |
| 220 RemoteServiceState state, | 220 const std::string& description) override { |
| 221 const std::string& description) override { | |
| 222 // Just forward to SyncFileSystemService. | 221 // Just forward to SyncFileSystemService. |
| 223 GetSyncService()->OnRemoteServiceStateUpdated(state, description); | 222 GetSyncService()->OnRemoteServiceStateUpdated(state, description); |
| 224 last_state_ = state; | 223 last_state_ = state; |
| 225 } | 224 } |
| 226 | 225 |
| 227 private: | 226 private: |
| 228 void DidProcessRemoteChange( | 227 void DidProcessRemoteChange( |
| 229 const SyncStatusCallback& callback, | 228 const SyncStatusCallback& callback, |
| 230 SyncStatusCode status, | 229 SyncStatusCode status, |
| 231 const FileSystemURL& url) { | 230 const FileSystemURL& url) { |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 iter != remote_sync_runners_.end(); ++iter) | 747 iter != remote_sync_runners_.end(); ++iter) |
| 749 ((*iter)->*method)(); | 748 ((*iter)->*method)(); |
| 750 } | 749 } |
| 751 | 750 |
| 752 RemoteFileSyncService* SyncFileSystemService::GetRemoteService( | 751 RemoteFileSyncService* SyncFileSystemService::GetRemoteService( |
| 753 const GURL& origin) { | 752 const GURL& origin) { |
| 754 return remote_service_.get(); | 753 return remote_service_.get(); |
| 755 } | 754 } |
| 756 | 755 |
| 757 } // namespace sync_file_system | 756 } // namespace sync_file_system |
| OLD | NEW |