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

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

Issue 14046031: Worker changes to prepare for lock-free shutdown. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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) 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 #include "chrome/browser/sync/glue/sync_backend_registrar.h" 5 #include "chrome/browser/sync/glue/sync_backend_registrar.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 } 52 }
53 53
54 } // namespace 54 } // namespace
55 55
56 SyncBackendRegistrar::SyncBackendRegistrar( 56 SyncBackendRegistrar::SyncBackendRegistrar(
57 const std::string& name, Profile* profile, 57 const std::string& name, Profile* profile,
58 MessageLoop* sync_loop) : 58 MessageLoop* sync_loop) :
59 name_(name), 59 name_(name),
60 profile_(profile), 60 profile_(profile),
61 sync_loop_(sync_loop), 61 sync_loop_(sync_loop),
62 ui_worker_(new UIModelWorker()), 62 ui_worker_(new UIModelWorker(this)),
63 stopped_on_ui_thread_(false) { 63 stopped_on_ui_thread_(false) {
64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
65 CHECK(profile_); 65 CHECK(profile_);
66 DCHECK(sync_loop_); 66 DCHECK(sync_loop_);
67 workers_[syncer::GROUP_DB] = new DatabaseModelWorker(); 67 workers_[syncer::GROUP_DB] = new DatabaseModelWorker(this);
68 workers_[syncer::GROUP_FILE] = new FileModelWorker(); 68 workers_[syncer::GROUP_FILE] = new FileModelWorker(this);
69 workers_[syncer::GROUP_UI] = ui_worker_; 69 workers_[syncer::GROUP_UI] = ui_worker_;
70 workers_[syncer::GROUP_PASSIVE] = new syncer::PassiveModelWorker(sync_loop_); 70 workers_[syncer::GROUP_PASSIVE] = new syncer::PassiveModelWorker(sync_loop_,
71 this);
71 72
72 HistoryService* history_service = 73 HistoryService* history_service =
73 HistoryServiceFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS); 74 HistoryServiceFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS);
74 if (history_service) { 75 if (history_service) {
75 workers_[syncer::GROUP_HISTORY] = 76 workers_[syncer::GROUP_HISTORY] =
76 new HistoryModelWorker(history_service->AsWeakPtr()); 77 new HistoryModelWorker(history_service->AsWeakPtr(), this);
77 } 78 }
78 79
79 scoped_refptr<PasswordStore> password_store = 80 scoped_refptr<PasswordStore> password_store =
80 PasswordStoreFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS); 81 PasswordStoreFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS);
81 if (password_store) { 82 if (password_store) {
82 workers_[syncer::GROUP_PASSWORD] = new PasswordModelWorker(password_store); 83 workers_[syncer::GROUP_PASSWORD] = new PasswordModelWorker(password_store,
84 this);
83 } 85 }
84 } 86 }
85 87
86 void SyncBackendRegistrar::SetInitialTypes(syncer::ModelTypeSet initial_types) { 88 void SyncBackendRegistrar::SetInitialTypes(syncer::ModelTypeSet initial_types) {
87 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 89 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
88 base::AutoLock lock(lock_); 90 base::AutoLock lock(lock_);
89 91
90 // This function should be called only once, shortly after construction. The 92 // This function should be called only once, shortly after construction. The
91 // routing info at that point is expected to be emtpy. 93 // routing info at that point is expected to be emtpy.
92 DCHECK(routing_info_.empty()); 94 DCHECK(routing_info_.empty());
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 return it->second; 290 return it->second;
289 } 291 }
290 292
291 bool SyncBackendRegistrar::IsCurrentThreadSafeForModel( 293 bool SyncBackendRegistrar::IsCurrentThreadSafeForModel(
292 syncer::ModelType model_type) const { 294 syncer::ModelType model_type) const {
293 lock_.AssertAcquired(); 295 lock_.AssertAcquired();
294 return IsOnThreadForGroup(model_type, 296 return IsOnThreadForGroup(model_type,
295 GetGroupForModelType(model_type, routing_info_)); 297 GetGroupForModelType(model_type, routing_info_));
296 } 298 }
297 299
300 void SyncBackendRegistrar::OnWorkerLoopDestroyed(syncer::ModelSafeGroup group) {
301 // Do nothing for now.
302 }
303
298 } // namespace browser_sync 304 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/sync_backend_registrar.h ('k') | chrome/browser/sync/glue/ui_model_worker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698