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

Unified Diff: components/invalidation/impl/gcm_invalidation_bridge.cc

Issue 2909113002: Deprecate NonThreadSafe in components/invalidation in favor of SequenceChecker. (Closed)
Patch Set: Created 3 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 side-by-side diff with in-line comments
Download patch
Index: components/invalidation/impl/gcm_invalidation_bridge.cc
diff --git a/components/invalidation/impl/gcm_invalidation_bridge.cc b/components/invalidation/impl/gcm_invalidation_bridge.cc
index c97ba93b14466dbedbc1d21c491859ce5c35b634..9909ef4ca4ed1a0a13dc2e44f8326b7cad9f90d5 100644
--- a/components/invalidation/impl/gcm_invalidation_bridge.cc
+++ b/components/invalidation/impl/gcm_invalidation_bridge.cc
@@ -35,8 +35,7 @@ const char kEchoTokenKey[] = "echo-token";
// Core should be very simple class that implements GCMNetwrokChannelDelegate
// and passes all calls to GCMInvalidationBridge. All calls should be serialized
// through GCMInvalidationBridge to avoid race conditions.
-class GCMInvalidationBridge::Core : public syncer::GCMNetworkChannelDelegate,
- public base::NonThreadSafe {
+class GCMInvalidationBridge::Core : public syncer::GCMNetworkChannelDelegate {
public:
Core(base::WeakPtr<GCMInvalidationBridge> bridge,
scoped_refptr<base::SingleThreadTaskRunner> ui_thread_task_runner);
@@ -72,6 +71,8 @@ class GCMInvalidationBridge::Core : public syncer::GCMNetworkChannelDelegate,
ConnectionStateCallback connection_state_callback_;
base::Closure store_reset_callback_;
+ SEQUENCE_CHECKER(sequence_checker_);
+
base::WeakPtrFactory<Core> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(Core);
@@ -84,7 +85,7 @@ GCMInvalidationBridge::Core::Core(
ui_thread_task_runner_(ui_thread_task_runner),
weak_factory_(this) {
// Core is created on UI thread but all calls happen on IO thread.
- DetachFromThread();
+ DETACH_FROM_SEQUENCE(sequence_checker_);
}
GCMInvalidationBridge::Core::~Core() {}
@@ -92,7 +93,7 @@ GCMInvalidationBridge::Core::~Core() {}
void GCMInvalidationBridge::Core::Initialize(
ConnectionStateCallback connection_state_callback,
base::Closure store_reset_callback) {
- DCHECK(CalledOnValidThread());
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
connection_state_callback_ = connection_state_callback;
store_reset_callback_ = store_reset_callback;
// Pass core WeapPtr and TaskRunner to GCMInvalidationBridge for it to be able
@@ -106,21 +107,21 @@ void GCMInvalidationBridge::Core::Initialize(
}
void GCMInvalidationBridge::Core::RequestToken(RequestTokenCallback callback) {
- DCHECK(CalledOnValidThread());
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
ui_thread_task_runner_->PostTask(
FROM_HERE,
base::Bind(&GCMInvalidationBridge::RequestToken, bridge_, callback));
}
void GCMInvalidationBridge::Core::InvalidateToken(const std::string& token) {
- DCHECK(CalledOnValidThread());
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
ui_thread_task_runner_->PostTask(
FROM_HERE,
base::Bind(&GCMInvalidationBridge::InvalidateToken, bridge_, token));
}
void GCMInvalidationBridge::Core::Register(RegisterCallback callback) {
- DCHECK(CalledOnValidThread());
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
ui_thread_task_runner_->PostTask(
FROM_HERE,
base::Bind(&GCMInvalidationBridge::Register, bridge_, callback));
@@ -138,7 +139,7 @@ void GCMInvalidationBridge::Core::RequestTokenFinished(
RequestTokenCallback callback,
const GoogleServiceAuthError& error,
const std::string& token) {
- DCHECK(CalledOnValidThread());
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
callback.Run(error, token);
}
@@ -146,7 +147,7 @@ void GCMInvalidationBridge::Core::RegisterFinished(
RegisterCallback callback,
const std::string& registration_id,
gcm::GCMClient::Result result) {
- DCHECK(CalledOnValidThread());
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
callback.Run(registration_id, result);
}
@@ -179,6 +180,7 @@ GCMInvalidationBridge::GCMInvalidationBridge(
weak_factory_(this) {}
GCMInvalidationBridge::~GCMInvalidationBridge() {
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (subscribed_for_incoming_messages_) {
gcm_driver_->RemoveAppHandler(kInvalidationsAppId);
gcm_driver_->RemoveConnectionObserver(this);
@@ -187,7 +189,7 @@ GCMInvalidationBridge::~GCMInvalidationBridge() {
std::unique_ptr<syncer::GCMNetworkChannelDelegate>
GCMInvalidationBridge::CreateDelegate() {
- DCHECK(CalledOnValidThread());
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return base::MakeUnique<Core>(weak_factory_.GetWeakPtr(),
base::ThreadTaskRunnerHandle::Get());
}
@@ -195,14 +197,14 @@ GCMInvalidationBridge::CreateDelegate() {
void GCMInvalidationBridge::CoreInitializationDone(
base::WeakPtr<Core> core,
scoped_refptr<base::SingleThreadTaskRunner> core_thread_task_runner) {
- DCHECK(CalledOnValidThread());
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
core_ = core;
core_thread_task_runner_ = core_thread_task_runner;
}
void GCMInvalidationBridge::RequestToken(
syncer::GCMNetworkChannelDelegate::RequestTokenCallback callback) {
- DCHECK(CalledOnValidThread());
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (access_token_request_ != NULL) {
// Report previous request as cancelled.
GoogleServiceAuthError error(GoogleServiceAuthError::REQUEST_CANCELED);
@@ -226,7 +228,7 @@ void GCMInvalidationBridge::OnGetTokenSuccess(
const OAuth2TokenService::Request* request,
const std::string& access_token,
const base::Time& expiration_time) {
- DCHECK(CalledOnValidThread());
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK_EQ(access_token_request_.get(), request);
core_thread_task_runner_->PostTask(
FROM_HERE,
@@ -242,7 +244,7 @@ void GCMInvalidationBridge::OnGetTokenSuccess(
void GCMInvalidationBridge::OnGetTokenFailure(
const OAuth2TokenService::Request* request,
const GoogleServiceAuthError& error) {
- DCHECK(CalledOnValidThread());
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK_EQ(access_token_request_.get(), request);
core_thread_task_runner_->PostTask(
FROM_HERE,
@@ -256,7 +258,7 @@ void GCMInvalidationBridge::OnGetTokenFailure(
}
void GCMInvalidationBridge::InvalidateToken(const std::string& token) {
- DCHECK(CalledOnValidThread());
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
OAuth2TokenService::ScopeSet scopes;
scopes.insert(GaiaConstants::kChromeSyncOAuth2Scope);
identity_provider_->GetTokenService()->InvalidateAccessToken(
@@ -265,7 +267,7 @@ void GCMInvalidationBridge::InvalidateToken(const std::string& token) {
void GCMInvalidationBridge::Register(
syncer::GCMNetworkChannelDelegate::RegisterCallback callback) {
- DCHECK(CalledOnValidThread());
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// No-op if GCMClient is disabled.
if (gcm_driver_ == NULL)
return;
@@ -283,7 +285,7 @@ void GCMInvalidationBridge::RegisterFinished(
syncer::GCMNetworkChannelDelegate::RegisterCallback callback,
const std::string& registration_id,
gcm::GCMClient::Result result) {
- DCHECK(CalledOnValidThread());
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
core_thread_task_runner_->PostTask(
FROM_HERE,
base::Bind(&GCMInvalidationBridge::Core::RegisterFinished,
@@ -294,7 +296,7 @@ void GCMInvalidationBridge::RegisterFinished(
}
void GCMInvalidationBridge::Unregister() {
- DCHECK(CalledOnValidThread());
+ DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// No-op if GCMClient is disabled.
if (gcm_driver_ == NULL)
return;
« no previous file with comments | « components/invalidation/impl/gcm_invalidation_bridge.h ('k') | components/invalidation/impl/gcm_network_channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698