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

Unified Diff: components/invalidation/gcm_network_channel.cc

Issue 334253006: Notify SyncNetworkChannel about GCM connection state (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed typo Created 6 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/invalidation/gcm_network_channel.cc
diff --git a/components/invalidation/gcm_network_channel.cc b/components/invalidation/gcm_network_channel.cc
index 7ee08af685af0eabe9fd275be41420d03a05919b..43081b9fb934902531e62a2aa9821446578c1bff 100644
--- a/components/invalidation/gcm_network_channel.cc
+++ b/components/invalidation/gcm_network_channel.cc
@@ -110,7 +110,8 @@ GCMNetworkChannel::GCMNetworkChannel(
diagnostic_info_(this),
weak_factory_(this) {
net::NetworkChangeNotifier::AddNetworkChangeObserver(this);
- delegate_->Initialize();
+ delegate_->Initialize(base::Bind(&GCMNetworkChannel::OnConnectionStateChanged,
+ weak_factory_.GetWeakPtr()));
Register();
}
@@ -283,6 +284,24 @@ void GCMNetworkChannel::OnIncomingMessage(const std::string& message,
#endif
}
+void GCMNetworkChannel::OnConnectionStateChanged(
+ GCMNetworkChannelDelegate::ConnectionState connection_state) {
+ switch (connection_state) {
+ case GCMNetworkChannelDelegate::CONNECTION_STATE_OFFLINE: {
+ NotifyStateChange(TRANSIENT_INVALIDATION_ERROR);
+ break;
+ }
+ case GCMNetworkChannelDelegate::CONNECTION_STATE_ONLINE: {
+ NotifyStateChange(INVALIDATIONS_ENABLED);
+ break;
+ }
+ default: {
+ NOTREACHED();
+ break;
+ }
+ }
+}
+
void GCMNetworkChannel::OnNetworkChanged(
net::NetworkChangeNotifier::ConnectionType connection_type) {
// Network connection is restored. Let's notify cacheinvalidations so it has
« no previous file with comments | « components/invalidation/gcm_network_channel.h ('k') | components/invalidation/gcm_network_channel_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698