Index: chrome/browser/android/data_usage/data_use_tab_model.h |
diff --git a/chrome/browser/android/data_usage/data_use_tab_model.h b/chrome/browser/android/data_usage/data_use_tab_model.h |
index 2d71ffac0dde7f3d96058f6f58d090ee694ed49b..bed0ff823525b320b52c748dbae73264430ec186 100644 |
--- a/chrome/browser/android/data_usage/data_use_tab_model.h |
+++ b/chrome/browser/android/data_usage/data_use_tab_model.h |
@@ -187,15 +187,41 @@ class DataUseTabModel { |
FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, |
MultipleObserverMultipleStartEndEvents); |
FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, ObserverStartEndEvents); |
+ FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, |
+ ProcessBufferedNavigationEventsAfterRuleFetch); |
FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, TabCloseEvent); |
FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, TabCloseEventEndsTracking); |
FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, |
UnexpiredTabEntryRemovaltimeHistogram); |
FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, |
MatchingRuleFetchOnControlAppInstall); |
+ FRIEND_TEST_ALL_PREFIXES( |
+ ExternalDataUseObserverTest, |
+ ProcessBufferedNavigationEventsAfterControlAppNotInstalled); |
+ FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, |
+ ProcessBufferedNavigationEventsAfterRuleFetch); |
+ FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, |
+ ProcessBufferedNavigationEventsAfterMaxLimit); |
typedef base::hash_map<SessionID::id_type, TabDataUseEntry> TabEntryMap; |
+ // Contains the details of a single UI navigation event. |
+ struct DataUseUINavigationEvent { |
+ DataUseUINavigationEvent(SessionID::id_type tab_id, |
+ TransitionType transition_type, |
+ GURL url, |
+ std::string package) |
+ : tab_id(tab_id), |
+ transition_type(transition_type), |
+ url(url), |
+ package(package) {} |
+ |
+ const SessionID::id_type tab_id; |
+ const TransitionType transition_type; |
+ const GURL url; |
+ const std::string package; |
+ }; |
+ |
// Gets the current label of a tab, and the new label if a navigation event |
// occurs in the tab. |tab_id| is the source tab of the generated event, |
// |transition| indicates the type of the UI event/transition, |url| is the |
@@ -231,6 +257,11 @@ class DataUseTabModel { |
// size is |kMaxTabEntries|. |
void CompactTabEntries(); |
+ // Processes the UI navigation events buffered in |data_use_ui_navigations_| |
+ // and deletes the vector in |data_use_ui_navigations_| so that navigation |
+ // events will not be buffered any more. |
+ void ProcessBufferedNavigationEvents(); |
+ |
// Collection of observers that receive tracking session start and end |
// notifications. Notifications are posted on UI thread. |
base::ObserverList<TabDataUseObserver> observers_; |
@@ -258,6 +289,15 @@ class DataUseTabModel { |
// True if the external control app is installed. |
bool is_control_app_installed_; |
+ // Buffer of UI navigation events that occurred until the first rule fetch is |
+ // complete or the control app not installed callback was received or until |
+ // |kDefaultMaxNavigationEventsBuffered| navigation events were buffered, |
+ // whichever occurs first. Existence of the vector in scoped_ptr indicates if |
+ // the UI navigation events need to be buffered. If the scoped_ptr contains a |
+ // vector all navigation events will be added to it. Otherwise all navigation |
+ // events will be processed immediately. |
+ scoped_ptr<std::vector<DataUseUINavigationEvent>> data_use_ui_navigations_; |
+ |
base::ThreadChecker thread_checker_; |
base::WeakPtrFactory<DataUseTabModel> weak_factory_; |