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 |