| 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 <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/scoped_ptr.h" | |
| 15 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
| 16 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 17 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
| 18 #include "chrome/browser/sync_file_system/conflict_resolution_policy.h" | 17 #include "chrome/browser/sync_file_system/conflict_resolution_policy.h" |
| 19 #include "chrome/browser/sync_file_system/file_status_observer.h" | 18 #include "chrome/browser/sync_file_system/file_status_observer.h" |
| 20 #include "chrome/browser/sync_file_system/remote_file_sync_service.h" | 19 #include "chrome/browser/sync_file_system/remote_file_sync_service.h" |
| 21 #include "chrome/browser/sync_file_system/sync_callbacks.h" | 20 #include "chrome/browser/sync_file_system/sync_callbacks.h" |
| 22 #include "chrome/browser/sync_file_system/sync_process_runner.h" | 21 #include "chrome/browser/sync_file_system/sync_process_runner.h" |
| 23 #include "chrome/browser/sync_file_system/sync_service_state.h" | 22 #include "chrome/browser/sync_file_system/sync_service_state.h" |
| 24 #include "chrome/browser/sync_file_system/task_logger.h" | 23 #include "chrome/browser/sync_file_system/task_logger.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 friend class SyncFileSystemServiceFactory; | 91 friend class SyncFileSystemServiceFactory; |
| 93 friend class SyncFileSystemServiceTest; | 92 friend class SyncFileSystemServiceTest; |
| 94 friend class SyncFileSystemTest; | 93 friend class SyncFileSystemTest; |
| 95 friend std::default_delete<SyncFileSystemService>; | 94 friend std::default_delete<SyncFileSystemService>; |
| 96 friend class LocalSyncRunner; | 95 friend class LocalSyncRunner; |
| 97 friend class RemoteSyncRunner; | 96 friend class RemoteSyncRunner; |
| 98 | 97 |
| 99 explicit SyncFileSystemService(Profile* profile); | 98 explicit SyncFileSystemService(Profile* profile); |
| 100 ~SyncFileSystemService() override; | 99 ~SyncFileSystemService() override; |
| 101 | 100 |
| 102 void Initialize(scoped_ptr<LocalFileSyncService> local_file_service, | 101 void Initialize(std::unique_ptr<LocalFileSyncService> local_file_service, |
| 103 scoped_ptr<RemoteFileSyncService> remote_file_service); | 102 std::unique_ptr<RemoteFileSyncService> remote_file_service); |
| 104 | 103 |
| 105 // Callbacks for InitializeForApp. | 104 // Callbacks for InitializeForApp. |
| 106 void DidInitializeFileSystem(const GURL& app_origin, | 105 void DidInitializeFileSystem(const GURL& app_origin, |
| 107 const SyncStatusCallback& callback, | 106 const SyncStatusCallback& callback, |
| 108 SyncStatusCode status); | 107 SyncStatusCode status); |
| 109 void DidRegisterOrigin(const GURL& app_origin, | 108 void DidRegisterOrigin(const GURL& app_origin, |
| 110 const SyncStatusCallback& callback, | 109 const SyncStatusCallback& callback, |
| 111 SyncStatusCode status); | 110 SyncStatusCode status); |
| 112 | 111 |
| 113 void DidInitializeFileSystemForDump(const GURL& app_origin, | 112 void DidInitializeFileSystemForDump(const GURL& app_origin, |
| 114 const DumpFilesCallback& callback, | 113 const DumpFilesCallback& callback, |
| 115 SyncStatusCode status); | 114 SyncStatusCode status); |
| 116 void DidDumpFiles(const GURL& app_origin, | 115 void DidDumpFiles(const GURL& app_origin, |
| 117 const DumpFilesCallback& callback, | 116 const DumpFilesCallback& callback, |
| 118 scoped_ptr<base::ListValue> files); | 117 std::unique_ptr<base::ListValue> files); |
| 119 | 118 |
| 120 void DidDumpDatabase(const DumpFilesCallback& callback, | 119 void DidDumpDatabase(const DumpFilesCallback& callback, |
| 121 scoped_ptr<base::ListValue> list); | 120 std::unique_ptr<base::ListValue> list); |
| 122 | 121 |
| 123 void DidGetExtensionStatusMap( | 122 void DidGetExtensionStatusMap( |
| 124 const ExtensionStatusMapCallback& callback, | 123 const ExtensionStatusMapCallback& callback, |
| 125 scoped_ptr<RemoteFileSyncService::OriginStatusMap> status_map); | 124 std::unique_ptr<RemoteFileSyncService::OriginStatusMap> status_map); |
| 126 | 125 |
| 127 // Overrides sync_enabled_ setting. This should be called only by tests. | 126 // Overrides sync_enabled_ setting. This should be called only by tests. |
| 128 void SetSyncEnabledForTesting(bool enabled); | 127 void SetSyncEnabledForTesting(bool enabled); |
| 129 | 128 |
| 130 void DidGetLocalChangeStatus(const SyncFileStatusCallback& callback, | 129 void DidGetLocalChangeStatus(const SyncFileStatusCallback& callback, |
| 131 SyncStatusCode status, | 130 SyncStatusCode status, |
| 132 bool has_pending_local_changes); | 131 bool has_pending_local_changes); |
| 133 | 132 |
| 134 void OnRemoteServiceStateUpdated(RemoteServiceState state, | 133 void OnRemoteServiceStateUpdated(RemoteServiceState state, |
| 135 const std::string& description); | 134 const std::string& description); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 162 // remote_file_service_->SetSyncEnabled() to update the status. | 161 // remote_file_service_->SetSyncEnabled() to update the status. |
| 163 // |profile_sync_service| must be non-null. | 162 // |profile_sync_service| must be non-null. |
| 164 void UpdateSyncEnabledStatus(sync_driver::SyncService* profile_sync_service); | 163 void UpdateSyncEnabledStatus(sync_driver::SyncService* profile_sync_service); |
| 165 | 164 |
| 166 // Runs the SyncProcessRunner method of all sync runners (e.g. for Local sync | 165 // Runs the SyncProcessRunner method of all sync runners (e.g. for Local sync |
| 167 // and Remote sync). | 166 // and Remote sync). |
| 168 void RunForEachSyncRunners(void(SyncProcessRunner::*method)()); | 167 void RunForEachSyncRunners(void(SyncProcessRunner::*method)()); |
| 169 | 168 |
| 170 Profile* profile_; | 169 Profile* profile_; |
| 171 | 170 |
| 172 scoped_ptr<LocalFileSyncService> local_service_; | 171 std::unique_ptr<LocalFileSyncService> local_service_; |
| 173 scoped_ptr<RemoteFileSyncService> remote_service_; | 172 std::unique_ptr<RemoteFileSyncService> remote_service_; |
| 174 | 173 |
| 175 // Holds all SyncProcessRunners. | 174 // Holds all SyncProcessRunners. |
| 176 ScopedVector<SyncProcessRunner> local_sync_runners_; | 175 ScopedVector<SyncProcessRunner> local_sync_runners_; |
| 177 ScopedVector<SyncProcessRunner> remote_sync_runners_; | 176 ScopedVector<SyncProcessRunner> remote_sync_runners_; |
| 178 | 177 |
| 179 // Indicates if sync is currently enabled or not. | 178 // Indicates if sync is currently enabled or not. |
| 180 bool sync_enabled_; | 179 bool sync_enabled_; |
| 181 | 180 |
| 182 TaskLogger task_logger_; | 181 TaskLogger task_logger_; |
| 183 base::ObserverList<SyncEventObserver> observers_; | 182 base::ObserverList<SyncEventObserver> observers_; |
| 184 | 183 |
| 185 bool promoting_demoted_changes_; | 184 bool promoting_demoted_changes_; |
| 186 base::Closure idle_callback_; | 185 base::Closure idle_callback_; |
| 187 | 186 |
| 188 DISALLOW_COPY_AND_ASSIGN(SyncFileSystemService); | 187 DISALLOW_COPY_AND_ASSIGN(SyncFileSystemService); |
| 189 }; | 188 }; |
| 190 | 189 |
| 191 } // namespace sync_file_system | 190 } // namespace sync_file_system |
| 192 | 191 |
| 193 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_FILE_SYSTEM_SERVICE_H_ | 192 #endif // CHROME_BROWSER_SYNC_FILE_SYSTEM_SYNC_FILE_SYSTEM_SERVICE_H_ |
| OLD | NEW |