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

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

Issue 1443683002: Notify DataUseTabModel of navigations and tab closures (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased, addressed comments Created 5 years, 1 month 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 43a07bdb110c5a8ac329cb20af38617e10afe9e3..8789d41bbf8df177c91afeeabd9f023b52d64433 100644
--- a/chrome/browser/android/data_usage/data_use_tab_model.h
+++ b/chrome/browser/android/data_usage/data_use_tab_model.h
@@ -14,7 +14,7 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
-#include "base/observer_list_threadsafe.h"
+#include "base/observer_list.h"
#include "base/threading/thread_checker.h"
#include "chrome/browser/android/data_usage/tab_data_use_entry.h"
#include "components/data_usage/core/data_use.h"
@@ -83,12 +83,10 @@ class DataUseTabModel {
// Notifies the DataUseTabModel of navigation events. |tab_id| is the source
// tab of the generated event, |transition| indicates the type of the UI
- // event/transition, |url| is the URL in the source tab, |package| indicates
- // the android package name of external application that initiated the event.
+ // event/transition, |url| is the URL in the source tab.
void OnNavigationEvent(int32_t tab_id,
TransitionType transition,
- const GURL& url,
- const std::string& package);
+ const GURL& url);
// Notifies the DataUseTabModel that tab with |tab_id| is closed. Any active
// tracking sessions for the tab are terminated, and the tab is marked as
@@ -102,11 +100,20 @@ class DataUseTabModel {
bool GetLabelForDataUse(const data_usage::DataUse& data_use,
std::string* output_label) const;
- // Adds or removes observers from the observer list. These functions are
- // thread-safe and can be called from any thread.
+ // Adds or removes observers from the observer list. Must be called only on
+ // IO thread.
void AddObserver(TabDataUseObserver* observer);
void RemoveObserver(TabDataUseObserver* observer);
+ protected:
+ // Notifies the observers that a data usage tracking session started for
+ // |tab_id|. Protected for testing.
+ void NotifyObserversOfTrackingStarting(int32_t tab_id);
+
+ // Notifies the observers that an active data usage tracking session ended for
+ // |tab_id|. Protected for testing.
+ void NotifyObserversOfTrackingEnding(int32_t tab_id);
+
private:
friend class DataUseTabModelTest;
friend class MockTabDataUseEntryTest;
@@ -127,14 +134,6 @@ class DataUseTabModel {
// about.
static size_t GetMaxTabEntriesForTests();
- // Notifies the observers that a data usage tracking session started for
- // |tab_id|.
- void NotifyObserversOfTrackingStarting(int32_t tab_id);
-
- // Notifies the observers that an active data usage tracking session ended for
- // |tab_id|.
- void NotifyObserversOfTrackingEnding(int32_t tab_id);
-
// Initiates a new tracking session with the |label| for tab with id |tab_id|.
void StartTrackingDataUse(int32_t tab_id, const std::string& label);
@@ -152,16 +151,13 @@ class DataUseTabModel {
const ExternalDataUseObserver* data_use_observer_;
// List of observers waiting for tracking session start and end notifications.
- const scoped_refptr<base::ObserverListThreadSafe<TabDataUseObserver>>
- observer_list_;
+ base::ObserverList<TabDataUseObserver> observer_list_;
// Maintains the tracking sessions of multiple tabs.
TabEntryMap active_tabs_;
base::ThreadChecker thread_checker_;
- // |weak_factory_| is used for generating weak pointers to be passed to
- // DataUseTabUIManager on the UI thread.
base::WeakPtrFactory<DataUseTabModel> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(DataUseTabModel);

Powered by Google App Engine
This is Rietveld 408576698