| 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 COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_CORE_H_ | 5 #ifndef COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_CORE_H_ |
| 6 #define COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_CORE_H_ | 6 #define COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_CORE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 class SyncBackendHostImpl; | 32 class SyncBackendHostImpl; |
| 33 | 33 |
| 34 class SyncBackendHostCore | 34 class SyncBackendHostCore |
| 35 : public base::RefCountedThreadSafe<SyncBackendHostCore>, | 35 : public base::RefCountedThreadSafe<SyncBackendHostCore>, |
| 36 public base::trace_event::MemoryDumpProvider, | 36 public base::trace_event::MemoryDumpProvider, |
| 37 public SyncEncryptionHandler::Observer, | 37 public SyncEncryptionHandler::Observer, |
| 38 public SyncManager::Observer, | 38 public SyncManager::Observer, |
| 39 public TypeDebugInfoObserver { | 39 public TypeDebugInfoObserver { |
| 40 public: | 40 public: |
| 41 SyncBackendHostCore(const std::string& name, | 41 SyncBackendHostCore(const std::string& name, |
| 42 const base::FilePath& sync_data_folder_path, | 42 const base::FilePath& sync_data_folder, |
| 43 const base::WeakPtr<SyncBackendHostImpl>& backend); | 43 const base::WeakPtr<SyncBackendHostImpl>& backend); |
| 44 | 44 |
| 45 // MemoryDumpProvider implementation. | 45 // MemoryDumpProvider implementation. |
| 46 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, | 46 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, |
| 47 base::trace_event::ProcessMemoryDump* pmd) override; | 47 base::trace_event::ProcessMemoryDump* pmd) override; |
| 48 | 48 |
| 49 // SyncManager::Observer implementation. The Core just acts like an air | 49 // SyncManager::Observer implementation. The Core just acts like an air |
| 50 // traffic controller here, forwarding incoming messages to appropriate | 50 // traffic controller here, forwarding incoming messages to appropriate |
| 51 // landing threads. | 51 // landing threads. |
| 52 void OnSyncCycleCompleted(const SyncCycleSnapshot& snapshot) override; | 52 void OnSyncCycleCompleted(const SyncCycleSnapshot& snapshot) override; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 void DisableProtocolEventForwarding(); | 166 void DisableProtocolEventForwarding(); |
| 167 | 167 |
| 168 // Enables the forwarding of directory type debug counters to the | 168 // Enables the forwarding of directory type debug counters to the |
| 169 // SyncEngineHost. Also requests that updates to all counters be emitted right | 169 // SyncEngineHost. Also requests that updates to all counters be emitted right |
| 170 // away to initialize any new listeners' states. | 170 // away to initialize any new listeners' states. |
| 171 void EnableDirectoryTypeDebugInfoForwarding(); | 171 void EnableDirectoryTypeDebugInfoForwarding(); |
| 172 | 172 |
| 173 // Disables forwarding of directory type debug counters. | 173 // Disables forwarding of directory type debug counters. |
| 174 void DisableDirectoryTypeDebugInfoForwarding(); | 174 void DisableDirectoryTypeDebugInfoForwarding(); |
| 175 | 175 |
| 176 // Delete the sync data folder to cleanup backend data. Happens the first | |
| 177 // time sync is enabled for a user (to prevent accidentally reusing old | |
| 178 // sync databases), as well as shutdown when you're no longer syncing. | |
| 179 void DeleteSyncDataFolder(); | |
| 180 | |
| 181 // Tell the sync manager to persist its state by writing to disk. | 176 // Tell the sync manager to persist its state by writing to disk. |
| 182 // Called on the sync thread, both by a timer and, on Android, when the | 177 // Called on the sync thread, both by a timer and, on Android, when the |
| 183 // application is backgrounded. | 178 // application is backgrounded. |
| 184 void SaveChanges(); | 179 void SaveChanges(); |
| 185 | 180 |
| 186 void DoClearServerData( | 181 void DoClearServerData( |
| 187 const SyncManager::ClearServerDataCallback& frontend_callback); | 182 const SyncManager::ClearServerDataCallback& frontend_callback); |
| 188 | 183 |
| 189 // Notify the syncer that the cookie jar has changed. | 184 // Notify the syncer that the cookie jar has changed. |
| 190 void DoOnCookieJarChanged(bool account_mismatch, bool empty_jar); | 185 void DoOnCookieJarChanged(bool account_mismatch, bool empty_jar); |
| 191 | 186 |
| 192 private: | 187 private: |
| 193 friend class base::RefCountedThreadSafe<SyncBackendHostCore>; | 188 friend class base::RefCountedThreadSafe<SyncBackendHostCore>; |
| 194 | 189 |
| 195 ~SyncBackendHostCore() override; | 190 ~SyncBackendHostCore() override; |
| 196 | 191 |
| 197 // Invoked when initialization of syncapi is complete and we can start | 192 // Invoked when initialization of syncapi is complete and we can start |
| 198 // our timer. | 193 // our timer. |
| 199 // This must be called from the thread on which SaveChanges is intended to | 194 // This must be called from the thread on which SaveChanges is intended to |
| 200 // be run on; the host's |registrar_->sync_thread()|. | 195 // be run on; the host's |registrar_->sync_thread()|. |
| 201 void StartSavingChanges(); | 196 void StartSavingChanges(); |
| 202 | 197 |
| 203 void ClearServerDataDone(const base::Closure& frontend_callback); | 198 void ClearServerDataDone(const base::Closure& frontend_callback); |
| 204 | 199 |
| 205 // Name used for debugging. | 200 // Name used for debugging. |
| 206 const std::string name_; | 201 const std::string name_; |
| 207 | 202 |
| 208 // Path of the folder that stores the sync data files. | 203 // Path of the folder that stores the sync data files. |
| 209 const base::FilePath sync_data_folder_path_; | 204 const base::FilePath sync_data_folder_; |
| 210 | 205 |
| 211 // Our parent SyncBackendHostImpl. | 206 // Our parent SyncBackendHostImpl. |
| 212 WeakHandle<SyncBackendHostImpl> host_; | 207 WeakHandle<SyncBackendHostImpl> host_; |
| 213 | 208 |
| 214 // Non-null only between calls to DoInitialize() and DoShutdown(). | 209 // Non-null only between calls to DoInitialize() and DoShutdown(). |
| 215 std::unique_ptr<SyncBackendRegistrar> registrar_; | 210 std::unique_ptr<SyncBackendRegistrar> registrar_; |
| 216 | 211 |
| 217 // The timer used to periodically call SaveChanges. | 212 // The timer used to periodically call SaveChanges. |
| 218 std::unique_ptr<base::RepeatingTimer> save_changes_timer_; | 213 std::unique_ptr<base::RepeatingTimer> save_changes_timer_; |
| 219 | 214 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 base::ThreadChecker thread_checker_; | 248 base::ThreadChecker thread_checker_; |
| 254 | 249 |
| 255 base::WeakPtrFactory<SyncBackendHostCore> weak_ptr_factory_; | 250 base::WeakPtrFactory<SyncBackendHostCore> weak_ptr_factory_; |
| 256 | 251 |
| 257 DISALLOW_COPY_AND_ASSIGN(SyncBackendHostCore); | 252 DISALLOW_COPY_AND_ASSIGN(SyncBackendHostCore); |
| 258 }; | 253 }; |
| 259 | 254 |
| 260 } // namespace syncer | 255 } // namespace syncer |
| 261 | 256 |
| 262 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_CORE_H_ | 257 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_HOST_CORE_H_ |
| OLD | NEW |