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

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

Issue 1544633002: Submit buffered data use reports when Chromium is backgrounded (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 76584900fd8017e1f10041962c8ca5278535fe0d..a2521bedb426401dc4283849b787f95908c4561f 100644
--- a/chrome/browser/android/data_usage/external_data_use_observer.h
+++ b/chrome/browser/android/data_usage/external_data_use_observer.h
@@ -21,6 +21,10 @@
#include "components/data_usage/core/data_use_aggregator.h"
#include "net/base/network_change_notifier.h"
+#if defined(OS_ANDROID)
+#include "base/android/application_status_listener.h"
+#endif
+
namespace base {
class SingleThreadTaskRunner;
}
@@ -77,6 +81,12 @@ class ExternalDataUseObserver : public data_usage::DataUseAggregator::Observer {
// successfully submitted to the external data use observer by Java.
void OnReportDataUseDone(bool success);
+#if defined(OS_ANDROID)
+ // Called whenever the application transitions from foreground to background
+ // and vice versa.
+ void OnApplicationStateChange(base::android::ApplicationState new_state);
tbansal1 2015/12/21 21:03:24 Does this method need to be public?
Raj 2015/12/29 23:17:35 Done.
+#endif
+
// Called by DataUseMatcher. |should_register| is true if |this| should
// register as a data use observer.
void ShouldRegisterAsDataUseObserver(bool should_register);
@@ -190,8 +200,10 @@ class ExternalDataUseObserver : public data_usage::DataUseAggregator::Observer {
// |buffered_data_reports_|. Since an unordered map is used to buffer the
// reports, the order of reports may change. The reports are buffered in an
// arbitrary order and there are no guarantees that the next report to be
- // submitted is the oldest one buffered.
- void SubmitBufferedDataUseReport();
+ // submitted is the oldest one buffered. |immediate| indicates whether to
+ // submit the report immediately or to wait until |data_use_report_min_bytes_|
+ // unreported bytes are buffered.
+ void SubmitBufferedDataUseReport(bool immediate);
// Aggregator that sends data use observations to |this|.
data_usage::DataUseAggregator* data_use_aggregator_;
@@ -242,6 +254,12 @@ class ExternalDataUseObserver : public data_usage::DataUseAggregator::Observer {
// duration, it is considered as timed out.
const base::TimeDelta data_report_submit_timeout_;
+#if defined(OS_ANDROID)
+ // ApplicationStatusListener used to listen when Chromium gets backgrounded
+ // and submit buffered data use reports.
+ scoped_ptr<base::android::ApplicationStatusListener> app_state_listener_;
+#endif
+
// True if |this| is currently registered as a data use observer.
bool registered_as_data_use_observer_;

Powered by Google App Engine
This is Rietveld 408576698