Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_ANDROID_DATA_USAGE_DATA_USE_TAB_MODEL_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_DATA_USAGE_DATA_USE_TAB_MODEL_H_ |
| 6 #define CHROME_BROWSER_ANDROID_DATA_USAGE_DATA_USE_TAB_MODEL_H_ | 6 #define CHROME_BROWSER_ANDROID_DATA_USAGE_DATA_USE_TAB_MODEL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 // Notification callback when tab tracking sessions are started and ended. | 70 // Notification callback when tab tracking sessions are started and ended. |
| 71 // The callback will be received on the same thread AddObserver was called | 71 // The callback will be received on the same thread AddObserver was called |
| 72 // from. | 72 // from. |
| 73 virtual void NotifyTrackingStarting(int32_t tab_id) = 0; | 73 virtual void NotifyTrackingStarting(int32_t tab_id) = 0; |
| 74 virtual void NotifyTrackingEnding(int32_t tab_id) = 0; | 74 virtual void NotifyTrackingEnding(int32_t tab_id) = 0; |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 DataUseTabModel(const ExternalDataUseObserver* data_use_observer, | 77 DataUseTabModel(const ExternalDataUseObserver* data_use_observer, |
| 78 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); | 78 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); |
| 79 | 79 |
| 80 ~DataUseTabModel(); | 80 virtual ~DataUseTabModel(); |
| 81 | 81 |
| 82 base::WeakPtr<DataUseTabModel> GetWeakPtr(); | 82 base::WeakPtr<DataUseTabModel> GetWeakPtr(); |
| 83 | 83 |
| 84 // Notifies the DataUseTabModel of navigation events. |tab_id| is the source | 84 // Notifies the DataUseTabModel of navigation events. |tab_id| is the source |
| 85 // tab of the generated event, |transition| indicates the type of the UI | 85 // tab of the generated event, |transition| indicates the type of the UI |
| 86 // event/transition, |url| is the URL in the source tab, |package| indicates | 86 // event/transition, |url| is the URL in the source tab, |package| indicates |
| 87 // the android package name of external application that initiated the event. | 87 // the android package name of external application that initiated the event. |
| 88 void OnNavigationEvent(int32_t tab_id, | 88 void OnNavigationEvent(int32_t tab_id, |
| 89 TransitionType transition, | 89 TransitionType transition, |
| 90 const GURL& url, | 90 const GURL& url, |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 103 std::string* output_label) const; | 103 std::string* output_label) const; |
| 104 | 104 |
| 105 // Adds or removes observers from the observer list. These functions are | 105 // Adds or removes observers from the observer list. These functions are |
| 106 // thread-safe and can be called from any thread. | 106 // thread-safe and can be called from any thread. |
| 107 void AddObserver(TabDataUseObserver* observer); | 107 void AddObserver(TabDataUseObserver* observer); |
| 108 void RemoveObserver(TabDataUseObserver* observer); | 108 void RemoveObserver(TabDataUseObserver* observer); |
| 109 | 109 |
| 110 private: | 110 private: |
| 111 friend class DataUseTabModelTest; | 111 friend class DataUseTabModelTest; |
| 112 friend class MockTabDataUseEntryTest; | 112 friend class MockTabDataUseEntryTest; |
| 113 FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, SingleTabTracking); | |
| 114 FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, MultipleTabTracking); | |
| 115 FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, ObserverStartEndEvents); | |
| 116 FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, ObserverNotNotifiedAfterRemove); | |
| 117 FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, | |
| 118 MultipleObserverMultipleStartEndEvents); | |
| 119 FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, TabCloseEvent); | 113 FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, TabCloseEvent); |
| 120 FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, TabCloseEventEndsTracking); | 114 FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, TabCloseEventEndsTracking); |
| 121 FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, | 115 FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, |
| 122 CompactTabEntriesWithinMaxLimit); | 116 CompactTabEntriesWithinMaxLimit); |
| 117 FRIEND_TEST_ALL_PREFIXES(MockDataUseTabModelTest, | |
| 118 UnexpiredTabEntryRemovaltimeHistogram); | |
| 119 FRIEND_TEST_ALL_PREFIXES(MockDataUseTabModelTest, | |
| 120 ExpiredInactiveTabEntryRemovaltimeHistogram); | |
| 121 FRIEND_TEST_ALL_PREFIXES(MockDataUseTabModelTest, | |
| 122 ExpiredActiveTabEntryRemovaltimeHistogram); | |
| 123 | 123 |
| 124 typedef base::hash_map<int32_t, TabDataUseEntry> TabEntryMap; | 124 typedef base::hash_map<int32_t, TabDataUseEntry> TabEntryMap; |
| 125 | 125 |
| 126 // Virtualized for unit test support. | |
| 127 virtual base::TimeTicks Now() const; | |
|
tbansal1
2015/11/16 17:17:38
#include base/time/time.h
and remove the include f
Raj
2015/11/16 20:09:36
Done.
| |
| 128 | |
| 126 // Returns the maximum number of tab entries to maintain session information | 129 // Returns the maximum number of tab entries to maintain session information |
| 127 // about. | 130 // about. |
| 128 static size_t GetMaxTabEntriesForTests(); | 131 static size_t GetMaxTabEntriesForTests(); |
| 129 | 132 |
| 130 // Notifies the observers that a data usage tracking session started for | 133 // Notifies the observers that a data usage tracking session started for |
| 131 // |tab_id|. | 134 // |tab_id|. |
| 132 void NotifyObserversOfTrackingStarting(int32_t tab_id); | 135 void NotifyObserversOfTrackingStarting(int32_t tab_id); |
| 133 | 136 |
| 134 // Notifies the observers that an active data usage tracking session ended for | 137 // Notifies the observers that an active data usage tracking session ended for |
| 135 // |tab_id|. | 138 // |tab_id|. |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 165 base::WeakPtrFactory<DataUseTabModel> weak_factory_; | 168 base::WeakPtrFactory<DataUseTabModel> weak_factory_; |
| 166 | 169 |
| 167 DISALLOW_COPY_AND_ASSIGN(DataUseTabModel); | 170 DISALLOW_COPY_AND_ASSIGN(DataUseTabModel); |
| 168 }; | 171 }; |
| 169 | 172 |
| 170 } // namespace android | 173 } // namespace android |
| 171 | 174 |
| 172 } // namespace chrome | 175 } // namespace chrome |
| 173 | 176 |
| 174 #endif // CHROME_BROWSER_ANDROID_DATA_USAGE_DATA_USE_TAB_MODEL_H_ | 177 #endif // CHROME_BROWSER_ANDROID_DATA_USAGE_DATA_USE_TAB_MODEL_H_ |
| OLD | NEW |