OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_BACKEND_SYNC_ENGINE_H_ | 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_ENGINE_H_ |
6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_ENGINE_H_ | 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_ENGINE_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
11 #include "chrome/browser/drive/drive_notification_observer.h" | 11 #include "chrome/browser/drive/drive_notification_observer.h" |
12 #include "chrome/browser/sync_file_system/local_change_processor.h" | 12 #include "chrome/browser/sync_file_system/local_change_processor.h" |
13 #include "chrome/browser/sync_file_system/remote_file_sync_service.h" | 13 #include "chrome/browser/sync_file_system/remote_file_sync_service.h" |
14 #include "chrome/browser/sync_file_system/sync_task_manager.h" | 14 #include "chrome/browser/sync_file_system/sync_task_manager.h" |
15 | 15 |
16 class ExtensionService; | 16 class ExtensionService; |
17 | 17 |
| 18 namespace base { |
| 19 class SequencedTaskRunner; |
| 20 } |
| 21 |
18 namespace drive { | 22 namespace drive { |
19 class DriveAPIService; | 23 class DriveAPIService; |
20 class DriveNotificationManager; | 24 class DriveNotificationManager; |
21 } | 25 } |
22 | 26 |
23 namespace sync_file_system { | 27 namespace sync_file_system { |
24 namespace drive_backend { | 28 namespace drive_backend { |
25 | 29 |
26 class LocalToRemoteSyncer; | 30 class LocalToRemoteSyncer; |
27 class MetadataDatabase; | 31 class MetadataDatabase; |
28 class RemoteToLocalSyncer; | 32 class RemoteToLocalSyncer; |
29 class SyncEngineInitializer; | 33 class SyncEngineInitializer; |
30 | 34 |
31 class SyncEngine : public RemoteFileSyncService, | 35 class SyncEngine : public RemoteFileSyncService, |
32 public LocalChangeProcessor, | 36 public LocalChangeProcessor, |
33 public SyncTaskManager::Client, | 37 public SyncTaskManager::Client, |
34 public drive::DriveNotificationObserver { | 38 public drive::DriveNotificationObserver { |
35 public: | 39 public: |
36 typedef Observer SyncServiceObserver; | 40 typedef Observer SyncServiceObserver; |
37 | 41 |
38 SyncEngine(const base::FilePath& base_dir, | 42 SyncEngine(const base::FilePath& base_dir, |
| 43 base::SequencedTaskRunner* task_runner, |
39 scoped_ptr<drive::DriveAPIService> drive_api, | 44 scoped_ptr<drive::DriveAPIService> drive_api, |
40 drive::DriveNotificationManager* notification_manager, | 45 drive::DriveNotificationManager* notification_manager, |
41 ExtensionService* extension_service); | 46 ExtensionService* extension_service); |
42 virtual ~SyncEngine(); | 47 virtual ~SyncEngine(); |
43 | 48 |
44 void Initialize(); | 49 void Initialize(); |
45 | 50 |
46 // RemoteFileSyncService overrides. | 51 // RemoteFileSyncService overrides. |
47 virtual void AddServiceObserver(SyncServiceObserver* observer) OVERRIDE; | 52 virtual void AddServiceObserver(SyncServiceObserver* observer) OVERRIDE; |
48 virtual void AddFileStatusObserver(FileStatusObserver* observer) OVERRIDE; | 53 virtual void AddFileStatusObserver(FileStatusObserver* observer) OVERRIDE; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 void DidProcessRemoteChange(RemoteToLocalSyncer* syncer, | 119 void DidProcessRemoteChange(RemoteToLocalSyncer* syncer, |
115 const SyncFileCallback& callback, | 120 const SyncFileCallback& callback, |
116 SyncStatusCode status); | 121 SyncStatusCode status); |
117 void DidApplyLocalChange(LocalToRemoteSyncer* syncer, | 122 void DidApplyLocalChange(LocalToRemoteSyncer* syncer, |
118 const SyncStatusCallback& callback, | 123 const SyncStatusCallback& callback, |
119 SyncStatusCode status); | 124 SyncStatusCode status); |
120 | 125 |
121 base::FilePath base_dir_; | 126 base::FilePath base_dir_; |
122 base::FilePath temporary_file_dir_; | 127 base::FilePath temporary_file_dir_; |
123 | 128 |
| 129 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| 130 |
124 scoped_ptr<drive::DriveAPIService> drive_api_; | 131 scoped_ptr<drive::DriveAPIService> drive_api_; |
125 scoped_ptr<MetadataDatabase> metadata_database_; | 132 scoped_ptr<MetadataDatabase> metadata_database_; |
126 | 133 |
127 // These external services are not owned by SyncEngine. | 134 // These external services are not owned by SyncEngine. |
128 // The owner of the SyncEngine is responsible for their lifetime. | 135 // The owner of the SyncEngine is responsible for their lifetime. |
129 // I.e. the owner should declare the dependency explicitly by calling | 136 // I.e. the owner should declare the dependency explicitly by calling |
130 // BrowserContextKeyedService::DependsOn(). | 137 // BrowserContextKeyedService::DependsOn(). |
131 drive::DriveNotificationManager* notification_manager_; | 138 drive::DriveNotificationManager* notification_manager_; |
132 ExtensionService* extension_service_; | 139 ExtensionService* extension_service_; |
133 | 140 |
134 ObserverList<SyncServiceObserver> service_observers_; | 141 ObserverList<SyncServiceObserver> service_observers_; |
135 ObserverList<FileStatusObserver> file_status_observers_; | 142 ObserverList<FileStatusObserver> file_status_observers_; |
136 RemoteChangeProcessor* remote_change_processor_; | 143 RemoteChangeProcessor* remote_change_processor_; |
137 | 144 |
138 base::WeakPtrFactory<SyncEngine> weak_ptr_factory_; | 145 base::WeakPtrFactory<SyncEngine> weak_ptr_factory_; |
139 SyncTaskManager task_manager_; | 146 SyncTaskManager task_manager_; |
140 | 147 |
141 DISALLOW_COPY_AND_ASSIGN(SyncEngine); | 148 DISALLOW_COPY_AND_ASSIGN(SyncEngine); |
142 }; | 149 }; |
143 | 150 |
144 } // namespace drive_backend | 151 } // namespace drive_backend |
145 } // namespace sync_file_system | 152 } // namespace sync_file_system |
146 | 153 |
147 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_ENGINE_H_ | 154 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_ENGINE_H_ |
OLD | NEW |