| 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> |
| 11 | 11 |
| 12 #include "base/containers/hash_tables.h" | 12 #include "base/containers/hash_tables.h" |
| 13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/observer_list_threadsafe.h" | 17 #include "base/observer_list_threadsafe.h" |
| 18 #include "base/threading/thread_checker.h" | 18 #include "base/threading/thread_checker.h" |
| 19 #include "base/time/time.h" |
| 19 #include "chrome/browser/android/data_usage/tab_data_use_entry.h" | 20 #include "chrome/browser/android/data_usage/tab_data_use_entry.h" |
| 20 #include "components/data_usage/core/data_use.h" | 21 #include "components/data_usage/core/data_use.h" |
| 21 #include "url/gurl.h" | 22 #include "url/gurl.h" |
| 22 | 23 |
| 23 namespace chrome { | 24 namespace chrome { |
| 24 | 25 |
| 25 namespace android { | 26 namespace android { |
| 26 | 27 |
| 27 class ExternalDataUseObserver; | 28 class ExternalDataUseObserver; |
| 28 | 29 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, MultipleTabTracking); | 120 FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, MultipleTabTracking); |
| 120 FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, ObserverStartEndEvents); | 121 FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, ObserverStartEndEvents); |
| 121 FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, ObserverNotNotifiedAfterRemove); | 122 FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, ObserverNotNotifiedAfterRemove); |
| 122 FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, | 123 FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, |
| 123 MultipleObserverMultipleStartEndEvents); | 124 MultipleObserverMultipleStartEndEvents); |
| 124 FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, TabCloseEvent); | 125 FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, TabCloseEvent); |
| 125 FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, TabCloseEventEndsTracking); | 126 FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, TabCloseEventEndsTracking); |
| 126 FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, OnTrackingLabelRemoved); | 127 FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, OnTrackingLabelRemoved); |
| 127 FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, | 128 FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, |
| 128 CompactTabEntriesWithinMaxLimit); | 129 CompactTabEntriesWithinMaxLimit); |
| 130 FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, |
| 131 UnexpiredTabEntryRemovaltimeHistogram); |
| 132 FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, |
| 133 ExpiredInactiveTabEntryRemovaltimeHistogram); |
| 134 FRIEND_TEST_ALL_PREFIXES(DataUseTabModelTest, |
| 135 ExpiredActiveTabEntryRemovaltimeHistogram); |
| 129 | 136 |
| 130 typedef base::hash_map<int32_t, TabDataUseEntry> TabEntryMap; | 137 typedef base::hash_map<int32_t, TabDataUseEntry> TabEntryMap; |
| 131 | 138 |
| 139 // Virtualized for unit test support. |
| 140 virtual base::TimeTicks Now() const; |
| 141 |
| 132 // Notifies the observers that a data usage tracking session started for | 142 // Notifies the observers that a data usage tracking session started for |
| 133 // |tab_id|. | 143 // |tab_id|. |
| 134 void NotifyObserversOfTrackingStarting(int32_t tab_id); | 144 void NotifyObserversOfTrackingStarting(int32_t tab_id); |
| 135 | 145 |
| 136 // Notifies the observers that an active data usage tracking session ended for | 146 // Notifies the observers that an active data usage tracking session ended for |
| 137 // |tab_id|. | 147 // |tab_id|. |
| 138 void NotifyObserversOfTrackingEnding(int32_t tab_id); | 148 void NotifyObserversOfTrackingEnding(int32_t tab_id); |
| 139 | 149 |
| 140 // Initiates a new tracking session with the |label| for tab with id |tab_id|. | 150 // Initiates a new tracking session with the |label| for tab with id |tab_id|. |
| 141 void StartTrackingDataUse(int32_t tab_id, const std::string& label); | 151 void StartTrackingDataUse(int32_t tab_id, const std::string& label); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 170 base::WeakPtrFactory<DataUseTabModel> weak_factory_; | 180 base::WeakPtrFactory<DataUseTabModel> weak_factory_; |
| 171 | 181 |
| 172 DISALLOW_COPY_AND_ASSIGN(DataUseTabModel); | 182 DISALLOW_COPY_AND_ASSIGN(DataUseTabModel); |
| 173 }; | 183 }; |
| 174 | 184 |
| 175 } // namespace android | 185 } // namespace android |
| 176 | 186 |
| 177 } // namespace chrome | 187 } // namespace chrome |
| 178 | 188 |
| 179 #endif // CHROME_BROWSER_ANDROID_DATA_USAGE_DATA_USE_TAB_MODEL_H_ | 189 #endif // CHROME_BROWSER_ANDROID_DATA_USAGE_DATA_USE_TAB_MODEL_H_ |
| OLD | NEW |