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

Side by Side Diff: chrome/browser/sync_file_system/drive_backend/sync_worker.h

Issue 318353002: [SyncFS] Create SyncWorkerInterface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix build errors Created 6 years, 6 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 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"
18 #include "chrome/browser/sync_file_system/sync_callbacks.h"
20 #include "chrome/browser/sync_file_system/sync_direction.h" 19 #include "chrome/browser/sync_file_system/sync_direction.h"
21 #include "chrome/browser/sync_file_system/task_logger.h" 20 #include "chrome/browser/sync_file_system/task_logger.h"
22 #include "net/base/network_change_notifier.h" 21 #include "net/base/network_change_notifier.h"
23 22
24 class ExtensionServiceInterface; 23 class ExtensionServiceInterface;
24 class GURL;
25 25
26 namespace base { 26 namespace base {
27 class SequencedTaskRunner; 27 class ListValue;
28 } 28 }
29 29
30 namespace drive { 30 namespace drive {
31 class DriveServiceInterface; 31 class DriveServiceInterface;
32 class DriveNotificationManager;
33 class DriveUploaderInterface; 32 class DriveUploaderInterface;
34 } 33 }
35 34
35 namespace fileapi {
36 class FileSystemURL;
37 }
38
36 namespace leveldb { 39 namespace leveldb {
37 class Env; 40 class Env;
38 } 41 }
39 42
40 namespace sync_file_system { 43 namespace sync_file_system {
41 44
42 class RemoteChangeProcessor; 45 class FileChange;
46 class SyncFileMetadata;
43 47
44 namespace drive_backend { 48 namespace drive_backend {
45 49
46 class LocalToRemoteSyncer; 50 class LocalToRemoteSyncer;
47 class MetadataDatabase; 51 class MetadataDatabase;
48 class RemoteChangeProcessorOnWorker; 52 class RemoteChangeProcessorOnWorker;
49 class RemoteToLocalSyncer; 53 class RemoteToLocalSyncer;
50 class SyncEngineContext; 54 class SyncEngineContext;
51 class SyncEngineInitializer; 55 class SyncEngineInitializer;
52 56
53 class SyncWorker : public SyncTaskManager::Client { 57 class SyncWorker : public SyncWorkerInterface,
58 public SyncTaskManager::Client {
54 public: 59 public:
55 enum AppStatus { 60 enum AppStatus {
56 APP_STATUS_ENABLED, 61 APP_STATUS_ENABLED,
57 APP_STATUS_DISABLED, 62 APP_STATUS_DISABLED,
58 APP_STATUS_UNINSTALLED, 63 APP_STATUS_UNINSTALLED,
59 }; 64 };
60 65
61 typedef base::hash_map<std::string, AppStatus> AppStatusMap; 66 typedef base::hash_map<std::string, AppStatus> AppStatusMap;
62 67
63 class Observer { 68 class Observer {
(...skipping 10 matching lines...) Expand all
74 virtual ~Observer() {} 79 virtual ~Observer() {}
75 }; 80 };
76 81
77 SyncWorker(const base::FilePath& base_dir, 82 SyncWorker(const base::FilePath& base_dir,
78 const base::WeakPtr<ExtensionServiceInterface>& extension_service, 83 const base::WeakPtr<ExtensionServiceInterface>& extension_service,
79 scoped_ptr<SyncEngineContext> sync_engine_context, 84 scoped_ptr<SyncEngineContext> sync_engine_context,
80 leveldb::Env* env_override); 85 leveldb::Env* env_override);
81 86
82 virtual ~SyncWorker(); 87 virtual ~SyncWorker();
83 88
84 void Initialize(); 89 virtual void Initialize() OVERRIDE;
85 90
86 // SyncTaskManager::Client overrides 91 // SyncTaskManager::Client overrides
87 virtual void MaybeScheduleNextTask() OVERRIDE; 92 virtual void MaybeScheduleNextTask() OVERRIDE;
88 virtual void NotifyLastOperationStatus( 93 virtual void NotifyLastOperationStatus(
89 SyncStatusCode sync_status, bool used_network) OVERRIDE; 94 SyncStatusCode sync_status, bool used_network) OVERRIDE;
90 virtual void RecordTaskLog(scoped_ptr<TaskLogger::TaskLog> task_log) OVERRIDE; 95 virtual void RecordTaskLog(scoped_ptr<TaskLogger::TaskLog> task_log) OVERRIDE;
91 96
92 void RegisterOrigin(const GURL& origin, const SyncStatusCallback& callback); 97 // SyncWorkerInterface overrides
93 void EnableOrigin(const GURL& origin, const SyncStatusCallback& callback); 98 virtual void RegisterOrigin(const GURL& origin,
94 void DisableOrigin(const GURL& origin, const SyncStatusCallback& callback); 99 const SyncStatusCallback& callback) OVERRIDE;
95 void UninstallOrigin( 100 virtual void EnableOrigin(const GURL& origin,
96 const GURL& origin, 101 const SyncStatusCallback& callback) OVERRIDE;
97 RemoteFileSyncService::UninstallFlag flag, 102 virtual void DisableOrigin(const GURL& origin,
98 const SyncStatusCallback& callback); 103 const SyncStatusCallback& callback) OVERRIDE;
99 void ProcessRemoteChange(const SyncFileCallback& callback); 104 virtual void UninstallOrigin(const GURL& origin,
100 void SetRemoteChangeProcessor( 105 RemoteFileSyncService::UninstallFlag flag,
101 RemoteChangeProcessorOnWorker* remote_change_processor_on_worker); 106 const SyncStatusCallback& callback) OVERRIDE;
102 RemoteServiceState GetCurrentState() const; 107 virtual void ProcessRemoteChange(const SyncFileCallback& callback) OVERRIDE;
103 void GetOriginStatusMap( 108 virtual void SetRemoteChangeProcessor(
104 const RemoteFileSyncService::StatusMapCallback& callback); 109 RemoteChangeProcessorOnWorker* remote_change_processor_on_worker)
105 scoped_ptr<base::ListValue> DumpFiles(const GURL& origin); 110 OVERRIDE;
106 scoped_ptr<base::ListValue> DumpDatabase(); 111 virtual RemoteServiceState GetCurrentState() const OVERRIDE;
107 void SetSyncEnabled(bool enabled); 112 virtual void GetOriginStatusMap(
108 void PromoteDemotedChanges(); 113 const RemoteFileSyncService::StatusMapCallback& callback) OVERRIDE;
109 SyncStatusCode SetDefaultConflictResolutionPolicy( 114 virtual scoped_ptr<base::ListValue> DumpFiles(const GURL& origin) OVERRIDE;
110 ConflictResolutionPolicy policy); 115 virtual scoped_ptr<base::ListValue> DumpDatabase() OVERRIDE;
111 SyncStatusCode SetConflictResolutionPolicy( 116 virtual void SetSyncEnabled(bool enabled) OVERRIDE;
112 const GURL& origin, 117 virtual void PromoteDemotedChanges() OVERRIDE;
113 ConflictResolutionPolicy policy);
114 ConflictResolutionPolicy GetDefaultConflictResolutionPolicy()
115 const;
116 ConflictResolutionPolicy GetConflictResolutionPolicy(
117 const GURL& origin) const;
118 118
119 void ApplyLocalChange( 119 virtual void ApplyLocalChange(
120 const FileChange& local_change, 120 const FileChange& local_change,
121 const base::FilePath& local_path, 121 const base::FilePath& local_path,
122 const SyncFileMetadata& local_metadata, 122 const SyncFileMetadata& local_metadata,
123 const fileapi::FileSystemURL& url, 123 const fileapi::FileSystemURL& url,
124 const SyncStatusCallback& callback); 124 const SyncStatusCallback& callback) OVERRIDE;
125 125
126 void OnNotificationReceived(); 126 virtual void OnNotificationReceived() OVERRIDE;
127 127
128 void OnReadyToSendRequests(const std::string& account_id); 128 virtual void OnReadyToSendRequests(const std::string& account_id) OVERRIDE;
129 void OnRefreshTokenInvalid(); 129 virtual void OnRefreshTokenInvalid() OVERRIDE;
130 130
131 void OnNetworkChanged(net::NetworkChangeNotifier::ConnectionType type); 131 virtual void OnNetworkChanged(
132 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE;
132 133
133 drive::DriveServiceInterface* GetDriveService(); 134 virtual drive::DriveServiceInterface* GetDriveService() OVERRIDE;
134 drive::DriveUploaderInterface* GetDriveUploader(); 135 virtual drive::DriveUploaderInterface* GetDriveUploader() OVERRIDE;
135 MetadataDatabase* GetMetadataDatabase(); 136 virtual MetadataDatabase* GetMetadataDatabase() OVERRIDE;
136 SyncTaskManager* GetSyncTaskManager(); 137 virtual SyncTaskManager* GetSyncTaskManager() OVERRIDE;
138
139 virtual void DetachFromSequence() OVERRIDE;
137 140
138 void AddObserver(Observer* observer); 141 void AddObserver(Observer* observer);
139 142
140 void DetachFromSequence();
141
142 private: 143 private:
143 friend class DriveBackendSyncTest; 144 friend class DriveBackendSyncTest;
144 friend class SyncWorkerTest; 145 friend class SyncWorkerTest;
145 146
147 // SyncWorkerInterface overrides.
148 // TODO(peria): Remove this interface after making FakeSyncWorker class.
149 virtual void SetHasRefreshToken(bool has_refresh_token) OVERRIDE;
150
146 void DoDisableApp(const std::string& app_id, 151 void DoDisableApp(const std::string& app_id,
147 const SyncStatusCallback& callback); 152 const SyncStatusCallback& callback);
148 void DoEnableApp(const std::string& app_id, 153 void DoEnableApp(const std::string& app_id,
149 const SyncStatusCallback& callback); 154 const SyncStatusCallback& callback);
150 155
151 void PostInitializeTask(); 156 void PostInitializeTask();
152 void DidInitialize(SyncEngineInitializer* initializer, 157 void DidInitialize(SyncEngineInitializer* initializer,
153 SyncStatusCode status); 158 SyncStatusCode status);
154 void UpdateRegisteredApps(); 159 void UpdateRegisteredApps();
155 void DidQueryAppStatus(const AppStatusMap* app_status); 160 void DidQueryAppStatus(const AppStatusMap* app_status);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 base::SequenceChecker sequence_checker_; 202 base::SequenceChecker sequence_checker_;
198 203
199 base::WeakPtrFactory<SyncWorker> weak_ptr_factory_; 204 base::WeakPtrFactory<SyncWorker> weak_ptr_factory_;
200 DISALLOW_COPY_AND_ASSIGN(SyncWorker); 205 DISALLOW_COPY_AND_ASSIGN(SyncWorker);
201 }; 206 };
202 207
203 } // namespace drive_backend 208 } // namespace drive_backend
204 } // namespace sync_file_system 209 } // namespace sync_file_system
205 210
206 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_WORKER_H_ 211 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_SYNC_WORKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698