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 |