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

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

Issue 1837223002: Buffer UI navigation events in DataUseTabModel until rule fetch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed tbansal comments Created 4 years, 9 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
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..2b3be0b2d08ca70602d7650b58d9eb836cc27d9d 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 releases the vector in |data_use_ui_navigations_| so that navigation
tbansal1 2016/03/29 18:19:04 s/releases/deletes/
Raj 2016/03/29 19:45:54 Done.
+ // 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_;
+ // Buffers of UI navigation events that occurred until the first rule fetch is
tbansal1 2016/03/29 18:19:03 s/Buffers/Buffer/ IIUC, this is a single buffer th
Raj 2016/03/29 19:45:54 Done.
+ // 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_;

Powered by Google App Engine
This is Rietveld 408576698