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

Unified Diff: components/metrics/metrics_service.cc

Issue 2812083002: Skip collection and upload of metrics if offline.
Patch Set: Created 3 years, 8 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/metrics/metrics_service.cc
diff --git a/components/metrics/metrics_service.cc b/components/metrics/metrics_service.cc
index 529af17d829491521866ac870048baf24d07d1a7..afe3dce214d10fe7fab5ceb2509158eadd516e1d 100644
--- a/components/metrics/metrics_service.cc
+++ b/components/metrics/metrics_service.cc
@@ -157,6 +157,7 @@
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
#include "components/variations/entropy_provider.h"
+#include "net/base/network_change_notifier.h"
Steven Holte 2017/04/12 23:26:23 I don't think net/ is allowed here, so this probab
namespace metrics {
@@ -727,6 +728,12 @@ void MetricsService::StartScheduledUpload() {
return;
}
+ // Don't try to send existing logs or to collecting something new if there is
+ // no network connection. A cumulative log will be created at the next (or
+ // future) upload time when a network connection is available.
+ if (net::NetworkChangeNotifier::IsOffline())
Steven Holte 2017/04/12 23:11:37 You should call (or schedule a call to) rotation_s
Steven Holte 2017/04/12 23:26:23 Actually after rereading the code, this will also
bcwhite 2017/04/18 14:56:44 Sounds like it's not worth it, then. One (or even
+ return;
+
// If there are unsent logs, send the next one. If not, start the asynchronous
// process of finalizing the current log for upload.
if (state_ == SENDING_LOGS && has_unsent_logs()) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698