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

Side by Side Diff: chrome/browser/sync/glue/sync_backend_registrar.cc

Issue 7891054: Add GROUP_FILE ModelSafeGroup (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "chrome/browser/sync/glue/sync_backend_registrar.h" 5 #include "chrome/browser/sync/glue/sync_backend_registrar.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/sync/glue/change_processor.h" 13 #include "chrome/browser/sync/glue/change_processor.h"
14 #include "chrome/browser/sync/glue/database_model_worker.h" 14 #include "chrome/browser/sync/glue/database_model_worker.h"
15 #include "chrome/browser/sync/glue/file_model_worker.h"
15 #include "chrome/browser/sync/glue/history_model_worker.h" 16 #include "chrome/browser/sync/glue/history_model_worker.h"
16 #include "chrome/browser/sync/glue/password_model_worker.h" 17 #include "chrome/browser/sync/glue/password_model_worker.h"
17 #include "chrome/browser/sync/glue/ui_model_worker.h" 18 #include "chrome/browser/sync/glue/ui_model_worker.h"
18 #include "content/browser/browser_thread.h" 19 #include "content/browser/browser_thread.h"
19 20
20 namespace browser_sync { 21 namespace browser_sync {
21 22
22 namespace { 23 namespace {
23 24
24 // Returns true if the current thread is the native thread for the 25 // Returns true if the current thread is the native thread for the
25 // given group (or if it is undeterminable). 26 // given group (or if it is undeterminable).
26 bool IsOnThreadForGroup(ModelSafeGroup group) { 27 bool IsOnThreadForGroup(ModelSafeGroup group) {
27 switch (group) { 28 switch (group) {
28 case GROUP_PASSIVE: 29 case GROUP_PASSIVE:
29 return false; 30 return false;
30 case GROUP_UI: 31 case GROUP_UI:
31 return BrowserThread::CurrentlyOn(BrowserThread::UI); 32 return BrowserThread::CurrentlyOn(BrowserThread::UI);
32 case GROUP_DB: 33 case GROUP_DB:
33 return BrowserThread::CurrentlyOn(BrowserThread::DB); 34 return BrowserThread::CurrentlyOn(BrowserThread::DB);
35 case GROUP_FILE:
36 return BrowserThread::CurrentlyOn(BrowserThread::FILE);
34 case GROUP_HISTORY: 37 case GROUP_HISTORY:
35 // TODO(ncarter): How to determine this? 38 // TODO(ncarter): How to determine this?
36 return true; 39 return true;
37 case GROUP_PASSWORD: 40 case GROUP_PASSWORD:
38 // TODO(ncarter): How to determine this? 41 // TODO(ncarter): How to determine this?
39 return true; 42 return true;
40 case MODEL_SAFE_GROUP_COUNT: 43 case MODEL_SAFE_GROUP_COUNT:
41 default: 44 default:
42 return false; 45 return false;
43 } 46 }
44 } 47 }
45 48
46 } // namespace 49 } // namespace
47 50
48 SyncBackendRegistrar::SyncBackendRegistrar( 51 SyncBackendRegistrar::SyncBackendRegistrar(
49 const syncable::ModelTypeSet& initial_types, 52 const syncable::ModelTypeSet& initial_types,
50 const std::string& name, Profile* profile, 53 const std::string& name, Profile* profile,
51 MessageLoop* sync_loop) : 54 MessageLoop* sync_loop) :
52 name_(name), 55 name_(name),
53 profile_(profile), 56 profile_(profile),
54 sync_loop_(sync_loop), 57 sync_loop_(sync_loop),
55 ui_worker_(new UIModelWorker()), 58 ui_worker_(new UIModelWorker()),
56 stopped_on_ui_thread_(false) { 59 stopped_on_ui_thread_(false) {
57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 60 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
58 CHECK(profile_); 61 CHECK(profile_);
59 DCHECK(sync_loop_); 62 DCHECK(sync_loop_);
60 workers_[GROUP_DB] = new DatabaseModelWorker(); 63 workers_[GROUP_DB] = new DatabaseModelWorker();
64 workers_[GROUP_FILE] = new FileModelWorker();
61 workers_[GROUP_UI] = ui_worker_; 65 workers_[GROUP_UI] = ui_worker_;
62 workers_[GROUP_PASSIVE] = new ModelSafeWorker(); 66 workers_[GROUP_PASSIVE] = new ModelSafeWorker();
63 67
64 // Any datatypes that we want the syncer to pull down must be in the 68 // Any datatypes that we want the syncer to pull down must be in the
65 // routing_info map. We set them to group passive, meaning that 69 // routing_info map. We set them to group passive, meaning that
66 // updates will be applied to sync, but not dispatched to the native 70 // updates will be applied to sync, but not dispatched to the native
67 // models. 71 // models.
68 for (syncable::ModelTypeSet::const_iterator it = initial_types.begin(); 72 for (syncable::ModelTypeSet::const_iterator it = initial_types.begin();
69 it != initial_types.end(); ++it) { 73 it != initial_types.end(); ++it) {
70 routing_info_[*it] = GROUP_PASSIVE; 74 routing_info_[*it] = GROUP_PASSIVE;
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 } 255 }
252 256
253 bool SyncBackendRegistrar::IsCurrentThreadSafeForModel( 257 bool SyncBackendRegistrar::IsCurrentThreadSafeForModel(
254 syncable::ModelType model_type) const { 258 syncable::ModelType model_type) const {
255 lock_.AssertAcquired(); 259 lock_.AssertAcquired();
256 return IsOnThreadForGroup(GetGroupForModelType(model_type, routing_info_)); 260 return IsOnThreadForGroup(GetGroupForModelType(model_type, routing_info_));
257 } 261 }
258 262
259 } // namespace browser_sync 263 } // namespace browser_sync
260 264
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698