Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1190)

Side by Side Diff: chrome/browser/sync_file_system/drive_file_sync_service.h

Issue 13891016: Merge ChromeOS and SyncFS XMPP Notification into one class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ChromeOS SigFault fix Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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.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"
20 #include "chrome/browser/google_apis/drive_notification_observer.h" 19 #include "chrome/browser/google_apis/drive_notification_observer.h"
21 #include "chrome/browser/sync_file_system/drive_file_sync_client_interface.h" 20 #include "chrome/browser/sync_file_system/drive_file_sync_client_interface.h"
22 #include "chrome/browser/sync_file_system/drive_metadata_store.h" 21 #include "chrome/browser/sync_file_system/drive_metadata_store.h"
23 #include "chrome/browser/sync_file_system/local_change_processor.h" 22 #include "chrome/browser/sync_file_system/local_change_processor.h"
24 #include "chrome/browser/sync_file_system/remote_file_sync_service.h" 23 #include "chrome/browser/sync_file_system/remote_file_sync_service.h"
25 #include "webkit/fileapi/syncable/file_change.h" 24 #include "webkit/fileapi/syncable/file_change.h"
26 #include "webkit/fileapi/syncable/sync_action.h" 25 #include "webkit/fileapi/syncable/sync_action.h"
27 #include "webkit/fileapi/syncable/sync_callbacks.h" 26 #include "webkit/fileapi/syncable/sync_callbacks.h"
28 #include "webkit/fileapi/syncable/sync_direction.h" 27 #include "webkit/fileapi/syncable/sync_direction.h"
29 #include "webkit/fileapi/syncable/sync_status_code.h" 28 #include "webkit/fileapi/syncable/sync_status_code.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 const base::FilePath& local_file_path, 107 const base::FilePath& local_file_path,
109 const SyncFileMetadata& local_file_metadata, 108 const SyncFileMetadata& local_file_metadata,
110 const fileapi::FileSystemURL& url, 109 const fileapi::FileSystemURL& url,
111 const SyncStatusCallback& callback) OVERRIDE; 110 const SyncStatusCallback& callback) OVERRIDE;
112 111
113 // DriveFileSyncClientObserver overrides. 112 // DriveFileSyncClientObserver overrides.
114 virtual void OnAuthenticated() OVERRIDE; 113 virtual void OnAuthenticated() OVERRIDE;
115 virtual void OnNetworkConnected() OVERRIDE; 114 virtual void OnNetworkConnected() OVERRIDE;
116 115
117 // google_apis::DriveNotificationObserver implementation. 116 // google_apis::DriveNotificationObserver implementation.
118 virtual void CheckForUpdates() OVERRIDE; 117 virtual void OnNotificationReceived() OVERRIDE;
119 118
120 private: 119 private:
121 friend class DriveFileSyncServiceMockTest; 120 friend class DriveFileSyncServiceMockTest;
122 friend class DriveFileSyncServiceSyncTest; 121 friend class DriveFileSyncServiceSyncTest;
123 class TaskToken; 122 class TaskToken;
124 struct ApplyLocalChangeParam; 123 struct ApplyLocalChangeParam;
125 struct ProcessRemoteChangeParam; 124 struct ProcessRemoteChangeParam;
126 125
127 enum RemoteSyncType { 126 enum RemoteSyncType {
128 // Smaller number indicates higher priority in ChangeQueue. 127 // Smaller number indicates higher priority in ChangeQueue.
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 // These two methods are called only from this method. 437 // These two methods are called only from this method.
439 void MaybeStartFetchChanges(); 438 void MaybeStartFetchChanges();
440 439
441 void FetchChangesForIncrementalSync(); 440 void FetchChangesForIncrementalSync();
442 void DidFetchChangesForIncrementalSync( 441 void DidFetchChangesForIncrementalSync(
443 scoped_ptr<TaskToken> token, 442 scoped_ptr<TaskToken> token,
444 bool has_new_changes, 443 bool has_new_changes,
445 google_apis::GDataErrorCode error, 444 google_apis::GDataErrorCode error,
446 scoped_ptr<google_apis::ResourceList> changes); 445 scoped_ptr<google_apis::ResourceList> changes);
447 bool GetOriginForEntry(const google_apis::ResourceEntry& entry, GURL* origin); 446 bool GetOriginForEntry(const google_apis::ResourceEntry& entry, GURL* origin);
448 void SchedulePolling();
449 void OnPollingTimerFired();
450 void UpdatePollingDelay(int64 new_delay_sec);
451 void NotifyObserversFileStatusChanged(const fileapi::FileSystemURL& url, 447 void NotifyObserversFileStatusChanged(const fileapi::FileSystemURL& url,
452 SyncFileStatus sync_status, 448 SyncFileStatus sync_status,
453 SyncAction action_taken, 449 SyncAction action_taken,
454 SyncDirection direction); 450 SyncDirection direction);
455 451
456 void HandleSyncRootDirectoryChange(const google_apis::ResourceEntry& entry); 452 void HandleSyncRootDirectoryChange(const google_apis::ResourceEntry& entry);
457 void HandleOriginRootDirectoryChange(const google_apis::ResourceEntry& entry); 453 void HandleOriginRootDirectoryChange(const google_apis::ResourceEntry& entry);
458 454
459 void EnsureSyncRootDirectory(const ResourceIdCallback& callback); 455 void EnsureSyncRootDirectory(const ResourceIdCallback& callback);
460 void DidEnsureSyncRoot(const ResourceIdCallback& callback, 456 void DidEnsureSyncRoot(const ResourceIdCallback& callback,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 498
503 std::set<GURL> pending_batch_sync_origins_; 499 std::set<GURL> pending_batch_sync_origins_;
504 500
505 // Absence of |token_| implies a task is running. Incoming tasks should 501 // Absence of |token_| implies a task is running. Incoming tasks should
506 // wait for the task to finish in |pending_tasks_| if |token_| is null. 502 // wait for the task to finish in |pending_tasks_| if |token_| is null.
507 // Each task must take TaskToken instance from |token_| and must hold it 503 // Each task must take TaskToken instance from |token_| and must hold it
508 // until it finished. And the task must return the instance through 504 // until it finished. And the task must return the instance through
509 // NotifyTaskDone when the task finished. 505 // NotifyTaskDone when the task finished.
510 scoped_ptr<TaskToken> token_; 506 scoped_ptr<TaskToken> token_;
511 507
512 // Timer to trigger fetching changes for incremental sync.
513 base::OneShotTimer<DriveFileSyncService> polling_timer_;
514 // If polling_delay_seconds_ is negative (<0) the timer won't start.
515 int64 polling_delay_seconds_;
516
517 // Is set to true when there's a fair possibility that we have some 508 // Is set to true when there's a fair possibility that we have some
518 // remote changes that haven't been fetched yet. 509 // remote changes that haven't been fetched yet.
519 // 510 //
520 // This flag is set when: 511 // This flag is set when:
521 // - This gets invalidation notification, 512 // - This gets invalidation notification,
522 // - The service is authenticated or becomes online, and 513 // - The service is authenticated or becomes online, and
523 // - The polling timer is fired. 514 // - The polling timer is fired.
524 // 515 //
525 // This flag is cleared when: 516 // This flag is cleared when:
526 // - A batch or incremental sync has been started, and 517 // - A batch or incremental sync has been started, and
(...skipping 10 matching lines...) Expand all
537 // Use WeakPtrFactory instead of SupportsWeakPtr to revoke the weak pointer 528 // Use WeakPtrFactory instead of SupportsWeakPtr to revoke the weak pointer
538 // in |token_|. 529 // in |token_|.
539 base::WeakPtrFactory<DriveFileSyncService> weak_factory_; 530 base::WeakPtrFactory<DriveFileSyncService> weak_factory_;
540 531
541 DISALLOW_COPY_AND_ASSIGN(DriveFileSyncService); 532 DISALLOW_COPY_AND_ASSIGN(DriveFileSyncService);
542 }; 533 };
543 534
544 } // namespace sync_file_system 535 } // namespace sync_file_system
545 536
546 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_FILE_SYNC_SERVICE_H_ 537 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_FILE_SYNC_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/google_apis/drive_notification_observer.h ('k') | chrome/browser/sync_file_system/drive_file_sync_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698