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

Unified Diff: sync/notifier/gcm_network_channel.cc

Issue 215073005: Notify cacheinvalidations about network status (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 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
« no previous file with comments | « sync/notifier/gcm_network_channel.h ('k') | sync/notifier/gcm_network_channel_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/notifier/gcm_network_channel.cc
diff --git a/sync/notifier/gcm_network_channel.cc b/sync/notifier/gcm_network_channel.cc
index 0badd3f26273b364199d049dda04a8571c7ed3d9..3805d0c9508d1f351d87bbb4ad795ece9781f150 100644
--- a/sync/notifier/gcm_network_channel.cc
+++ b/sync/notifier/gcm_network_channel.cc
@@ -155,11 +155,13 @@ GCMNetworkChannel::GCMNetworkChannel(
register_backoff_entry_(new net::BackoffEntry(&kRegisterBackoffPolicy)),
diagnostic_info_(this),
weak_factory_(this) {
+ net::NetworkChangeNotifier::AddNetworkChangeObserver(this);
delegate_->Initialize();
Register();
}
GCMNetworkChannel::~GCMNetworkChannel() {
+ net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
}
void GCMNetworkChannel::UpdateCredentials(
@@ -261,6 +263,10 @@ void GCMNetworkChannel::OnGetTokenComplete(
// sending message and at that time we'll retry requesting access token.
DVLOG(1) << "RequestAccessToken failed: " << error.ToString();
RecordOutgoingMessageStatus(ACCESS_TOKEN_FAILURE);
+ // Message won't get sent because of connection failure. Let's retry once
+ // connection is restored.
+ if (error.state() == GoogleServiceAuthError::CONNECTION_FAILED)
+ NotifyStateChange(TRANSIENT_INVALIDATION_ERROR);
cached_message_.clear();
return;
}
@@ -337,13 +343,23 @@ void GCMNetworkChannel::OnURLFetchComplete(const net::URLFetcher* source) {
fetcher->GetResponseCode() != net::HTTP_NO_CONTENT)) {
DVLOG(1) << "URLFetcher failure";
RecordOutgoingMessageStatus(POST_FAILURE);
+ NotifyStateChange(TRANSIENT_INVALIDATION_ERROR);
return;
}
RecordOutgoingMessageStatus(OUTGOING_MESSAGE_SUCCESS);
+ NotifyStateChange(INVALIDATIONS_ENABLED);
DVLOG(2) << "URLFetcher success";
}
+void GCMNetworkChannel::OnNetworkChanged(
+ net::NetworkChangeNotifier::ConnectionType connection_type) {
+ // Network connection is restored. Let's notify cacheinvalidations so it has
+ // chance to retry.
+ if (connection_type != net::NetworkChangeNotifier::CONNECTION_NONE)
+ NotifyStateChange(INVALIDATIONS_ENABLED);
+}
+
GURL GCMNetworkChannel::BuildUrl(const std::string& registration_id) {
DCHECK(!registration_id.empty());
« no previous file with comments | « sync/notifier/gcm_network_channel.h ('k') | sync/notifier/gcm_network_channel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698