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

Unified Diff: chrome/browser/android/data_usage/external_data_use_observer.h

Issue 1491793002: Add histograms for ExternalDataUseObserver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed sclittle comments Created 5 years 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: chrome/browser/android/data_usage/external_data_use_observer.h
diff --git a/chrome/browser/android/data_usage/external_data_use_observer.h b/chrome/browser/android/data_usage/external_data_use_observer.h
index 2cb052439b16fae87f43a9ca64799d17e8c52dd5..bb2bf463e549b93e52968c1b65e53499a8b1fac1 100644
--- a/chrome/browser/android/data_usage/external_data_use_observer.h
+++ b/chrome/browser/android/data_usage/external_data_use_observer.h
@@ -54,6 +54,20 @@ class DataUseTabModel;
// TODO(tbansal): Create an inner class that manages the UI and IO threads.
class ExternalDataUseObserver : public data_usage::DataUseAggregator::Observer {
public:
+ // Result of data usage report submission. This enum must remain synchronized
+ // with the enum of the same name in metrics/histograms/histograms.xml.
+ enum DataUsageReportSubmissionResult {
+ // Submission of data use report to the external observer was successful.
+ DATAUSAGE_REPORT_SUBMISSION_SUCCESSFUL = 0,
+ // Submission of data use report to the external observer returned error.
+ DATAUSAGE_REPORT_SUBMISSION_FAILED = 1,
+ // Submission of data use report to the external observer timed out.
+ DATAUSAGE_REPORT_SUBMISSION_TIMED_OUT = 2,
+ // Data use report was lost before an attempt was made to submit it.
+ DATAUSAGE_REPORT_SUBMISSION_LOST = 3,
+ DATAUSAGE_REPORT_SUBMISSION_MAX = 4
+ };
+
// External data use observer field trial name.
static const char kExternalDataUseObserverFieldTrial[];
@@ -103,10 +117,10 @@ class ExternalDataUseObserver : public data_usage::DataUseAggregator::Observer {
private:
friend class DataUseTabModelTest;
friend class ExternalDataUseObserverTest;
- FRIEND_TEST_ALL_PREFIXES(DataUseUITabModelTest, ReportTabEventsTest);
FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, BufferDataUseReports);
FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, BufferSize);
FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, ChangeRegex);
+ FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, DataUseReportTimedOut);
FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, HashFunction);
FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, LabelRemoved);
FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, MultipleMatchingRules);
@@ -114,6 +128,7 @@ class ExternalDataUseObserver : public data_usage::DataUseAggregator::Observer {
FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest,
PeriodicFetchMatchingRules);
FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, ReportsMergedCorrectly);
+ FRIEND_TEST_ALL_PREFIXES(DataUseUITabModelTest, ReportTabEventsTest);
FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, SingleRegex);
FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest,
TimestampsMergedCorrectly);
@@ -279,8 +294,14 @@ class ExternalDataUseObserver : public data_usage::DataUseAggregator::Observer {
// True if callback from |FetchMatchingRulesDone| is currently pending.
bool matching_rules_fetch_pending_;
- // True if callback from |SubmitDataUseReportCallback| is currently pending.
- bool submit_data_report_pending_;
+ // Time when the currently pending data use report was submitted.
+ // |last_data_report_submitted_ticks_| is null if no data use report is
+ // currently pending.
+ base::TimeTicks last_data_report_submitted_ticks_;
+
+ // |pending_report_bytes_| is the total byte count in the data use report that
+ // is currently pending.
+ int64_t pending_report_bytes_;
// Contains matching rules.
std::vector<scoped_ptr<MatchingRule>> matching_rules_;
@@ -317,6 +338,10 @@ class ExternalDataUseObserver : public data_usage::DataUseAggregator::Observer {
// submitted.
const int64_t data_use_report_min_bytes_;
+ // If a data use report is pending for more than |data_report_submit_timeout_|
+ // duration, it is considered as timed out.
+ const base::TimeDelta data_report_submit_timeout_;
+
base::ThreadChecker thread_checker_;
// |io_weak_factory_| and |ui_weak_factory_| are used for posting tasks on the

Powered by Google App Engine
This is Rietveld 408576698