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

Side by Side Diff: components/sync/driver/glue/sync_backend_host_impl.cc

Issue 2283373002: Remove unneeded scoped_refptr<>::get() on method binding (Closed)
Patch Set: Created 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/sync/driver/glue/sync_backend_host_impl.h" 5 #include "components/sync/driver/glue/sync_backend_host_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 new syncer::InternalComponentsFactoryImpl(factory_switches)), 131 new syncer::InternalComponentsFactoryImpl(factory_switches)),
132 unrecoverable_error_handler, report_unrecoverable_error_function, 132 unrecoverable_error_handler, report_unrecoverable_error_function,
133 std::move(saved_nigori_state), invalidation_versions)); 133 std::move(saved_nigori_state), invalidation_versions));
134 InitCore(std::move(init_opts)); 134 InitCore(std::move(init_opts));
135 } 135 }
136 136
137 void SyncBackendHostImpl::TriggerRefresh(const syncer::ModelTypeSet& types) { 137 void SyncBackendHostImpl::TriggerRefresh(const syncer::ModelTypeSet& types) {
138 DCHECK(ui_thread_->BelongsToCurrentThread()); 138 DCHECK(ui_thread_->BelongsToCurrentThread());
139 registrar_->sync_thread()->task_runner()->PostTask( 139 registrar_->sync_thread()->task_runner()->PostTask(
140 FROM_HERE, 140 FROM_HERE,
141 base::Bind(&SyncBackendHostCore::DoRefreshTypes, core_.get(), types)); 141 base::Bind(&SyncBackendHostCore::DoRefreshTypes, core_, types));
142 } 142 }
143 143
144 void SyncBackendHostImpl::UpdateCredentials( 144 void SyncBackendHostImpl::UpdateCredentials(
145 const syncer::SyncCredentials& credentials) { 145 const syncer::SyncCredentials& credentials) {
146 DCHECK(registrar_->sync_thread()->IsRunning()); 146 DCHECK(registrar_->sync_thread()->IsRunning());
147 registrar_->sync_thread()->task_runner()->PostTask( 147 registrar_->sync_thread()->task_runner()->PostTask(
148 FROM_HERE, base::Bind(&SyncBackendHostCore::DoUpdateCredentials, 148 FROM_HERE, base::Bind(&SyncBackendHostCore::DoUpdateCredentials,
149 core_.get(), credentials)); 149 core_, credentials));
150 } 150 }
151 151
152 void SyncBackendHostImpl::StartSyncingWithServer() { 152 void SyncBackendHostImpl::StartSyncingWithServer() {
153 SDVLOG(1) << "SyncBackendHostImpl::StartSyncingWithServer called."; 153 SDVLOG(1) << "SyncBackendHostImpl::StartSyncingWithServer called.";
154 154
155 syncer::ModelSafeRoutingInfo routing_info; 155 syncer::ModelSafeRoutingInfo routing_info;
156 registrar_->GetModelSafeRoutingInfo(&routing_info); 156 registrar_->GetModelSafeRoutingInfo(&routing_info);
157 157
158 registrar_->sync_thread()->task_runner()->PostTask( 158 registrar_->sync_thread()->task_runner()->PostTask(
159 FROM_HERE, base::Bind(&SyncBackendHostCore::DoStartSyncing, core_.get(), 159 FROM_HERE, base::Bind(&SyncBackendHostCore::DoStartSyncing, core_,
160 routing_info, sync_prefs_->GetLastPollTime())); 160 routing_info, sync_prefs_->GetLastPollTime()));
161 } 161 }
162 162
163 void SyncBackendHostImpl::SetEncryptionPassphrase(const std::string& passphrase, 163 void SyncBackendHostImpl::SetEncryptionPassphrase(const std::string& passphrase,
164 bool is_explicit) { 164 bool is_explicit) {
165 DCHECK(registrar_->sync_thread()->IsRunning()); 165 DCHECK(registrar_->sync_thread()->IsRunning());
166 if (!IsNigoriEnabled()) { 166 if (!IsNigoriEnabled()) {
167 NOTREACHED() << "SetEncryptionPassphrase must never be called when nigori" 167 NOTREACHED() << "SetEncryptionPassphrase must never be called when nigori"
168 " is disabled."; 168 " is disabled.";
169 return; 169 return;
170 } 170 }
171 171
172 // We should never be called with an empty passphrase. 172 // We should never be called with an empty passphrase.
173 DCHECK(!passphrase.empty()); 173 DCHECK(!passphrase.empty());
174 174
175 // This should only be called by the frontend. 175 // This should only be called by the frontend.
176 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); 176 DCHECK(frontend_task_runner_->BelongsToCurrentThread());
177 177
178 // SetEncryptionPassphrase should never be called if we are currently 178 // SetEncryptionPassphrase should never be called if we are currently
179 // encrypted with an explicit passphrase. 179 // encrypted with an explicit passphrase.
180 DCHECK(cached_passphrase_type_ == syncer::KEYSTORE_PASSPHRASE || 180 DCHECK(cached_passphrase_type_ == syncer::KEYSTORE_PASSPHRASE ||
181 cached_passphrase_type_ == syncer::IMPLICIT_PASSPHRASE); 181 cached_passphrase_type_ == syncer::IMPLICIT_PASSPHRASE);
182 182
183 // Post an encryption task on the syncer thread. 183 // Post an encryption task on the syncer thread.
184 registrar_->sync_thread()->task_runner()->PostTask( 184 registrar_->sync_thread()->task_runner()->PostTask(
185 FROM_HERE, base::Bind(&SyncBackendHostCore::DoSetEncryptionPassphrase, 185 FROM_HERE, base::Bind(&SyncBackendHostCore::DoSetEncryptionPassphrase,
186 core_.get(), passphrase, is_explicit)); 186 core_, passphrase, is_explicit));
187 } 187 }
188 188
189 bool SyncBackendHostImpl::SetDecryptionPassphrase( 189 bool SyncBackendHostImpl::SetDecryptionPassphrase(
190 const std::string& passphrase) { 190 const std::string& passphrase) {
191 if (!IsNigoriEnabled()) { 191 if (!IsNigoriEnabled()) {
192 NOTREACHED() << "SetDecryptionPassphrase must never be called when nigori" 192 NOTREACHED() << "SetDecryptionPassphrase must never be called when nigori"
193 " is disabled."; 193 " is disabled.";
194 return false; 194 return false;
195 } 195 }
196 196
197 // We should never be called with an empty passphrase. 197 // We should never be called with an empty passphrase.
198 DCHECK(!passphrase.empty()); 198 DCHECK(!passphrase.empty());
199 199
200 // This should only be called by the frontend. 200 // This should only be called by the frontend.
201 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); 201 DCHECK(frontend_task_runner_->BelongsToCurrentThread());
202 202
203 // This should only be called when we have cached pending keys. 203 // This should only be called when we have cached pending keys.
204 DCHECK(cached_pending_keys_.has_blob()); 204 DCHECK(cached_pending_keys_.has_blob());
205 205
206 // Check the passphrase that was provided against our local cache of the 206 // Check the passphrase that was provided against our local cache of the
207 // cryptographer's pending keys. If this was unsuccessful, the UI layer can 207 // cryptographer's pending keys. If this was unsuccessful, the UI layer can
208 // immediately call OnPassphraseRequired without showing the user a spinner. 208 // immediately call OnPassphraseRequired without showing the user a spinner.
209 if (!CheckPassphraseAgainstCachedPendingKeys(passphrase)) 209 if (!CheckPassphraseAgainstCachedPendingKeys(passphrase))
210 return false; 210 return false;
211 211
212 // Post a decryption task on the syncer thread. 212 // Post a decryption task on the syncer thread.
213 registrar_->sync_thread()->task_runner()->PostTask( 213 registrar_->sync_thread()->task_runner()->PostTask(
214 FROM_HERE, base::Bind(&SyncBackendHostCore::DoSetDecryptionPassphrase, 214 FROM_HERE, base::Bind(&SyncBackendHostCore::DoSetDecryptionPassphrase,
215 core_.get(), passphrase)); 215 core_, passphrase));
216 216
217 // Since we were able to decrypt the cached pending keys with the passphrase 217 // Since we were able to decrypt the cached pending keys with the passphrase
218 // provided, we immediately alert the UI layer that the passphrase was 218 // provided, we immediately alert the UI layer that the passphrase was
219 // accepted. This will avoid the situation where a user enters a passphrase, 219 // accepted. This will avoid the situation where a user enters a passphrase,
220 // clicks OK, immediately reopens the advanced settings dialog, and gets an 220 // clicks OK, immediately reopens the advanced settings dialog, and gets an
221 // unnecessary prompt for a passphrase. 221 // unnecessary prompt for a passphrase.
222 // Note: It is not guaranteed that the passphrase will be accepted by the 222 // Note: It is not guaranteed that the passphrase will be accepted by the
223 // syncer thread, since we could receive a new nigori node while the task is 223 // syncer thread, since we could receive a new nigori node while the task is
224 // pending. This scenario is a valid race, and SetDecryptionPassphrase can 224 // pending. This scenario is a valid race, and SetDecryptionPassphrase can
225 // trigger a new OnPassphraseRequired if it needs to. 225 // trigger a new OnPassphraseRequired if it needs to.
(...skipping 30 matching lines...) Expand all
256 invalidator_->UnregisterInvalidationHandler(this); 256 invalidator_->UnregisterInvalidationHandler(this);
257 invalidator_ = NULL; 257 invalidator_ = NULL;
258 } 258 }
259 invalidation_handler_registered_ = false; 259 invalidation_handler_registered_ = false;
260 260
261 model_type_connector_.reset(); 261 model_type_connector_.reset();
262 262
263 // Shut down and destroy sync manager. 263 // Shut down and destroy sync manager.
264 registrar_->sync_thread()->task_runner()->PostTask( 264 registrar_->sync_thread()->task_runner()->PostTask(
265 FROM_HERE, 265 FROM_HERE,
266 base::Bind(&SyncBackendHostCore::DoShutdown, core_.get(), reason)); 266 base::Bind(&SyncBackendHostCore::DoShutdown, core_, reason));
267 core_ = NULL; 267 core_ = NULL;
268 268
269 // Worker cleanup. 269 // Worker cleanup.
270 SyncBackendRegistrar* detached_registrar = registrar_.release(); 270 SyncBackendRegistrar* detached_registrar = registrar_.release();
271 detached_registrar->sync_thread()->task_runner()->PostTask( 271 detached_registrar->sync_thread()->task_runner()->PostTask(
272 FROM_HERE, base::Bind(&SyncBackendRegistrar::Shutdown, 272 FROM_HERE, base::Bind(&SyncBackendRegistrar::Shutdown,
273 base::Unretained(detached_registrar))); 273 base::Unretained(detached_registrar)));
274 274
275 if (sync_thread_claimed) 275 if (sync_thread_claimed)
276 return detached_registrar->ReleaseSyncThread(); 276 return detached_registrar->ReleaseSyncThread();
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 DCHECK(syncer::Intersection(active_types, types_to_purge).Empty()); 402 DCHECK(syncer::Intersection(active_types, types_to_purge).Empty());
403 DCHECK(syncer::Intersection(active_types, fatal_types).Empty()); 403 DCHECK(syncer::Intersection(active_types, fatal_types).Empty());
404 DCHECK(syncer::Intersection(active_types, unapply_types).Empty()); 404 DCHECK(syncer::Intersection(active_types, unapply_types).Empty());
405 DCHECK(syncer::Intersection(active_types, inactive_types).Empty()); 405 DCHECK(syncer::Intersection(active_types, inactive_types).Empty());
406 return syncer::Difference(active_types, types_to_download); 406 return syncer::Difference(active_types, types_to_download);
407 } 407 }
408 408
409 void SyncBackendHostImpl::EnableEncryptEverything() { 409 void SyncBackendHostImpl::EnableEncryptEverything() {
410 registrar_->sync_thread()->task_runner()->PostTask( 410 registrar_->sync_thread()->task_runner()->PostTask(
411 FROM_HERE, 411 FROM_HERE,
412 base::Bind(&SyncBackendHostCore::DoEnableEncryptEverything, core_.get())); 412 base::Bind(&SyncBackendHostCore::DoEnableEncryptEverything, core_));
413 } 413 }
414 414
415 void SyncBackendHostImpl::ActivateDirectoryDataType( 415 void SyncBackendHostImpl::ActivateDirectoryDataType(
416 syncer::ModelType type, 416 syncer::ModelType type,
417 syncer::ModelSafeGroup group, 417 syncer::ModelSafeGroup group,
418 sync_driver::ChangeProcessor* change_processor) { 418 sync_driver::ChangeProcessor* change_processor) {
419 registrar_->ActivateDataType(type, group, change_processor, GetUserShare()); 419 registrar_->ActivateDataType(type, group, change_processor, GetUserShare());
420 } 420 }
421 421
422 void SyncBackendHostImpl::DeactivateDirectoryDataType(syncer::ModelType type) { 422 void SyncBackendHostImpl::DeactivateDirectoryDataType(syncer::ModelType type) {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 ScopedVector<base::ListValue>)> callback) { 525 ScopedVector<base::ListValue>)> callback) {
526 DCHECK(initialized()); 526 DCHECK(initialized());
527 registrar_->sync_thread()->task_runner()->PostTask( 527 registrar_->sync_thread()->task_runner()->PostTask(
528 FROM_HERE, base::Bind(&SyncBackendHostCore::GetAllNodesForTypes, core_, 528 FROM_HERE, base::Bind(&SyncBackendHostCore::GetAllNodesForTypes, core_,
529 types, frontend_task_runner_, callback)); 529 types, frontend_task_runner_, callback));
530 } 530 }
531 531
532 void SyncBackendHostImpl::InitCore( 532 void SyncBackendHostImpl::InitCore(
533 std::unique_ptr<DoInitializeOptions> options) { 533 std::unique_ptr<DoInitializeOptions> options) {
534 registrar_->sync_thread()->task_runner()->PostTask( 534 registrar_->sync_thread()->task_runner()->PostTask(
535 FROM_HERE, base::Bind(&SyncBackendHostCore::DoInitialize, core_.get(), 535 FROM_HERE, base::Bind(&SyncBackendHostCore::DoInitialize, core_,
536 base::Passed(&options))); 536 base::Passed(&options)));
537 } 537 }
538 538
539 void SyncBackendHostImpl::RequestConfigureSyncer( 539 void SyncBackendHostImpl::RequestConfigureSyncer(
540 syncer::ConfigureReason reason, 540 syncer::ConfigureReason reason,
541 syncer::ModelTypeSet to_download, 541 syncer::ModelTypeSet to_download,
542 syncer::ModelTypeSet to_purge, 542 syncer::ModelTypeSet to_purge,
543 syncer::ModelTypeSet to_journal, 543 syncer::ModelTypeSet to_journal,
544 syncer::ModelTypeSet to_unapply, 544 syncer::ModelTypeSet to_unapply,
545 syncer::ModelTypeSet to_ignore, 545 syncer::ModelTypeSet to_ignore,
546 const syncer::ModelSafeRoutingInfo& routing_info, 546 const syncer::ModelSafeRoutingInfo& routing_info,
547 const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>& 547 const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>&
548 ready_task, 548 ready_task,
549 const base::Closure& retry_callback) { 549 const base::Closure& retry_callback) {
550 DoConfigureSyncerTypes config_types; 550 DoConfigureSyncerTypes config_types;
551 config_types.to_download = to_download; 551 config_types.to_download = to_download;
552 config_types.to_purge = to_purge; 552 config_types.to_purge = to_purge;
553 config_types.to_journal = to_journal; 553 config_types.to_journal = to_journal;
554 config_types.to_unapply = to_unapply; 554 config_types.to_unapply = to_unapply;
555 registrar_->sync_thread()->task_runner()->PostTask( 555 registrar_->sync_thread()->task_runner()->PostTask(
556 FROM_HERE, 556 FROM_HERE,
557 base::Bind(&SyncBackendHostCore::DoConfigureSyncer, core_.get(), reason, 557 base::Bind(&SyncBackendHostCore::DoConfigureSyncer, core_, reason,
558 config_types, routing_info, ready_task, retry_callback)); 558 config_types, routing_info, ready_task, retry_callback));
559 } 559 }
560 560
561 void SyncBackendHostImpl::FinishConfigureDataTypesOnFrontendLoop( 561 void SyncBackendHostImpl::FinishConfigureDataTypesOnFrontendLoop(
562 const syncer::ModelTypeSet enabled_types, 562 const syncer::ModelTypeSet enabled_types,
563 const syncer::ModelTypeSet succeeded_configuration_types, 563 const syncer::ModelTypeSet succeeded_configuration_types,
564 const syncer::ModelTypeSet failed_configuration_types, 564 const syncer::ModelTypeSet failed_configuration_types,
565 const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>& 565 const base::Callback<void(syncer::ModelTypeSet, syncer::ModelTypeSet)>&
566 ready_task) { 566 ready_task) {
567 if (!frontend_) 567 if (!frontend_)
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 if (!frontend_) 676 if (!frontend_)
677 return; 677 return;
678 DCHECK(frontend_task_runner_->BelongsToCurrentThread()); 678 DCHECK(frontend_task_runner_->BelongsToCurrentThread());
679 frontend_->OnMigrationNeededForTypes(types); 679 frontend_->OnMigrationNeededForTypes(types);
680 } 680 }
681 681
682 void SyncBackendHostImpl::OnInvalidatorStateChange( 682 void SyncBackendHostImpl::OnInvalidatorStateChange(
683 syncer::InvalidatorState state) { 683 syncer::InvalidatorState state) {
684 registrar_->sync_thread()->task_runner()->PostTask( 684 registrar_->sync_thread()->task_runner()->PostTask(
685 FROM_HERE, base::Bind(&SyncBackendHostCore::DoOnInvalidatorStateChange, 685 FROM_HERE, base::Bind(&SyncBackendHostCore::DoOnInvalidatorStateChange,
686 core_.get(), state)); 686 core_, state));
687 } 687 }
688 688
689 void SyncBackendHostImpl::OnIncomingInvalidation( 689 void SyncBackendHostImpl::OnIncomingInvalidation(
690 const syncer::ObjectIdInvalidationMap& invalidation_map) { 690 const syncer::ObjectIdInvalidationMap& invalidation_map) {
691 registrar_->sync_thread()->task_runner()->PostTask( 691 registrar_->sync_thread()->task_runner()->PostTask(
692 FROM_HERE, base::Bind(&SyncBackendHostCore::DoOnIncomingInvalidation, 692 FROM_HERE, base::Bind(&SyncBackendHostCore::DoOnIncomingInvalidation,
693 core_.get(), invalidation_map)); 693 core_, invalidation_map));
694 } 694 }
695 695
696 std::string SyncBackendHostImpl::GetOwnerName() const { 696 std::string SyncBackendHostImpl::GetOwnerName() const {
697 return "SyncBackendHostImpl"; 697 return "SyncBackendHostImpl";
698 } 698 }
699 699
700 bool SyncBackendHostImpl::CheckPassphraseAgainstCachedPendingKeys( 700 bool SyncBackendHostImpl::CheckPassphraseAgainstCachedPendingKeys(
701 const std::string& passphrase) const { 701 const std::string& passphrase) const {
702 DCHECK(cached_pending_keys_.has_blob()); 702 DCHECK(cached_pending_keys_.has_blob());
703 DCHECK(!passphrase.empty()); 703 DCHECK(!passphrase.empty());
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 819
820 base::MessageLoop* SyncBackendHostImpl::GetSyncLoopForTesting() { 820 base::MessageLoop* SyncBackendHostImpl::GetSyncLoopForTesting() {
821 return registrar_->sync_thread()->message_loop(); 821 return registrar_->sync_thread()->message_loop();
822 } 822 }
823 823
824 void SyncBackendHostImpl::RefreshTypesForTest(syncer::ModelTypeSet types) { 824 void SyncBackendHostImpl::RefreshTypesForTest(syncer::ModelTypeSet types) {
825 DCHECK(ui_thread_->BelongsToCurrentThread()); 825 DCHECK(ui_thread_->BelongsToCurrentThread());
826 826
827 registrar_->sync_thread()->task_runner()->PostTask( 827 registrar_->sync_thread()->task_runner()->PostTask(
828 FROM_HERE, 828 FROM_HERE,
829 base::Bind(&SyncBackendHostCore::DoRefreshTypes, core_.get(), types)); 829 base::Bind(&SyncBackendHostCore::DoRefreshTypes, core_, types));
830 } 830 }
831 831
832 void SyncBackendHostImpl::ClearServerData( 832 void SyncBackendHostImpl::ClearServerData(
833 const syncer::SyncManager::ClearServerDataCallback& callback) { 833 const syncer::SyncManager::ClearServerDataCallback& callback) {
834 DCHECK(ui_thread_->BelongsToCurrentThread()); 834 DCHECK(ui_thread_->BelongsToCurrentThread());
835 registrar_->sync_thread()->task_runner()->PostTask( 835 registrar_->sync_thread()->task_runner()->PostTask(
836 FROM_HERE, base::Bind(&SyncBackendHostCore::DoClearServerData, 836 FROM_HERE, base::Bind(&SyncBackendHostCore::DoClearServerData,
837 core_.get(), callback)); 837 core_, callback));
838 } 838 }
839 839
840 void SyncBackendHostImpl::OnCookieJarChanged(bool account_mismatch, 840 void SyncBackendHostImpl::OnCookieJarChanged(bool account_mismatch,
841 bool empty_jar) { 841 bool empty_jar) {
842 DCHECK(ui_thread_->BelongsToCurrentThread()); 842 DCHECK(ui_thread_->BelongsToCurrentThread());
843 registrar_->sync_thread()->task_runner()->PostTask( 843 registrar_->sync_thread()->task_runner()->PostTask(
844 FROM_HERE, base::Bind(&SyncBackendHostCore::DoOnCookieJarChanged, 844 FROM_HERE, base::Bind(&SyncBackendHostCore::DoOnCookieJarChanged,
845 core_.get(), account_mismatch, empty_jar)); 845 core_, account_mismatch, empty_jar));
846 } 846 }
847 847
848 void SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop( 848 void SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop(
849 const syncer::SyncManager::ClearServerDataCallback& frontend_callback) { 849 const syncer::SyncManager::ClearServerDataCallback& frontend_callback) {
850 DCHECK(ui_thread_->BelongsToCurrentThread()); 850 DCHECK(ui_thread_->BelongsToCurrentThread());
851 frontend_callback.Run(); 851 frontend_callback.Run();
852 } 852 }
853 853
854 } // namespace browser_sync 854 } // namespace browser_sync
855 855
856 #undef SDVLOG 856 #undef SDVLOG
857 857
858 #undef SLOG 858 #undef SLOG
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698