| 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 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_FILE_SYNC_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_FILE_SYNC_SERVICE_H_ |
| 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_FILE_SYNC_SERVICE_H_ | 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_FILE_SYNC_SERVICE_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/callback_forward.h" | 14 #include "base/callback_forward.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
| 18 #include "base/threading/non_thread_safe.h" | 18 #include "base/threading/non_thread_safe.h" |
| 19 #include "base/timer.h" |
| 19 #include "chrome/browser/sync_file_system/drive_file_sync_client.h" | 20 #include "chrome/browser/sync_file_system/drive_file_sync_client.h" |
| 20 #include "chrome/browser/sync_file_system/local_change_processor.h" | 21 #include "chrome/browser/sync_file_system/local_change_processor.h" |
| 21 #include "chrome/browser/sync_file_system/remote_file_sync_service.h" | 22 #include "chrome/browser/sync_file_system/remote_file_sync_service.h" |
| 22 #include "webkit/fileapi/syncable/file_change.h" | 23 #include "webkit/fileapi/syncable/file_change.h" |
| 23 #include "webkit/fileapi/syncable/sync_callbacks.h" | 24 #include "webkit/fileapi/syncable/sync_callbacks.h" |
| 24 #include "webkit/fileapi/syncable/sync_operation_type.h" | 25 #include "webkit/fileapi/syncable/sync_operation_type.h" |
| 25 | 26 |
| 26 namespace google_apis { | 27 namespace google_apis { |
| 27 class DocumentFeed; | 28 class DocumentFeed; |
| 28 } | 29 } |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 scoped_ptr<ProcessRemoteChangeParam> param, | 274 scoped_ptr<ProcessRemoteChangeParam> param, |
| 274 fileapi::SyncStatusCode status); | 275 fileapi::SyncStatusCode status); |
| 275 void AbortRemoteSync( | 276 void AbortRemoteSync( |
| 276 scoped_ptr<ProcessRemoteChangeParam> param, | 277 scoped_ptr<ProcessRemoteChangeParam> param, |
| 277 fileapi::SyncStatusCode status); | 278 fileapi::SyncStatusCode status); |
| 278 void FinalizeRemoteSync( | 279 void FinalizeRemoteSync( |
| 279 scoped_ptr<ProcessRemoteChangeParam> param, | 280 scoped_ptr<ProcessRemoteChangeParam> param, |
| 280 fileapi::SyncStatusCode status); | 281 fileapi::SyncStatusCode status); |
| 281 | 282 |
| 282 void AppendNewRemoteChange(const GURL& origin, | 283 void AppendNewRemoteChange(const GURL& origin, |
| 283 google_apis::DocumentEntry* entry, | 284 const google_apis::DocumentEntry& entry, |
| 284 int64 changestamp, | 285 int64 changestamp, |
| 285 RemoteSyncType sync_type); | 286 RemoteSyncType sync_type); |
| 286 void CancelRemoteChange(const fileapi::FileSystemURL& url); | 287 void RemoveRemoteChange(const fileapi::FileSystemURL& url); |
| 287 void MaybeMarkAsIncrementalSyncOrigin(const GURL& origin); | 288 void MaybeMarkAsIncrementalSyncOrigin(const GURL& origin); |
| 288 | 289 |
| 289 // This returns false if no change is found for the |url|. | 290 // This returns false if no change is found for the |url|. |
| 290 bool GetPendingChangeForFileSystemURL(const fileapi::FileSystemURL& url, | 291 bool GetPendingChangeForFileSystemURL(const fileapi::FileSystemURL& url, |
| 291 RemoteChange* change) const; | 292 RemoteChange* change) const; |
| 292 | 293 |
| 293 // A wrapper implementation to GDataErrorCodeToSyncStatusCode which returns | 294 // A wrapper implementation to GDataErrorCodeToSyncStatusCode which returns |
| 294 // authentication error if the user is not signed in. | 295 // authentication error if the user is not signed in. |
| 295 fileapi::SyncStatusCode GDataErrorCodeToSyncStatusCodeWrapper( | 296 fileapi::SyncStatusCode GDataErrorCodeToSyncStatusCodeWrapper( |
| 296 google_apis::GDataErrorCode error) const; | 297 google_apis::GDataErrorCode error) const; |
| 297 | 298 |
| 298 FilePath temporary_file_dir_; | 299 FilePath temporary_file_dir_; |
| 299 | 300 |
| 301 void FetchChangesForIncrementalSync(); |
| 302 void DidFetchChangesForIncrementalSync( |
| 303 scoped_ptr<TaskToken> token, |
| 304 google_apis::GDataErrorCode error, |
| 305 scoped_ptr<google_apis::DocumentFeed> changes); |
| 306 bool GetOriginForEntry(const google_apis::DocumentEntry& entry, GURL* origin); |
| 307 void SchedulePolling(); |
| 308 |
| 300 scoped_ptr<DriveMetadataStore> metadata_store_; | 309 scoped_ptr<DriveMetadataStore> metadata_store_; |
| 301 scoped_ptr<DriveFileSyncClient> sync_client_; | 310 scoped_ptr<DriveFileSyncClient> sync_client_; |
| 302 | 311 |
| 303 fileapi::SyncStatusCode last_operation_status_; | 312 fileapi::SyncStatusCode last_operation_status_; |
| 304 RemoteServiceState state_; | 313 RemoteServiceState state_; |
| 305 std::deque<base::Closure> pending_tasks_; | 314 std::deque<base::Closure> pending_tasks_; |
| 306 | 315 |
| 307 int64 largest_changestamp_; | 316 int64 largest_fetched_changestamp_; |
| 317 |
| 308 PendingChangeQueue pending_changes_; | 318 PendingChangeQueue pending_changes_; |
| 309 URLToChange url_to_change_; | 319 URLToChange url_to_change_; |
| 310 | 320 |
| 311 std::set<GURL> pending_batch_sync_origins_; | 321 std::set<GURL> pending_batch_sync_origins_; |
| 312 | 322 |
| 313 // Absence of |token_| implies a task is running. Incoming tasks should | 323 // Absence of |token_| implies a task is running. Incoming tasks should |
| 314 // wait for the task to finish in |pending_tasks_| if |token_| is null. | 324 // wait for the task to finish in |pending_tasks_| if |token_| is null. |
| 315 // Each task must take TaskToken instance from |token_| and must hold it | 325 // Each task must take TaskToken instance from |token_| and must hold it |
| 316 // until it finished. And the task must return the instance through | 326 // until it finished. And the task must return the instance through |
| 317 // NotifyTaskDone when the task finished. | 327 // NotifyTaskDone when the task finished. |
| 318 scoped_ptr<TaskToken> token_; | 328 scoped_ptr<TaskToken> token_; |
| 319 | 329 |
| 330 base::OneShotTimer<DriveFileSyncService> polling_timer_; |
| 331 int64 polling_delay_seconds_; |
| 332 bool polling_enabled_; |
| 333 |
| 320 ObserverList<Observer> observers_; | 334 ObserverList<Observer> observers_; |
| 321 | 335 |
| 322 // Use WeakPtrFactory instead of SupportsWeakPtr to revoke the weak pointer | 336 // Use WeakPtrFactory instead of SupportsWeakPtr to revoke the weak pointer |
| 323 // in |token_|. | 337 // in |token_|. |
| 324 base::WeakPtrFactory<DriveFileSyncService> weak_factory_; | 338 base::WeakPtrFactory<DriveFileSyncService> weak_factory_; |
| 325 | 339 |
| 326 DISALLOW_COPY_AND_ASSIGN(DriveFileSyncService); | 340 DISALLOW_COPY_AND_ASSIGN(DriveFileSyncService); |
| 327 }; | 341 }; |
| 328 | 342 |
| 329 } // namespace sync_file_system | 343 } // namespace sync_file_system |
| 330 | 344 |
| 331 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_FILE_SYNC_SERVICE_H_ | 345 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_FILE_SYNC_SERVICE_H_ |
| OLD | NEW |