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

Side by Side Diff: components/sync_driver/glue/sync_backend_registrar.h

Issue 1907683003: Convert //components/sync_driver from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Build fix, address feedback Created 4 years, 8 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_REGISTRAR_H_ 5 #ifndef COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_REGISTRAR_H_
6 #define COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_REGISTRAR_H_ 6 #define COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_REGISTRAR_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <memory>
11 #include <string> 12 #include <string>
12 #include <vector> 13 #include <vector>
13 14
14 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
15 #include "base/macros.h" 16 #include "base/macros.h"
16 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
17 #include "base/memory/scoped_ptr.h"
18 #include "base/synchronization/lock.h" 18 #include "base/synchronization/lock.h"
19 #include "base/threading/thread.h" 19 #include "base/threading/thread.h"
20 #include "sync/internal_api/public/base/model_type.h" 20 #include "sync/internal_api/public/base/model_type.h"
21 #include "sync/internal_api/public/engine/model_safe_worker.h" 21 #include "sync/internal_api/public/engine/model_safe_worker.h"
22 #include "sync/internal_api/public/sync_manager.h" 22 #include "sync/internal_api/public/sync_manager.h"
23 23
24 class Profile; 24 class Profile;
25 25
26 namespace base { 26 namespace base {
27 class MessageLoop; 27 class MessageLoop;
(...skipping 16 matching lines...) Expand all
44 // routing info for the enabled sync types, and also routes change 44 // routing info for the enabled sync types, and also routes change
45 // events to the right processors. 45 // events to the right processors.
46 class SyncBackendRegistrar : public syncer::SyncManager::ChangeDelegate, 46 class SyncBackendRegistrar : public syncer::SyncManager::ChangeDelegate,
47 public syncer::WorkerLoopDestructionObserver { 47 public syncer::WorkerLoopDestructionObserver {
48 public: 48 public:
49 // |name| is used for debugging. Does not take ownership of |profile|. 49 // |name| is used for debugging. Does not take ownership of |profile|.
50 // Must be created on the UI thread. 50 // Must be created on the UI thread.
51 SyncBackendRegistrar( 51 SyncBackendRegistrar(
52 const std::string& name, 52 const std::string& name,
53 sync_driver::SyncClient* sync_client, 53 sync_driver::SyncClient* sync_client,
54 scoped_ptr<base::Thread> sync_thread, 54 std::unique_ptr<base::Thread> sync_thread,
55 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread, 55 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread,
56 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread, 56 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread,
57 const scoped_refptr<base::SingleThreadTaskRunner>& file_thread); 57 const scoped_refptr<base::SingleThreadTaskRunner>& file_thread);
58 58
59 // SyncBackendRegistrar must be destroyed as follows: 59 // SyncBackendRegistrar must be destroyed as follows:
60 // 60 //
61 // 1) On the UI thread, call RequestWorkerStopOnUIThread(). 61 // 1) On the UI thread, call RequestWorkerStopOnUIThread().
62 // 2) UI posts task to shut down syncer on sync thread. 62 // 2) UI posts task to shut down syncer on sync thread.
63 // 3) If sync is disabled, call ReleaseSyncThread() on the UI thread. 63 // 3) If sync is disabled, call ReleaseSyncThread() on the UI thread.
64 // 3) UI posts SyncBackendRegistrar::ShutDown() on sync thread to 64 // 3) UI posts SyncBackendRegistrar::ShutDown() on sync thread to
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 const syncer::ImmutableChangeRecordList& changes) override; 126 const syncer::ImmutableChangeRecordList& changes) override;
127 void OnChangesComplete(syncer::ModelType model_type) override; 127 void OnChangesComplete(syncer::ModelType model_type) override;
128 128
129 void GetWorkers(std::vector<scoped_refptr<syncer::ModelSafeWorker>>* out); 129 void GetWorkers(std::vector<scoped_refptr<syncer::ModelSafeWorker>>* out);
130 void GetModelSafeRoutingInfo(syncer::ModelSafeRoutingInfo* out); 130 void GetModelSafeRoutingInfo(syncer::ModelSafeRoutingInfo* out);
131 131
132 // syncer::WorkerLoopDestructionObserver implementation. 132 // syncer::WorkerLoopDestructionObserver implementation.
133 void OnWorkerLoopDestroyed(syncer::ModelSafeGroup group) override; 133 void OnWorkerLoopDestroyed(syncer::ModelSafeGroup group) override;
134 134
135 // Release ownership of |sync_thread_|. Called when sync is disabled. 135 // Release ownership of |sync_thread_|. Called when sync is disabled.
136 scoped_ptr<base::Thread> ReleaseSyncThread(); 136 std::unique_ptr<base::Thread> ReleaseSyncThread();
137 137
138 // Unregister workers from loop destruction observation. 138 // Unregister workers from loop destruction observation.
139 void Shutdown(); 139 void Shutdown();
140 140
141 base::Thread* sync_thread(); 141 base::Thread* sync_thread();
142 142
143 private: 143 private:
144 typedef std::map<syncer::ModelSafeGroup, 144 typedef std::map<syncer::ModelSafeGroup,
145 scoped_refptr<syncer::ModelSafeWorker>> WorkerMap; 145 scoped_refptr<syncer::ModelSafeWorker>> WorkerMap;
146 typedef std::map<syncer::ModelType, sync_driver::ChangeProcessor*> 146 typedef std::map<syncer::ModelType, sync_driver::ChangeProcessor*>
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 213
214 // References to the thread task runners that sync depends on. 214 // References to the thread task runners that sync depends on.
215 const scoped_refptr<base::SingleThreadTaskRunner> ui_thread_; 215 const scoped_refptr<base::SingleThreadTaskRunner> ui_thread_;
216 const scoped_refptr<base::SingleThreadTaskRunner> db_thread_; 216 const scoped_refptr<base::SingleThreadTaskRunner> db_thread_;
217 const scoped_refptr<base::SingleThreadTaskRunner> file_thread_; 217 const scoped_refptr<base::SingleThreadTaskRunner> file_thread_;
218 218
219 // Declare |sync_thread_| at the end so that it will be destroyed before 219 // Declare |sync_thread_| at the end so that it will be destroyed before
220 // objects above because tasks on sync thread depend on those objects, 220 // objects above because tasks on sync thread depend on those objects,
221 // e.g. Shutdown() depends on |lock_|, SyncManager::Init() depends on 221 // e.g. Shutdown() depends on |lock_|, SyncManager::Init() depends on
222 // workers, etc. 222 // workers, etc.
223 scoped_ptr<base::Thread> sync_thread_; 223 std::unique_ptr<base::Thread> sync_thread_;
224 224
225 // Set of types with non-blocking implementation (as opposed to directory 225 // Set of types with non-blocking implementation (as opposed to directory
226 // based). 226 // based).
227 syncer::ModelTypeSet non_blocking_types_; 227 syncer::ModelTypeSet non_blocking_types_;
228 228
229 DISALLOW_COPY_AND_ASSIGN(SyncBackendRegistrar); 229 DISALLOW_COPY_AND_ASSIGN(SyncBackendRegistrar);
230 }; 230 };
231 231
232 } // namespace browser_sync 232 } // namespace browser_sync
233 233
234 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_REGISTRAR_H_ 234 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_REGISTRAR_H_
OLDNEW
« no previous file with comments | « components/sync_driver/glue/sync_backend_host_mock.cc ('k') | components/sync_driver/glue/sync_backend_registrar.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698