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

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

Issue 2473813002: Notify GCMAppHandlers when the store is reset, so they clear cached IDs (Closed)
Patch Set: Update Cryptauth comment Created 4 years, 1 month 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 09aca1e3991a2ec7e6b8a5ab57de62f236d9a7b1..c97ba93b14466dbedbc1d21c491859ce5c35b634 100644
--- a/components/invalidation/impl/gcm_invalidation_bridge.cc
+++ b/components/invalidation/impl/gcm_invalidation_bridge.cc
@@ -43,7 +43,8 @@ class GCMInvalidationBridge::Core : public syncer::GCMNetworkChannelDelegate,
~Core() override;
// syncer::GCMNetworkChannelDelegate implementation.
- void Initialize(ConnectionStateCallback callback) override;
+ void Initialize(ConnectionStateCallback connection_state_callback,
+ base::Closure store_reset_callback) override;
void RequestToken(RequestTokenCallback callback) override;
void InvalidateToken(const std::string& token) override;
void Register(RegisterCallback callback) override;
@@ -61,6 +62,7 @@ class GCMInvalidationBridge::Core : public syncer::GCMNetworkChannelDelegate,
const std::string& echo_token);
void OnConnectionStateChanged(bool online);
+ void OnStoreReset();
private:
base::WeakPtr<GCMInvalidationBridge> bridge_;
@@ -68,6 +70,7 @@ class GCMInvalidationBridge::Core : public syncer::GCMNetworkChannelDelegate,
MessageCallback message_callback_;
ConnectionStateCallback connection_state_callback_;
+ base::Closure store_reset_callback_;
base::WeakPtrFactory<Core> weak_factory_;
@@ -86,9 +89,12 @@ GCMInvalidationBridge::Core::Core(
GCMInvalidationBridge::Core::~Core() {}
-void GCMInvalidationBridge::Core::Initialize(ConnectionStateCallback callback) {
+void GCMInvalidationBridge::Core::Initialize(
+ ConnectionStateCallback connection_state_callback,
+ base::Closure store_reset_callback) {
DCHECK(CalledOnValidThread());
- connection_state_callback_ = callback;
+ connection_state_callback_ = connection_state_callback;
+ store_reset_callback_ = store_reset_callback;
// Pass core WeapPtr and TaskRunner to GCMInvalidationBridge for it to be able
// to post back.
ui_thread_task_runner_->PostTask(
@@ -157,6 +163,12 @@ void GCMInvalidationBridge::Core::OnConnectionStateChanged(bool online) {
}
}
+void GCMInvalidationBridge::Core::OnStoreReset() {
+ if (!store_reset_callback_.is_null()) {
+ store_reset_callback_.Run();
+ }
+}
+
GCMInvalidationBridge::GCMInvalidationBridge(
gcm::GCMDriver* gcm_driver,
IdentityProvider* identity_provider)
@@ -319,6 +331,11 @@ void GCMInvalidationBridge::ShutdownHandler() {
// Nothing to do.
}
+void GCMInvalidationBridge::OnStoreReset() {
+ core_thread_task_runner_->PostTask(
+ FROM_HERE, base::Bind(&GCMInvalidationBridge::Core::OnStoreReset, core_));
+}
+
void GCMInvalidationBridge::OnMessage(const std::string& app_id,
const gcm::IncomingMessage& message) {
gcm::MessageData::const_iterator it;

Powered by Google App Engine
This is Rietveld 408576698