Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_WORKER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_WORKER_H_ |
| 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_WORKER_H_ | 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_WORKER_H_ |
| 7 | 7 |
| 8 #include <set> | |
| 9 #include <string> | 8 #include <string> |
| 10 | 9 |
| 10 #include "base/files/file_path.h" | |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
| 14 #include "chrome/browser/drive/drive_notification_observer.h" | |
| 15 #include "chrome/browser/drive/drive_service_interface.h" | |
| 16 #include "chrome/browser/sync_file_system/drive_backend/sync_task_manager.h" | 14 #include "chrome/browser/sync_file_system/drive_backend/sync_task_manager.h" |
| 17 #include "chrome/browser/sync_file_system/local_change_processor.h" | 15 #include "chrome/browser/sync_file_system/drive_backend/sync_worker_interface.h" |
| 18 #include "chrome/browser/sync_file_system/remote_file_sync_service.h" | 16 #include "chrome/browser/sync_file_system/remote_file_sync_service.h" |
| 19 #include "chrome/browser/sync_file_system/sync_action.h" | 17 #include "chrome/browser/sync_file_system/sync_action.h" |
| 20 #include "chrome/browser/sync_file_system/sync_direction.h" | 18 #include "chrome/browser/sync_file_system/sync_direction.h" |
| 21 #include "chrome/browser/sync_file_system/task_logger.h" | 19 #include "chrome/browser/sync_file_system/task_logger.h" |
| 22 #include "net/base/network_change_notifier.h" | 20 #include "net/base/network_change_notifier.h" |
| 23 | 21 |
| 24 class ExtensionServiceInterface; | 22 class ExtensionServiceInterface; |
| 23 class FileChange; | |
| 24 class GURL; | |
| 25 class SyncStatusCallback; | |
|
tzik
2014/06/11 04:23:07
This is a typedef name which can't be declared for
peria
2014/06/11 04:45:09
Done.
| |
| 26 class SyncFileMetadata; | |
| 25 | 27 |
| 26 namespace base { | 28 namespace base { |
| 27 class SequencedTaskRunner; | 29 class ListValue; |
| 28 } | 30 } |
| 29 | 31 |
| 30 namespace drive { | 32 namespace drive { |
| 31 class DriveServiceInterface; | 33 class DriveServiceInterface; |
| 32 class DriveNotificationManager; | |
| 33 class DriveUploaderInterface; | 34 class DriveUploaderInterface; |
| 34 } | 35 } |
| 35 | 36 |
| 37 namespace fileapi { | |
| 38 class FileSystemURL; | |
| 39 } | |
| 40 | |
| 36 namespace leveldb { | 41 namespace leveldb { |
| 37 class Env; | 42 class Env; |
| 38 } | 43 } |
| 39 | 44 |
| 40 namespace sync_file_system { | 45 namespace sync_file_system { |
| 41 | |
| 42 class RemoteChangeProcessor; | |
| 43 | |
| 44 namespace drive_backend { | 46 namespace drive_backend { |
| 45 | 47 |
| 46 class LocalToRemoteSyncer; | 48 class LocalToRemoteSyncer; |
| 47 class MetadataDatabase; | 49 class MetadataDatabase; |
| 48 class RemoteChangeProcessorOnWorker; | 50 class RemoteChangeProcessorOnWorker; |
| 49 class RemoteToLocalSyncer; | 51 class RemoteToLocalSyncer; |
| 50 class SyncEngineContext; | 52 class SyncEngineContext; |
| 51 class SyncEngineInitializer; | 53 class SyncEngineInitializer; |
| 52 | 54 |
| 53 class SyncWorker : public SyncTaskManager::Client { | 55 class SyncWorker : public SyncWorkerInterface, |
| 56 public SyncTaskManager::Client { | |
| 54 public: | 57 public: |
| 55 enum AppStatus { | 58 enum AppStatus { |
| 56 APP_STATUS_ENABLED, | 59 APP_STATUS_ENABLED, |
| 57 APP_STATUS_DISABLED, | 60 APP_STATUS_DISABLED, |
| 58 APP_STATUS_UNINSTALLED, | 61 APP_STATUS_UNINSTALLED, |
| 59 }; | 62 }; |
| 60 | 63 |
| 61 typedef base::hash_map<std::string, AppStatus> AppStatusMap; | 64 typedef base::hash_map<std::string, AppStatus> AppStatusMap; |
| 62 | 65 |
| 63 class Observer { | 66 class Observer { |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 74 virtual ~Observer() {} | 77 virtual ~Observer() {} |
| 75 }; | 78 }; |
| 76 | 79 |
| 77 SyncWorker(const base::FilePath& base_dir, | 80 SyncWorker(const base::FilePath& base_dir, |
| 78 const base::WeakPtr<ExtensionServiceInterface>& extension_service, | 81 const base::WeakPtr<ExtensionServiceInterface>& extension_service, |
| 79 scoped_ptr<SyncEngineContext> sync_engine_context, | 82 scoped_ptr<SyncEngineContext> sync_engine_context, |
| 80 leveldb::Env* env_override); | 83 leveldb::Env* env_override); |
| 81 | 84 |
| 82 virtual ~SyncWorker(); | 85 virtual ~SyncWorker(); |
| 83 | 86 |
| 84 void Initialize(); | 87 virtual void Initialize() OVERRIDE; |
| 85 | 88 |
| 86 // SyncTaskManager::Client overrides | 89 // SyncTaskManager::Client overrides |
| 87 virtual void MaybeScheduleNextTask() OVERRIDE; | 90 virtual void MaybeScheduleNextTask() OVERRIDE; |
| 88 virtual void NotifyLastOperationStatus( | 91 virtual void NotifyLastOperationStatus( |
| 89 SyncStatusCode sync_status, bool used_network) OVERRIDE; | 92 SyncStatusCode sync_status, bool used_network) OVERRIDE; |
| 90 virtual void RecordTaskLog(scoped_ptr<TaskLogger::TaskLog> task_log) OVERRIDE; | 93 virtual void RecordTaskLog(scoped_ptr<TaskLogger::TaskLog> task_log) OVERRIDE; |
| 91 | 94 |
| 92 void RegisterOrigin(const GURL& origin, const SyncStatusCallback& callback); | 95 // SyncWorkerInterface overrides |
| 93 void EnableOrigin(const GURL& origin, const SyncStatusCallback& callback); | 96 virtual void RegisterOrigin(const GURL& origin, |
| 94 void DisableOrigin(const GURL& origin, const SyncStatusCallback& callback); | 97 const SyncStatusCallback& callback) OVERRIDE; |
| 95 void UninstallOrigin( | 98 virtual void EnableOrigin(const GURL& origin, |
| 96 const GURL& origin, | 99 const SyncStatusCallback& callback) OVERRIDE; |
| 97 RemoteFileSyncService::UninstallFlag flag, | 100 virtual void DisableOrigin(const GURL& origin, |
| 98 const SyncStatusCallback& callback); | 101 const SyncStatusCallback& callback) OVERRIDE; |
| 99 void ProcessRemoteChange(const SyncFileCallback& callback); | 102 virtual void UninstallOrigin(const GURL& origin, |
| 100 void SetRemoteChangeProcessor( | 103 RemoteFileSyncService::UninstallFlag flag, |
| 101 RemoteChangeProcessorOnWorker* remote_change_processor_on_worker); | 104 const SyncStatusCallback& callback) OVERRIDE; |
| 102 RemoteServiceState GetCurrentState() const; | 105 virtual void ProcessRemoteChange(const SyncFileCallback& callback) OVERRIDE; |
| 103 void GetOriginStatusMap( | 106 virtual void SetRemoteChangeProcessor( |
| 104 const RemoteFileSyncService::StatusMapCallback& callback); | 107 RemoteChangeProcessorOnWorker* remote_change_processor_on_worker) |
| 105 scoped_ptr<base::ListValue> DumpFiles(const GURL& origin); | 108 OVERRIDE; |
| 106 scoped_ptr<base::ListValue> DumpDatabase(); | 109 virtual RemoteServiceState GetCurrentState() const OVERRIDE; |
| 107 void SetSyncEnabled(bool enabled); | 110 virtual void GetOriginStatusMap( |
| 108 void PromoteDemotedChanges(); | 111 const RemoteFileSyncService::StatusMapCallback& callback) OVERRIDE; |
| 109 SyncStatusCode SetDefaultConflictResolutionPolicy( | 112 virtual scoped_ptr<base::ListValue> DumpFiles(const GURL& origin) OVERRIDE; |
| 110 ConflictResolutionPolicy policy); | 113 virtual scoped_ptr<base::ListValue> DumpDatabase() OVERRIDE; |
| 111 SyncStatusCode SetConflictResolutionPolicy( | 114 virtual void SetSyncEnabled(bool enabled) OVERRIDE; |
| 112 const GURL& origin, | 115 virtual void PromoteDemotedChanges() OVERRIDE; |
| 113 ConflictResolutionPolicy policy); | |
| 114 ConflictResolutionPolicy GetDefaultConflictResolutionPolicy() | |
| 115 const; | |
| 116 ConflictResolutionPolicy GetConflictResolutionPolicy( | |
| 117 const GURL& origin) const; | |
| 118 | 116 |
| 119 void ApplyLocalChange( | 117 virtual void ApplyLocalChange( |
| 120 const FileChange& local_change, | 118 const FileChange& local_change, |
| 121 const base::FilePath& local_path, | 119 const base::FilePath& local_path, |
| 122 const SyncFileMetadata& local_metadata, | 120 const SyncFileMetadata& local_metadata, |
| 123 const fileapi::FileSystemURL& url, | 121 const fileapi::FileSystemURL& url, |
| 124 const SyncStatusCallback& callback); | 122 const SyncStatusCallback& callback) OVERRIDE; |
| 125 | 123 |
| 126 void OnNotificationReceived(); | 124 virtual void OnNotificationReceived() OVERRIDE; |
| 127 | 125 |
| 128 void OnReadyToSendRequests(const std::string& account_id); | 126 virtual void OnReadyToSendRequests(const std::string& account_id) OVERRIDE; |
| 129 void OnRefreshTokenInvalid(); | 127 virtual void OnRefreshTokenInvalid() OVERRIDE; |
| 130 | 128 |
| 131 void OnNetworkChanged(net::NetworkChangeNotifier::ConnectionType type); | 129 virtual void OnNetworkChanged( |
| 130 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; | |
| 132 | 131 |
| 133 drive::DriveServiceInterface* GetDriveService(); | 132 virtual drive::DriveServiceInterface* GetDriveService() OVERRIDE; |
| 134 drive::DriveUploaderInterface* GetDriveUploader(); | 133 virtual drive::DriveUploaderInterface* GetDriveUploader() OVERRIDE; |
| 135 MetadataDatabase* GetMetadataDatabase(); | 134 virtual MetadataDatabase* GetMetadataDatabase() OVERRIDE; |
| 136 SyncTaskManager* GetSyncTaskManager(); | 135 virtual SyncTaskManager* GetSyncTaskManager() OVERRIDE; |
| 136 | |
| 137 virtual void DetachFromSequence() OVERRIDE; | |
| 137 | 138 |
| 138 void AddObserver(Observer* observer); | 139 void AddObserver(Observer* observer); |
| 139 | 140 |
| 140 void DetachFromSequence(); | |
| 141 | |
| 142 private: | 141 private: |
| 143 friend class DriveBackendSyncTest; | 142 friend class DriveBackendSyncTest; |
| 144 friend class SyncWorkerTest; | 143 friend class SyncWorkerTest; |
| 145 | 144 |
| 145 // SyncWorkerInterface overrides. | |
| 146 // TODO(peria): Remove this interface after making FakeSyncWorker class. | |
| 147 virtual void SetHasRefreshToken(bool has_refresh_token) OVERRIDE; | |
| 148 | |
| 146 void DoDisableApp(const std::string& app_id, | 149 void DoDisableApp(const std::string& app_id, |
| 147 const SyncStatusCallback& callback); | 150 const SyncStatusCallback& callback); |
| 148 void DoEnableApp(const std::string& app_id, | 151 void DoEnableApp(const std::string& app_id, |
| 149 const SyncStatusCallback& callback); | 152 const SyncStatusCallback& callback); |
| 150 | 153 |
| 151 void PostInitializeTask(); | 154 void PostInitializeTask(); |
| 152 void DidInitialize(SyncEngineInitializer* initializer, | 155 void DidInitialize(SyncEngineInitializer* initializer, |
| 153 SyncStatusCode status); | 156 SyncStatusCode status); |
| 154 void UpdateRegisteredApps(); | 157 void UpdateRegisteredApps(); |
| 155 void DidQueryAppStatus(const AppStatusMap* app_status); | 158 void DidQueryAppStatus(const AppStatusMap* app_status); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 base::SequenceChecker sequence_checker_; | 200 base::SequenceChecker sequence_checker_; |
| 198 | 201 |
| 199 base::WeakPtrFactory<SyncWorker> weak_ptr_factory_; | 202 base::WeakPtrFactory<SyncWorker> weak_ptr_factory_; |
| 200 DISALLOW_COPY_AND_ASSIGN(SyncWorker); | 203 DISALLOW_COPY_AND_ASSIGN(SyncWorker); |
| 201 }; | 204 }; |
| 202 | 205 |
| 203 } // namespace drive_backend | 206 } // namespace drive_backend |
| 204 } // namespace sync_file_system | 207 } // namespace sync_file_system |
| 205 | 208 |
| 206 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_WORKER_H_ | 209 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_WORKER_H_ |
| OLD | NEW |