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

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

Issue 1848793006: [Sync] Register USS types with ModelTypeRegistry before download (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 <string>
11 #include <vector> 12 #include <vector>
12 13
13 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
16 #include "base/synchronization/lock.h" 17 #include "base/synchronization/lock.h"
17 #include "base/threading/thread.h" 18 #include "base/threading/thread.h"
18 #include "sync/internal_api/public/base/model_type.h" 19 #include "sync/internal_api/public/base/model_type.h"
19 #include "sync/internal_api/public/engine/model_safe_worker.h" 20 #include "sync/internal_api/public/engine/model_safe_worker.h"
20 #include "sync/internal_api/public/sync_manager.h" 21 #include "sync/internal_api/public/sync_manager.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 // 2) UI posts task to shut down syncer on sync thread. 61 // 2) UI posts task to shut down syncer on sync thread.
61 // 3) If sync is disabled, call ReleaseSyncThread() on the UI thread. 62 // 3) If sync is disabled, call ReleaseSyncThread() on the UI thread.
62 // 3) UI posts SyncBackendRegistrar::ShutDown() on sync thread to 63 // 3) UI posts SyncBackendRegistrar::ShutDown() on sync thread to
63 // unregister workers from observing destruction of their working loops. 64 // unregister workers from observing destruction of their working loops.
64 // 4) Workers notify registrar when unregistration finishes or working 65 // 4) Workers notify registrar when unregistration finishes or working
65 // loops are destroyed. Registrar destroys itself on last worker 66 // loops are destroyed. Registrar destroys itself on last worker
66 // notification. Sync thread will be stopped if ownership was not 67 // notification. Sync thread will be stopped if ownership was not
67 // released. 68 // released.
68 ~SyncBackendRegistrar() override; 69 ~SyncBackendRegistrar() override;
69 70
71 // Adds |type| to set of non-blocking types. These types will have
72 // GROUP_NON_BLOCKING initial model safe group and would be treated
73 // differently in ModelTypeRegistry.
74 void RegisterNonBlockingType(syncer::ModelType type);
75
70 // Informs the SyncBackendRegistrar of the currently enabled set of types. 76 // Informs the SyncBackendRegistrar of the currently enabled set of types.
71 // These types will be placed in the passive group. This function should be 77 // These types will be placed in the passive group. This function should be
72 // called exactly once during startup. 78 // called exactly once during startup.
73 void SetInitialTypes(syncer::ModelTypeSet initial_types); 79 void SetInitialTypes(syncer::ModelTypeSet initial_types);
74 80
75 // Returns whether or not we are currently syncing encryption keys. 81 // Returns whether or not we are currently syncing encryption keys.
76 // Must be called on the UI thread. 82 // Must be called on the UI thread.
77 bool IsNigoriEnabled() const; 83 bool IsNigoriEnabled() const;
78 84
79 // Removes all types in |types_to_remove| from the routing info and 85 // Removes all types in |types_to_remove| from the routing info and
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 165
160 // Return true if |model_type| lives on the current thread. Must be 166 // Return true if |model_type| lives on the current thread. Must be
161 // called with |lock_| held. May be called on any thread. 167 // called with |lock_| held. May be called on any thread.
162 bool IsCurrentThreadSafeForModel(syncer::ModelType model_type) const; 168 bool IsCurrentThreadSafeForModel(syncer::ModelType model_type) const;
163 169
164 // Returns true if the current thread is the native thread for the 170 // Returns true if the current thread is the native thread for the
165 // given group (or if it is undeterminable). 171 // given group (or if it is undeterminable).
166 bool IsOnThreadForGroup(syncer::ModelType type, 172 bool IsOnThreadForGroup(syncer::ModelType type,
167 syncer::ModelSafeGroup group) const; 173 syncer::ModelSafeGroup group) const;
168 174
175 // Returns model safe group that should be assigned to type when it is first
176 // configured (before activation). Returns GROUP_PASSIVE for directory types
177 // and GROUP_NON_BLOCKING for non-blocking types.
178 syncer::ModelSafeGroup GetInitialGroupForType(syncer::ModelType type) const;
179
169 // Name used for debugging. 180 // Name used for debugging.
170 const std::string name_; 181 const std::string name_;
171 182
172 // A pointer to the sync client. 183 // A pointer to the sync client.
173 sync_driver::SyncClient* const sync_client_; 184 sync_driver::SyncClient* const sync_client_;
174 185
175 // Protects all variables below. 186 // Protects all variables below.
176 mutable base::Lock lock_; 187 mutable base::Lock lock_;
177 188
178 // We maintain ownership of all workers. In some cases, we need to 189 // We maintain ownership of all workers. In some cases, we need to
(...skipping 23 matching lines...) Expand all
202 const scoped_refptr<base::SingleThreadTaskRunner> ui_thread_; 213 const scoped_refptr<base::SingleThreadTaskRunner> ui_thread_;
203 const scoped_refptr<base::SingleThreadTaskRunner> db_thread_; 214 const scoped_refptr<base::SingleThreadTaskRunner> db_thread_;
204 const scoped_refptr<base::SingleThreadTaskRunner> file_thread_; 215 const scoped_refptr<base::SingleThreadTaskRunner> file_thread_;
205 216
206 // Declare |sync_thread_| at the end so that it will be destroyed before 217 // Declare |sync_thread_| at the end so that it will be destroyed before
207 // objects above because tasks on sync thread depend on those objects, 218 // objects above because tasks on sync thread depend on those objects,
208 // e.g. Shutdown() depends on |lock_|, SyncManager::Init() depends on 219 // e.g. Shutdown() depends on |lock_|, SyncManager::Init() depends on
209 // workers, etc. 220 // workers, etc.
210 scoped_ptr<base::Thread> sync_thread_; 221 scoped_ptr<base::Thread> sync_thread_;
211 222
223 // Set of types with non-blocking implementation (as opposed to directory
224 // based).
225 syncer::ModelTypeSet non_blocking_types_;
226
212 DISALLOW_COPY_AND_ASSIGN(SyncBackendRegistrar); 227 DISALLOW_COPY_AND_ASSIGN(SyncBackendRegistrar);
213 }; 228 };
214 229
215 } // namespace browser_sync 230 } // namespace browser_sync
216 231
217 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_REGISTRAR_H_ 232 #endif // COMPONENTS_SYNC_DRIVER_GLUE_SYNC_BACKEND_REGISTRAR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698