| OLD | NEW |
| 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_SYNC_FILE_SYSTEM_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_FILE_SYSTEM_SERVICE_H_ |
| 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_FILE_SYSTEM_SERVICE_H_ | 6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_FILE_SYSTEM_SERVICE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 public ProfileSyncServiceObserver, | 47 public ProfileSyncServiceObserver, |
| 48 public FileStatusObserver, | 48 public FileStatusObserver, |
| 49 public extensions::ExtensionRegistryObserver, | 49 public extensions::ExtensionRegistryObserver, |
| 50 public base::SupportsWeakPtr<SyncFileSystemService> { | 50 public base::SupportsWeakPtr<SyncFileSystemService> { |
| 51 public: | 51 public: |
| 52 typedef base::Callback<void(const base::ListValue&)> DumpFilesCallback; | 52 typedef base::Callback<void(const base::ListValue&)> DumpFilesCallback; |
| 53 typedef base::Callback<void(const RemoteFileSyncService::OriginStatusMap&)> | 53 typedef base::Callback<void(const RemoteFileSyncService::OriginStatusMap&)> |
| 54 ExtensionStatusMapCallback; | 54 ExtensionStatusMapCallback; |
| 55 | 55 |
| 56 // KeyedService implementation. | 56 // KeyedService implementation. |
| 57 virtual void Shutdown() override; | 57 void Shutdown() override; |
| 58 | 58 |
| 59 void InitializeForApp(storage::FileSystemContext* file_system_context, | 59 void InitializeForApp(storage::FileSystemContext* file_system_context, |
| 60 const GURL& app_origin, | 60 const GURL& app_origin, |
| 61 const SyncStatusCallback& callback); | 61 const SyncStatusCallback& callback); |
| 62 | 62 |
| 63 void GetExtensionStatusMap(const ExtensionStatusMapCallback& callback); | 63 void GetExtensionStatusMap(const ExtensionStatusMapCallback& callback); |
| 64 void DumpFiles(const GURL& origin, const DumpFilesCallback& callback); | 64 void DumpFiles(const GURL& origin, const DumpFilesCallback& callback); |
| 65 void DumpDatabase(const DumpFilesCallback& callback); | 65 void DumpDatabase(const DumpFilesCallback& callback); |
| 66 | 66 |
| 67 // Returns the file |url|'s sync status. | 67 // Returns the file |url|'s sync status. |
| 68 void GetFileSyncStatus(const storage::FileSystemURL& url, | 68 void GetFileSyncStatus(const storage::FileSystemURL& url, |
| 69 const SyncFileStatusCallback& callback); | 69 const SyncFileStatusCallback& callback); |
| 70 | 70 |
| 71 void AddSyncEventObserver(SyncEventObserver* observer); | 71 void AddSyncEventObserver(SyncEventObserver* observer); |
| 72 void RemoveSyncEventObserver(SyncEventObserver* observer); | 72 void RemoveSyncEventObserver(SyncEventObserver* observer); |
| 73 | 73 |
| 74 LocalChangeProcessor* GetLocalChangeProcessor(const GURL& origin); | 74 LocalChangeProcessor* GetLocalChangeProcessor(const GURL& origin); |
| 75 | 75 |
| 76 // SyncProcessRunner::Client implementations. | 76 // SyncProcessRunner::Client implementations. |
| 77 virtual void OnSyncIdle() override; | 77 void OnSyncIdle() override; |
| 78 virtual SyncServiceState GetSyncServiceState() override; | 78 SyncServiceState GetSyncServiceState() override; |
| 79 virtual SyncFileSystemService* GetSyncService() override; | 79 SyncFileSystemService* GetSyncService() override; |
| 80 | 80 |
| 81 void OnPromotionCompleted(int* num_running_jobs); | 81 void OnPromotionCompleted(int* num_running_jobs); |
| 82 void CheckIfIdle(); | 82 void CheckIfIdle(); |
| 83 | 83 |
| 84 TaskLogger* task_logger() { return &task_logger_; } | 84 TaskLogger* task_logger() { return &task_logger_; } |
| 85 | 85 |
| 86 void CallOnIdleForTesting(const base::Closure& callback); | 86 void CallOnIdleForTesting(const base::Closure& callback); |
| 87 | 87 |
| 88 private: | 88 private: |
| 89 friend class SyncFileSystemServiceFactory; | 89 friend class SyncFileSystemServiceFactory; |
| 90 friend class SyncFileSystemServiceTest; | 90 friend class SyncFileSystemServiceTest; |
| 91 friend class SyncFileSystemTest; | 91 friend class SyncFileSystemTest; |
| 92 friend struct base::DefaultDeleter<SyncFileSystemService>; | 92 friend struct base::DefaultDeleter<SyncFileSystemService>; |
| 93 friend class LocalSyncRunner; | 93 friend class LocalSyncRunner; |
| 94 friend class RemoteSyncRunner; | 94 friend class RemoteSyncRunner; |
| 95 | 95 |
| 96 explicit SyncFileSystemService(Profile* profile); | 96 explicit SyncFileSystemService(Profile* profile); |
| 97 virtual ~SyncFileSystemService(); | 97 ~SyncFileSystemService() override; |
| 98 | 98 |
| 99 void Initialize(scoped_ptr<LocalFileSyncService> local_file_service, | 99 void Initialize(scoped_ptr<LocalFileSyncService> local_file_service, |
| 100 scoped_ptr<RemoteFileSyncService> remote_file_service); | 100 scoped_ptr<RemoteFileSyncService> remote_file_service); |
| 101 | 101 |
| 102 // Callbacks for InitializeForApp. | 102 // Callbacks for InitializeForApp. |
| 103 void DidInitializeFileSystem(const GURL& app_origin, | 103 void DidInitializeFileSystem(const GURL& app_origin, |
| 104 const SyncStatusCallback& callback, | 104 const SyncStatusCallback& callback, |
| 105 SyncStatusCode status); | 105 SyncStatusCode status); |
| 106 void DidRegisterOrigin(const GURL& app_origin, | 106 void DidRegisterOrigin(const GURL& app_origin, |
| 107 const SyncStatusCallback& callback, | 107 const SyncStatusCallback& callback, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 125 void SetSyncEnabledForTesting(bool enabled); | 125 void SetSyncEnabledForTesting(bool enabled); |
| 126 | 126 |
| 127 void DidGetLocalChangeStatus(const SyncFileStatusCallback& callback, | 127 void DidGetLocalChangeStatus(const SyncFileStatusCallback& callback, |
| 128 SyncStatusCode status, | 128 SyncStatusCode status, |
| 129 bool has_pending_local_changes); | 129 bool has_pending_local_changes); |
| 130 | 130 |
| 131 void OnRemoteServiceStateUpdated(RemoteServiceState state, | 131 void OnRemoteServiceStateUpdated(RemoteServiceState state, |
| 132 const std::string& description); | 132 const std::string& description); |
| 133 | 133 |
| 134 // extensions::ExtensionRegistryObserver implementations. | 134 // extensions::ExtensionRegistryObserver implementations. |
| 135 virtual void OnExtensionInstalled( | 135 void OnExtensionInstalled(content::BrowserContext* browser_context, |
| 136 content::BrowserContext* browser_context, | 136 const extensions::Extension* extension, |
| 137 const extensions::Extension* extension, | 137 bool is_update) override; |
| 138 bool is_update) override; | 138 void OnExtensionUnloaded( |
| 139 virtual void OnExtensionUnloaded( | |
| 140 content::BrowserContext* browser_context, | 139 content::BrowserContext* browser_context, |
| 141 const extensions::Extension* extension, | 140 const extensions::Extension* extension, |
| 142 extensions::UnloadedExtensionInfo::Reason reason) override; | 141 extensions::UnloadedExtensionInfo::Reason reason) override; |
| 143 virtual void OnExtensionUninstalled( | 142 void OnExtensionUninstalled(content::BrowserContext* browser_context, |
| 144 content::BrowserContext* browser_context, | 143 const extensions::Extension* extension, |
| 145 const extensions::Extension* extension, | 144 extensions::UninstallReason reason) override; |
| 146 extensions::UninstallReason reason) override; | 145 void OnExtensionLoaded(content::BrowserContext* browser_context, |
| 147 virtual void OnExtensionLoaded( | 146 const extensions::Extension* extension) override; |
| 148 content::BrowserContext* browser_context, | |
| 149 const extensions::Extension* extension) override; | |
| 150 | 147 |
| 151 // ProfileSyncServiceObserver implementation. | 148 // ProfileSyncServiceObserver implementation. |
| 152 virtual void OnStateChanged() override; | 149 void OnStateChanged() override; |
| 153 | 150 |
| 154 // SyncFileStatusObserver implementation. | 151 // SyncFileStatusObserver implementation. |
| 155 virtual void OnFileStatusChanged(const storage::FileSystemURL& url, | 152 void OnFileStatusChanged(const storage::FileSystemURL& url, |
| 156 SyncFileType file_type, | 153 SyncFileType file_type, |
| 157 SyncFileStatus sync_status, | 154 SyncFileStatus sync_status, |
| 158 SyncAction action_taken, | 155 SyncAction action_taken, |
| 159 SyncDirection direction) override; | 156 SyncDirection direction) override; |
| 160 | 157 |
| 161 // Check the profile's sync preference settings and call | 158 // Check the profile's sync preference settings and call |
| 162 // remote_file_service_->SetSyncEnabled() to update the status. | 159 // remote_file_service_->SetSyncEnabled() to update the status. |
| 163 // |profile_sync_service| must be non-null. | 160 // |profile_sync_service| must be non-null. |
| 164 void UpdateSyncEnabledStatus(ProfileSyncServiceBase* profile_sync_service); | 161 void UpdateSyncEnabledStatus(ProfileSyncServiceBase* profile_sync_service); |
| 165 | 162 |
| 166 // Runs the SyncProcessRunner method of all sync runners (e.g. for Local sync | 163 // Runs the SyncProcessRunner method of all sync runners (e.g. for Local sync |
| 167 // and Remote sync). | 164 // and Remote sync). |
| 168 void RunForEachSyncRunners(void(SyncProcessRunner::*method)()); | 165 void RunForEachSyncRunners(void(SyncProcessRunner::*method)()); |
| 169 | 166 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 188 | 185 |
| 189 bool promoting_demoted_changes_; | 186 bool promoting_demoted_changes_; |
| 190 base::Closure idle_callback_; | 187 base::Closure idle_callback_; |
| 191 | 188 |
| 192 DISALLOW_COPY_AND_ASSIGN(SyncFileSystemService); | 189 DISALLOW_COPY_AND_ASSIGN(SyncFileSystemService); |
| 193 }; | 190 }; |
| 194 | 191 |
| 195 } // namespace sync_file_system | 192 } // namespace sync_file_system |
| 196 | 193 |
| 197 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_FILE_SYSTEM_SERVICE_H_ | 194 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_FILE_SYSTEM_SERVICE_H_ |
| OLD | NEW |