Chromium Code Reviews| 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/drive/drive_service_interface.h" | 12 #include "chrome/browser/drive/drive_service_interface.h" |
| 13 #include "chrome/browser/sync_file_system/drive_backend/sync_engine_context.h" | 13 #include "chrome/browser/sync_file_system/drive_backend/sync_engine_context.h" |
| 14 #include "chrome/browser/sync_file_system/local_change_processor.h" | 14 #include "chrome/browser/sync_file_system/local_change_processor.h" |
| 15 #include "chrome/browser/sync_file_system/remote_file_sync_service.h" | 15 #include "chrome/browser/sync_file_system/remote_file_sync_service.h" |
| 16 #include "chrome/browser/sync_file_system/sync_task_manager.h" | 16 #include "chrome/browser/sync_file_system/sync_task_manager.h" |
| 17 #include "net/base/network_change_notifier.h" | 17 #include "net/base/network_change_notifier.h" |
| 18 | 18 |
| 19 class ExtensionService; | 19 class ExtensionServiceInterface; |
| 20 | 20 |
| 21 namespace base { | 21 namespace base { |
| 22 class SequencedTaskRunner; | 22 class SequencedTaskRunner; |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace drive { | 25 namespace drive { |
| 26 class DriveServiceInterface; | 26 class DriveServiceInterface; |
| 27 class DriveNotificationManager; | 27 class DriveNotificationManager; |
| 28 } | 28 } |
| 29 | 29 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 42 public drive::DriveServiceObserver, | 42 public drive::DriveServiceObserver, |
| 43 public net::NetworkChangeNotifier::NetworkChangeObserver, | 43 public net::NetworkChangeNotifier::NetworkChangeObserver, |
| 44 public SyncEngineContext { | 44 public SyncEngineContext { |
| 45 public: | 45 public: |
| 46 typedef Observer SyncServiceObserver; | 46 typedef Observer SyncServiceObserver; |
| 47 | 47 |
| 48 SyncEngine(const base::FilePath& base_dir, | 48 SyncEngine(const base::FilePath& base_dir, |
| 49 base::SequencedTaskRunner* task_runner, | 49 base::SequencedTaskRunner* task_runner, |
| 50 scoped_ptr<drive::DriveServiceInterface> drive_service, | 50 scoped_ptr<drive::DriveServiceInterface> drive_service, |
| 51 drive::DriveNotificationManager* notification_manager, | 51 drive::DriveNotificationManager* notification_manager, |
| 52 ExtensionService* extension_service); | 52 ExtensionServiceInterface* extension_service); |
| 53 virtual ~SyncEngine(); | 53 virtual ~SyncEngine(); |
| 54 | 54 |
| 55 void Initialize(); | 55 void Initialize(); |
| 56 | 56 |
| 57 // RemoteFileSyncService overrides. | 57 // RemoteFileSyncService overrides. |
| 58 virtual void AddServiceObserver(SyncServiceObserver* observer) OVERRIDE; | 58 virtual void AddServiceObserver(SyncServiceObserver* observer) OVERRIDE; |
| 59 virtual void AddFileStatusObserver(FileStatusObserver* observer) OVERRIDE; | 59 virtual void AddFileStatusObserver(FileStatusObserver* observer) OVERRIDE; |
| 60 virtual void RegisterOrigin( | 60 virtual void RegisterOrigin( |
| 61 const GURL& origin, | 61 const GURL& origin, |
| 62 const SyncStatusCallback& callback) OVERRIDE; | 62 const SyncStatusCallback& callback) OVERRIDE; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 | 112 |
| 113 // net::NetworkChangeNotifier::NetworkChangeObserver overrides. | 113 // net::NetworkChangeNotifier::NetworkChangeObserver overrides. |
| 114 virtual void OnNetworkChanged( | 114 virtual void OnNetworkChanged( |
| 115 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; | 115 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; |
| 116 | 116 |
| 117 // SyncEngineContext overrides. | 117 // SyncEngineContext overrides. |
| 118 virtual drive::DriveServiceInterface* GetDriveService() OVERRIDE; | 118 virtual drive::DriveServiceInterface* GetDriveService() OVERRIDE; |
| 119 virtual MetadataDatabase* GetMetadataDatabase() OVERRIDE; | 119 virtual MetadataDatabase* GetMetadataDatabase() OVERRIDE; |
| 120 virtual RemoteChangeProcessor* GetRemoteChangeProcessor() OVERRIDE; | 120 virtual RemoteChangeProcessor* GetRemoteChangeProcessor() OVERRIDE; |
| 121 | 121 |
| 122 | |
|
kinuko
2013/11/18 08:56:18
nit: extra empty line
keishi
2013/11/18 09:15:32
Done.
| |
| 122 private: | 123 private: |
| 124 friend class SyncEngineTest; | |
| 125 | |
| 123 void DoDisableApp(const std::string& app_id, | 126 void DoDisableApp(const std::string& app_id, |
| 124 const SyncStatusCallback& callback); | 127 const SyncStatusCallback& callback); |
| 125 void DoEnableApp(const std::string& app_id, | 128 void DoEnableApp(const std::string& app_id, |
| 126 const SyncStatusCallback& callback); | 129 const SyncStatusCallback& callback); |
| 127 | 130 |
| 128 void DidInitialize(SyncEngineInitializer* initializer, | 131 void DidInitialize(SyncEngineInitializer* initializer, |
| 129 SyncStatusCode status); | 132 SyncStatusCode status); |
| 130 void DidProcessRemoteChange(RemoteToLocalSyncer* syncer, | 133 void DidProcessRemoteChange(RemoteToLocalSyncer* syncer, |
| 131 const SyncFileCallback& callback, | 134 const SyncFileCallback& callback, |
| 132 SyncStatusCode status); | 135 SyncStatusCode status); |
| 133 void DidApplyLocalChange(LocalToRemoteSyncer* syncer, | 136 void DidApplyLocalChange(LocalToRemoteSyncer* syncer, |
| 134 const SyncStatusCallback& callback, | 137 const SyncStatusCallback& callback, |
| 135 SyncStatusCode status); | 138 SyncStatusCode status); |
| 136 void DidFetchChangeList(SyncStatusCallback& callback); | 139 void DidFetchChangeList(SyncStatusCallback& callback); |
| 137 | 140 |
| 138 void MaybeStartFetchChanges(); | 141 void MaybeStartFetchChanges(); |
| 139 void UpdateServiceStateFromSyncStatusCode( | 142 void UpdateServiceStateFromSyncStatusCode( |
| 140 SyncStatusCode state, | 143 SyncStatusCode state, |
| 141 const std::string& description); | 144 const std::string& description); |
| 142 void UpdateServiceState(RemoteServiceState state, | 145 void UpdateServiceState(RemoteServiceState state, |
| 143 const std::string& description); | 146 const std::string& description); |
| 147 void UpdateRegisteredApps(); | |
| 144 | 148 |
| 145 base::FilePath base_dir_; | 149 base::FilePath base_dir_; |
| 146 base::FilePath temporary_file_dir_; | 150 base::FilePath temporary_file_dir_; |
| 147 | 151 |
| 148 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 152 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| 149 | 153 |
| 150 scoped_ptr<drive::DriveServiceInterface> drive_service_; | 154 scoped_ptr<drive::DriveServiceInterface> drive_service_; |
| 151 scoped_ptr<MetadataDatabase> metadata_database_; | 155 scoped_ptr<MetadataDatabase> metadata_database_; |
| 152 | 156 |
| 153 // These external services are not owned by SyncEngine. | 157 // These external services are not owned by SyncEngine. |
| 154 // The owner of the SyncEngine is responsible for their lifetime. | 158 // The owner of the SyncEngine is responsible for their lifetime. |
| 155 // I.e. the owner should declare the dependency explicitly by calling | 159 // I.e. the owner should declare the dependency explicitly by calling |
| 156 // BrowserContextKeyedService::DependsOn(). | 160 // BrowserContextKeyedService::DependsOn(). |
| 157 drive::DriveNotificationManager* notification_manager_; | 161 drive::DriveNotificationManager* notification_manager_; |
| 158 ExtensionService* extension_service_; | 162 ExtensionServiceInterface* extension_service_; |
| 159 | 163 |
| 160 ObserverList<SyncServiceObserver> service_observers_; | 164 ObserverList<SyncServiceObserver> service_observers_; |
| 161 ObserverList<FileStatusObserver> file_status_observers_; | 165 ObserverList<FileStatusObserver> file_status_observers_; |
| 162 RemoteChangeProcessor* remote_change_processor_; | 166 RemoteChangeProcessor* remote_change_processor_; |
| 163 | 167 |
| 164 RemoteServiceState service_state_; | 168 RemoteServiceState service_state_; |
| 165 | 169 |
| 166 bool should_check_remote_change_; | 170 bool should_check_remote_change_; |
| 167 base::TimeTicks time_to_check_changes_; | 171 base::TimeTicks time_to_check_changes_; |
| 168 | 172 |
| 169 bool sync_enabled_; | 173 bool sync_enabled_; |
| 170 ConflictResolutionPolicy conflict_resolution_policy_; | 174 ConflictResolutionPolicy conflict_resolution_policy_; |
| 171 bool network_available_; | 175 bool network_available_; |
| 172 | 176 |
| 173 scoped_ptr<SyncTaskManager> task_manager_; | 177 scoped_ptr<SyncTaskManager> task_manager_; |
| 174 | 178 |
| 175 base::WeakPtrFactory<SyncEngine> weak_ptr_factory_; | 179 base::WeakPtrFactory<SyncEngine> weak_ptr_factory_; |
| 176 | 180 |
| 177 DISALLOW_COPY_AND_ASSIGN(SyncEngine); | 181 DISALLOW_COPY_AND_ASSIGN(SyncEngine); |
| 178 }; | 182 }; |
| 179 | 183 |
| 180 } // namespace drive_backend | 184 } // namespace drive_backend |
| 181 } // namespace sync_file_system | 185 } // namespace sync_file_system |
| 182 | 186 |
| 183 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_ENGINE_H_ | 187 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_ENGINE_H_ |
| OLD | NEW |