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

Unified Diff: components/sync_driver/glue/sync_backend_host_core.cc

Issue 2087583002: Remove calls to MessageLoop::current() in components. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix test error Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: components/sync_driver/glue/sync_backend_host_core.cc
diff --git a/components/sync_driver/glue/sync_backend_host_core.cc b/components/sync_driver/glue/sync_backend_host_core.cc
index a36b4b768ffad00aa80d557db9654158884cf60d..af99ecac4015ba7fba38c70d26d1f9c00d5cee48 100644
--- a/components/sync_driver/glue/sync_backend_host_core.cc
+++ b/components/sync_driver/glue/sync_backend_host_core.cc
@@ -133,7 +133,7 @@ void SyncBackendHostCore::OnSyncCycleCompleted(
const syncer::sessions::SyncSessionSnapshot& snapshot) {
if (!sync_loop_)
return;
- DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
+ DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
host_.Call(
FROM_HERE,
@@ -142,7 +142,7 @@ void SyncBackendHostCore::OnSyncCycleCompleted(
}
void SyncBackendHostCore::DoRefreshTypes(syncer::ModelTypeSet types) {
- DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
+ DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
sync_manager_->RefreshTypes(types);
}
@@ -152,7 +152,7 @@ void SyncBackendHostCore::OnInitializationComplete(
debug_info_listener,
bool success,
const syncer::ModelTypeSet restored_types) {
- DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
+ DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
if (!success) {
DoDestroySyncManager(syncer::STOP_SYNC);
@@ -219,7 +219,7 @@ void SyncBackendHostCore::OnConnectionStatusChange(
syncer::ConnectionStatus status) {
if (!sync_loop_)
return;
- DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
+ DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
host_.Call(
FROM_HERE,
&SyncBackendHostImpl::HandleConnectionStatusChangeOnFrontendLoop, status);
@@ -230,7 +230,7 @@ void SyncBackendHostCore::OnPassphraseRequired(
const sync_pb::EncryptedData& pending_keys) {
if (!sync_loop_)
return;
- DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
+ DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
host_.Call(
FROM_HERE,
&SyncBackendHostImpl::NotifyPassphraseRequired, reason, pending_keys);
@@ -239,7 +239,7 @@ void SyncBackendHostCore::OnPassphraseRequired(
void SyncBackendHostCore::OnPassphraseAccepted() {
if (!sync_loop_)
return;
- DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
+ DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
host_.Call(
FROM_HERE,
&SyncBackendHostImpl::NotifyPassphraseAccepted);
@@ -250,7 +250,7 @@ void SyncBackendHostCore::OnBootstrapTokenUpdated(
syncer::BootstrapTokenType type) {
if (!sync_loop_)
return;
- DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
+ DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
host_.Call(FROM_HERE,
&SyncBackendHostImpl::PersistEncryptionBootstrapToken,
bootstrap_token,
@@ -262,7 +262,7 @@ void SyncBackendHostCore::OnEncryptedTypesChanged(
bool encrypt_everything) {
if (!sync_loop_)
return;
- DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
+ DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
// NOTE: We're in a transaction.
host_.Call(
FROM_HERE,
@@ -273,7 +273,7 @@ void SyncBackendHostCore::OnEncryptedTypesChanged(
void SyncBackendHostCore::OnEncryptionComplete() {
if (!sync_loop_)
return;
- DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
+ DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
// NOTE: We're in a transaction.
host_.Call(
FROM_HERE,
@@ -332,7 +332,7 @@ void SyncBackendHostCore::OnActionableError(
const syncer::SyncProtocolError& sync_error) {
if (!sync_loop_)
return;
- DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
+ DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
host_.Call(
FROM_HERE,
&SyncBackendHostImpl::HandleActionableErrorEventOnFrontendLoop,
@@ -340,7 +340,7 @@ void SyncBackendHostCore::OnActionableError(
}
void SyncBackendHostCore::OnMigrationRequested(syncer::ModelTypeSet types) {
- DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
+ DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
host_.Call(
FROM_HERE,
&SyncBackendHostImpl::HandleMigrationRequestedOnFrontendLoop,
@@ -361,13 +361,13 @@ void SyncBackendHostCore::OnProtocolEvent(
void SyncBackendHostCore::DoOnInvalidatorStateChange(
syncer::InvalidatorState state) {
- DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
+ DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
sync_manager_->SetInvalidatorEnabled(state == syncer::INVALIDATIONS_ENABLED);
}
void SyncBackendHostCore::DoOnIncomingInvalidation(
const syncer::ObjectIdInvalidationMap& invalidation_map) {
- DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
+ DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
syncer::ObjectIdSet ids = invalidation_map.GetObjectIds();
for (const invalidation::ObjectId& object_id : ids) {
@@ -463,7 +463,7 @@ void SyncBackendHostCore::DoInitialize(
void SyncBackendHostCore::DoUpdateCredentials(
const syncer::SyncCredentials& credentials) {
- DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
+ DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
// UpdateCredentials can be called during backend initialization, possibly
// when backend initialization has failed but hasn't notified the UI thread
// yet. In that case, the sync manager may have been destroyed on the sync
@@ -476,20 +476,20 @@ void SyncBackendHostCore::DoUpdateCredentials(
void SyncBackendHostCore::DoStartSyncing(
const syncer::ModelSafeRoutingInfo& routing_info,
base::Time last_poll_time) {
- DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
+ DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
sync_manager_->StartSyncingNormally(routing_info, last_poll_time);
}
void SyncBackendHostCore::DoSetEncryptionPassphrase(
const std::string& passphrase,
bool is_explicit) {
- DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
+ DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
sync_manager_->GetEncryptionHandler()->SetEncryptionPassphrase(
passphrase, is_explicit);
}
void SyncBackendHostCore::DoInitialProcessControlTypes() {
- DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
+ DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
DVLOG(1) << "Initilalizing Control Types";
@@ -528,13 +528,13 @@ void SyncBackendHostCore::DoInitialProcessControlTypes() {
void SyncBackendHostCore::DoSetDecryptionPassphrase(
const std::string& passphrase) {
- DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
+ DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
sync_manager_->GetEncryptionHandler()->SetDecryptionPassphrase(
passphrase);
}
void SyncBackendHostCore::DoEnableEncryptEverything() {
- DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
+ DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
sync_manager_->GetEncryptionHandler()->EnableEncryptEverything();
}
@@ -560,7 +560,7 @@ void SyncBackendHostCore::ShutdownOnUIThread() {
}
void SyncBackendHostCore::DoShutdown(syncer::ShutdownReason reason) {
- DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
+ DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
DoDestroySyncManager(reason);
@@ -574,7 +574,7 @@ void SyncBackendHostCore::DoShutdown(syncer::ShutdownReason reason) {
}
void SyncBackendHostCore::DoDestroySyncManager(syncer::ShutdownReason reason) {
- DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
+ DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
if (sync_manager_) {
DisableDirectoryTypeDebugInfoForwarding();
save_changes_timer_.reset();
@@ -591,7 +591,7 @@ void SyncBackendHostCore::DoConfigureSyncer(
const base::Callback<void(syncer::ModelTypeSet,
syncer::ModelTypeSet)>& ready_task,
const base::Closure& retry_callback) {
- DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
+ DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
DCHECK(!ready_task.is_null());
DCHECK(!retry_callback.is_null());
base::Closure chained_ready_task(
@@ -617,7 +617,7 @@ void SyncBackendHostCore::DoFinishConfigureDataTypes(
syncer::ModelTypeSet types_to_config,
const base::Callback<void(syncer::ModelTypeSet,
syncer::ModelTypeSet)>& ready_task) {
- DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
+ DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
// Update the enabled types for the bridge and sync manager.
syncer::ModelSafeRoutingInfo routing_info;
@@ -639,14 +639,14 @@ void SyncBackendHostCore::DoFinishConfigureDataTypes(
void SyncBackendHostCore::DoRetryConfiguration(
const base::Closure& retry_callback) {
- DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
+ DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
host_.Call(FROM_HERE,
&SyncBackendHostImpl::RetryConfigurationOnFrontendLoop,
retry_callback);
}
void SyncBackendHostCore::SendBufferedProtocolEventsAndEnableForwarding() {
- DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
+ DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
forward_protocol_events_ = true;
if (sync_manager_) {
@@ -694,7 +694,7 @@ void SyncBackendHostCore::DisableDirectoryTypeDebugInfoForwarding() {
}
void SyncBackendHostCore::DeleteSyncDataFolder() {
- DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
+ DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
if (base::DirectoryExists(sync_data_folder_path_)) {
if (!base::DeleteFile(sync_data_folder_path_, true))
SLOG(DFATAL) << "Could not delete the Sync Data folder.";
@@ -732,7 +732,7 @@ void SyncBackendHostCore::StartSavingChanges() {
// We may already be shut down.
if (!sync_loop_)
return;
- DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
+ DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
DCHECK(!save_changes_timer_.get());
save_changes_timer_.reset(new base::RepeatingTimer());
save_changes_timer_->Start(FROM_HERE,
@@ -741,13 +741,13 @@ void SyncBackendHostCore::StartSavingChanges() {
}
void SyncBackendHostCore::SaveChanges() {
- DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
+ DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
sync_manager_->SaveChanges();
}
void SyncBackendHostCore::DoClearServerData(
const syncer::SyncManager::ClearServerDataCallback& frontend_callback) {
- DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
+ DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
const syncer::SyncManager::ClearServerDataCallback callback =
base::Bind(&SyncBackendHostCore::ClearServerDataDone,
weak_ptr_factory_.GetWeakPtr(), frontend_callback);
@@ -756,13 +756,13 @@ void SyncBackendHostCore::DoClearServerData(
void SyncBackendHostCore::DoOnCookieJarChanged(bool account_mismatch,
bool empty_jar) {
- DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
+ DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
sync_manager_->OnCookieJarChanged(account_mismatch, empty_jar);
}
void SyncBackendHostCore::ClearServerDataDone(
const base::Closure& frontend_callback) {
- DCHECK_EQ(base::MessageLoop::current(), sync_loop_);
+ DCHECK(sync_loop_->task_runner()->BelongsToCurrentThread());
host_.Call(FROM_HERE, &SyncBackendHostImpl::ClearServerDataDoneOnFrontendLoop,
frontend_callback);
}
« no previous file with comments | « components/policy/core/browser/browser_policy_connector.cc ('k') | components/sync_driver/glue/sync_backend_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698