OLD | NEW |
---|---|
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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 } | 78 } |
79 | 79 |
80 scoped_refptr<PasswordStore> password_store = | 80 scoped_refptr<PasswordStore> password_store = |
81 PasswordStoreFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS); | 81 PasswordStoreFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS); |
82 if (password_store.get()) { | 82 if (password_store.get()) { |
83 workers_[syncer::GROUP_PASSWORD] = | 83 workers_[syncer::GROUP_PASSWORD] = |
84 new PasswordModelWorker(password_store, this); | 84 new PasswordModelWorker(password_store, this); |
85 } | 85 } |
86 } | 86 } |
87 | 87 |
88 SyncBackendRegistrar::~SyncBackendRegistrar() { | |
89 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
90 DCHECK(stopped_on_ui_thread_); | |
91 } | |
92 | |
88 void SyncBackendRegistrar::SetInitialTypes(syncer::ModelTypeSet initial_types) { | 93 void SyncBackendRegistrar::SetInitialTypes(syncer::ModelTypeSet initial_types) { |
89 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 94 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
90 base::AutoLock lock(lock_); | 95 base::AutoLock lock(lock_); |
91 | 96 |
92 // This function should be called only once, shortly after construction. The | 97 // This function should be called only once, shortly after construction. The |
93 // routing info at that point is expected to be emtpy. | 98 // routing info at that point is expected to be emtpy. |
94 DCHECK(routing_info_.empty()); | 99 DCHECK(routing_info_.empty()); |
95 | 100 |
96 // Set our initial state to reflect the current status of the sync directory. | 101 // Set our initial state to reflect the current status of the sync directory. |
97 // This will ensure that our calculations in ConfigureDataTypes() will always | 102 // This will ensure that our calculations in ConfigureDataTypes() will always |
98 // return correct results. | 103 // return correct results. |
99 for (syncer::ModelTypeSet::Iterator it = initial_types.First(); | 104 for (syncer::ModelTypeSet::Iterator it = initial_types.First(); |
100 it.Good(); it.Inc()) { | 105 it.Good(); it.Inc()) { |
101 routing_info_[it.Get()] = syncer::GROUP_PASSIVE; | 106 routing_info_[it.Get()] = syncer::GROUP_PASSIVE; |
102 } | 107 } |
103 | 108 |
104 if (!workers_.count(syncer::GROUP_HISTORY)) { | 109 if (!workers_.count(syncer::GROUP_HISTORY)) { |
105 LOG_IF(WARNING, initial_types.Has(syncer::TYPED_URLS)) | 110 LOG_IF(WARNING, initial_types.Has(syncer::TYPED_URLS)) |
106 << "History store disabled, cannot sync Omnibox History"; | 111 << "History store disabled, cannot sync Omnibox History"; |
107 routing_info_.erase(syncer::TYPED_URLS); | 112 routing_info_.erase(syncer::TYPED_URLS); |
108 } | 113 } |
109 | 114 |
110 if (!workers_.count(syncer::GROUP_PASSWORD)) { | 115 if (!workers_.count(syncer::GROUP_PASSWORD)) { |
111 LOG_IF(WARNING, initial_types.Has(syncer::PASSWORDS)) | 116 LOG_IF(WARNING, initial_types.Has(syncer::PASSWORDS)) |
112 << "Password store not initialized, cannot sync passwords"; | 117 << "Password store not initialized, cannot sync passwords"; |
113 routing_info_.erase(syncer::PASSWORDS); | 118 routing_info_.erase(syncer::PASSWORDS); |
114 } | 119 } |
rlarocque
2013/06/21 20:40:03
Should last_configured_types_ be initialized here?
Nicolas Zea
2013/06/21 21:20:48
Good point, done.
| |
115 } | 120 } |
116 | 121 |
117 SyncBackendRegistrar::~SyncBackendRegistrar() { | |
118 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
119 DCHECK(stopped_on_ui_thread_); | |
120 } | |
121 | |
122 bool SyncBackendRegistrar::IsNigoriEnabled() const { | 122 bool SyncBackendRegistrar::IsNigoriEnabled() const { |
123 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 123 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
124 base::AutoLock lock(lock_); | 124 base::AutoLock lock(lock_); |
125 return routing_info_.find(syncer::NIGORI) != routing_info_.end(); | 125 return routing_info_.find(syncer::NIGORI) != routing_info_.end(); |
126 } | 126 } |
127 | 127 |
128 syncer::ModelTypeSet SyncBackendRegistrar::ConfigureDataTypes( | 128 syncer::ModelTypeSet SyncBackendRegistrar::ConfigureDataTypes( |
129 syncer::ModelTypeSet types_to_add, | 129 syncer::ModelTypeSet types_to_add, |
130 syncer::ModelTypeSet types_to_remove) { | 130 syncer::ModelTypeSet types_to_remove) { |
131 DCHECK(Intersection(types_to_add, types_to_remove).Empty()); | 131 DCHECK(Intersection(types_to_add, types_to_remove).Empty()); |
(...skipping 26 matching lines...) Expand all Loading... | |
158 | 158 |
159 // TODO(akalin): Use SVLOG/SLOG if we add any more logging. | 159 // TODO(akalin): Use SVLOG/SLOG if we add any more logging. |
160 DVLOG(1) << name_ << ": Adding types " | 160 DVLOG(1) << name_ << ": Adding types " |
161 << syncer::ModelTypeSetToString(types_to_add) | 161 << syncer::ModelTypeSetToString(types_to_add) |
162 << " (with newly-added types " | 162 << " (with newly-added types " |
163 << syncer::ModelTypeSetToString(newly_added_types) | 163 << syncer::ModelTypeSetToString(newly_added_types) |
164 << ") and removing types " | 164 << ") and removing types " |
165 << syncer::ModelTypeSetToString(types_to_remove) | 165 << syncer::ModelTypeSetToString(types_to_remove) |
166 << " to get new routing info " | 166 << " to get new routing info " |
167 <<syncer::ModelSafeRoutingInfoToString(routing_info_); | 167 <<syncer::ModelSafeRoutingInfoToString(routing_info_); |
168 last_configured_types_ = syncer::GetRoutingInfoTypes(routing_info_); | |
168 | 169 |
169 return newly_added_types; | 170 return newly_added_types; |
170 } | 171 } |
171 | 172 |
173 syncer::ModelTypeSet SyncBackendRegistrar::GetLastConfiguredTypes() const { | |
174 return last_configured_types_; | |
175 } | |
176 | |
172 void SyncBackendRegistrar::StopOnUIThread() { | 177 void SyncBackendRegistrar::StopOnUIThread() { |
173 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
174 DCHECK(!stopped_on_ui_thread_); | 179 DCHECK(!stopped_on_ui_thread_); |
175 ui_worker_->Stop(); | 180 ui_worker_->Stop(); |
176 stopped_on_ui_thread_ = true; | 181 stopped_on_ui_thread_ = true; |
177 } | 182 } |
178 | 183 |
179 void SyncBackendRegistrar::OnSyncerShutdownComplete() { | 184 void SyncBackendRegistrar::OnSyncerShutdownComplete() { |
180 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); | 185 DCHECK_EQ(base::MessageLoop::current(), sync_loop_); |
181 ui_worker_->OnSyncerShutdownComplete(); | 186 ui_worker_->OnSyncerShutdownComplete(); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
295 lock_.AssertAcquired(); | 300 lock_.AssertAcquired(); |
296 return IsOnThreadForGroup(model_type, | 301 return IsOnThreadForGroup(model_type, |
297 GetGroupForModelType(model_type, routing_info_)); | 302 GetGroupForModelType(model_type, routing_info_)); |
298 } | 303 } |
299 | 304 |
300 void SyncBackendRegistrar::OnWorkerLoopDestroyed(syncer::ModelSafeGroup group) { | 305 void SyncBackendRegistrar::OnWorkerLoopDestroyed(syncer::ModelSafeGroup group) { |
301 // Do nothing for now. | 306 // Do nothing for now. |
302 } | 307 } |
303 | 308 |
304 } // namespace browser_sync | 309 } // namespace browser_sync |
OLD | NEW |