| 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> |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 bool GetPendingChangeForFileSystemURL(const fileapi::FileSystemURL& url, | 334 bool GetPendingChangeForFileSystemURL(const fileapi::FileSystemURL& url, |
| 335 RemoteChange* change) const; | 335 RemoteChange* change) const; |
| 336 | 336 |
| 337 // A wrapper implementation to GDataErrorCodeToSyncStatusCode which returns | 337 // A wrapper implementation to GDataErrorCodeToSyncStatusCode which returns |
| 338 // authentication error if the user is not signed in. | 338 // authentication error if the user is not signed in. |
| 339 fileapi::SyncStatusCode GDataErrorCodeToSyncStatusCodeWrapper( | 339 fileapi::SyncStatusCode GDataErrorCodeToSyncStatusCodeWrapper( |
| 340 google_apis::GDataErrorCode error) const; | 340 google_apis::GDataErrorCode error) const; |
| 341 | 341 |
| 342 base::FilePath temporary_file_dir_; | 342 base::FilePath temporary_file_dir_; |
| 343 | 343 |
| 344 // May start batch sync or incremental sync. |
| 345 // This immediately returns if: |
| 346 // - Another task is running (i.e. task_ is null), or |
| 347 // - The service state is DISABLED. |
| 348 // |
| 349 // This calls: |
| 350 // - StartBatchSyncForOrigin() if it has any pending batch sync origins, or |
| 351 // - FetchChangesForIncrementalSync() otherwise. |
| 352 // |
| 353 // These two methods are called only from this method. |
| 354 void MaybeStartFetchChanges(); |
| 355 |
| 344 void FetchChangesForIncrementalSync(); | 356 void FetchChangesForIncrementalSync(); |
| 345 void DidFetchChangesForIncrementalSync( | 357 void DidFetchChangesForIncrementalSync( |
| 346 scoped_ptr<TaskToken> token, | 358 scoped_ptr<TaskToken> token, |
| 347 bool has_new_changes, | 359 bool has_new_changes, |
| 348 google_apis::GDataErrorCode error, | 360 google_apis::GDataErrorCode error, |
| 349 scoped_ptr<google_apis::ResourceList> changes); | 361 scoped_ptr<google_apis::ResourceList> changes); |
| 350 bool GetOriginForEntry(const google_apis::ResourceEntry& entry, GURL* origin); | 362 bool GetOriginForEntry(const google_apis::ResourceEntry& entry, GURL* origin); |
| 351 void SchedulePolling(); | 363 void SchedulePolling(); |
| 364 void OnPollingTimerFired(); |
| 352 void UpdatePollingDelay(int64 new_delay_sec); | 365 void UpdatePollingDelay(int64 new_delay_sec); |
| 353 void RegisterDriveNotifications(); | 366 void RegisterDriveNotifications(); |
| 354 void SetPushNotificationEnabled(syncer::InvalidatorState state); | 367 void SetPushNotificationEnabled(syncer::InvalidatorState state); |
| 355 | 368 |
| 356 scoped_ptr<DriveMetadataStore> metadata_store_; | 369 scoped_ptr<DriveMetadataStore> metadata_store_; |
| 357 scoped_ptr<DriveFileSyncClient> sync_client_; | 370 scoped_ptr<DriveFileSyncClient> sync_client_; |
| 358 | 371 |
| 359 Profile* profile_; | 372 Profile* profile_; |
| 360 fileapi::SyncStatusCode last_operation_status_; | 373 fileapi::SyncStatusCode last_operation_status_; |
| 361 std::deque<base::Closure> pending_tasks_; | 374 std::deque<base::Closure> pending_tasks_; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 387 | 400 |
| 388 // True when Drive File Sync Service is registered for Drive notifications. | 401 // True when Drive File Sync Service is registered for Drive notifications. |
| 389 bool push_notification_registered_; | 402 bool push_notification_registered_; |
| 390 // True once the first drive notification is received with OK state. | 403 // True once the first drive notification is received with OK state. |
| 391 bool push_notification_enabled_; | 404 bool push_notification_enabled_; |
| 392 // Timer to trigger fetching changes for incremental sync. | 405 // Timer to trigger fetching changes for incremental sync. |
| 393 base::OneShotTimer<DriveFileSyncService> polling_timer_; | 406 base::OneShotTimer<DriveFileSyncService> polling_timer_; |
| 394 // If polling_delay_seconds_ is negative (<0) the timer won't start. | 407 // If polling_delay_seconds_ is negative (<0) the timer won't start. |
| 395 int64 polling_delay_seconds_; | 408 int64 polling_delay_seconds_; |
| 396 | 409 |
| 397 // Is set to true while the service is fetching changes for incremental | 410 // Is set to true when there's a fair possibility that we have some |
| 398 // sync. Polling will be disabled while this is true. | 411 // remote changes that haven't been fetched yet. |
| 399 bool is_fetching_changes_; | 412 // |
| 413 // This flag is set when: |
| 414 // - This gets invalidation notification, |
| 415 // - The service is authenticated or becomes online, and |
| 416 // - The polling timer is fired. |
| 417 // |
| 418 // This flag is cleared when: |
| 419 // - A batch or incremental sync has been started, and |
| 420 // - When all pending batch sync tasks have been finished. |
| 421 bool may_have_unfetched_changes_; |
| 400 | 422 |
| 401 ObserverList<Observer> service_observers_; | 423 ObserverList<Observer> service_observers_; |
| 402 ObserverList<FileStatusObserver> file_status_observers_; | 424 ObserverList<FileStatusObserver> file_status_observers_; |
| 403 | 425 |
| 404 // Use WeakPtrFactory instead of SupportsWeakPtr to revoke the weak pointer | 426 // Use WeakPtrFactory instead of SupportsWeakPtr to revoke the weak pointer |
| 405 // in |token_|. | 427 // in |token_|. |
| 406 base::WeakPtrFactory<DriveFileSyncService> weak_factory_; | 428 base::WeakPtrFactory<DriveFileSyncService> weak_factory_; |
| 407 | 429 |
| 408 DISALLOW_COPY_AND_ASSIGN(DriveFileSyncService); | 430 DISALLOW_COPY_AND_ASSIGN(DriveFileSyncService); |
| 409 }; | 431 }; |
| 410 | 432 |
| 411 } // namespace sync_file_system | 433 } // namespace sync_file_system |
| 412 | 434 |
| 413 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_FILE_SYNC_SERVICE_H_ | 435 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_FILE_SYNC_SERVICE_H_ |
| OLD | NEW |