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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 ~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. |
87 // the android package name of external application that initiated the event. | |
88 void OnNavigationEvent(int32_t tab_id, | 87 void OnNavigationEvent(int32_t tab_id, |
89 TransitionType transition, | 88 TransitionType transition, |
90 const GURL& url, | 89 const GURL& url); |
91 const std::string& package); | |
92 | 90 |
93 // Notifies the DataUseTabModel that tab with |tab_id| is closed. Any active | 91 // Notifies the DataUseTabModel that tab with |tab_id| is closed. Any active |
94 // tracking sessions for the tab are terminated, and the tab is marked as | 92 // tracking sessions for the tab are terminated, and the tab is marked as |
95 // closed. | 93 // closed. |
96 void OnTabCloseEvent(int32_t tab_id); | 94 void OnTabCloseEvent(int32_t tab_id); |
97 | 95 |
98 // Gets the label for the |data_use| object. |output_label| must not be null. | 96 // Gets the label for the |data_use| object. |output_label| must not be null. |
99 // If a tab tracking session is found that was active at the time of request | 97 // If a tab tracking session is found that was active at the time of request |
100 // start of |data_use|, returns true and |output_label| is populated with its | 98 // start of |data_use|, returns true and |output_label| is populated with its |
101 // label. Otherwise returns false and |output_label| is set to empty string. | 99 // label. Otherwise returns false and |output_label| is set to empty string. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
145 // After removing expired tab entries, if the size of |active_tabs_| exceeds | 143 // After removing expired tab entries, if the size of |active_tabs_| exceeds |
146 // |kMaxTabEntries|, oldest unexpired tab entries will be removed until its | 144 // |kMaxTabEntries|, oldest unexpired tab entries will be removed until its |
147 // size is |kMaxTabEntries|. | 145 // size is |kMaxTabEntries|. |
148 void CompactTabEntries(); | 146 void CompactTabEntries(); |
149 | 147 |
150 // Contains the ExternalDataUseObserver. The caller must ensure that the | 148 // Contains the ExternalDataUseObserver. The caller must ensure that the |
151 // |data_use_observer_| outlives this instance. | 149 // |data_use_observer_| outlives this instance. |
152 const ExternalDataUseObserver* data_use_observer_; | 150 const ExternalDataUseObserver* data_use_observer_; |
153 | 151 |
154 // List of observers waiting for tracking session start and end notifications. | 152 // List of observers waiting for tracking session start and end notifications. |
155 const scoped_refptr<base::ObserverListThreadSafe<TabDataUseObserver>> | 153 const scoped_refptr<base::ObserverListThreadSafe<TabDataUseObserver>> |
sclittle
2015/11/17 22:50:11
nit: If you're certain that all observers will be
tbansal1
2015/11/18 01:32:22
Done.
| |
156 observer_list_; | 154 observer_list_; |
157 | 155 |
158 // Maintains the tracking sessions of multiple tabs. | 156 // Maintains the tracking sessions of multiple tabs. |
159 TabEntryMap active_tabs_; | 157 TabEntryMap active_tabs_; |
160 | 158 |
161 base::ThreadChecker thread_checker_; | 159 base::ThreadChecker thread_checker_; |
162 | 160 |
163 // |weak_factory_| is used for generating weak pointers to be passed to | 161 // |weak_factory_| is used for generating weak pointers to be passed to |
164 // DataUseTabUIManager on the UI thread. | 162 // DataUseTabUIManager on the UI thread. |
sclittle
2015/11/17 22:50:11
nit: What do you mean, passing the WeakPtrs to the
tbansal1
2015/11/18 01:32:22
Done.
| |
165 base::WeakPtrFactory<DataUseTabModel> weak_factory_; | 163 base::WeakPtrFactory<DataUseTabModel> weak_factory_; |
166 | 164 |
167 DISALLOW_COPY_AND_ASSIGN(DataUseTabModel); | 165 DISALLOW_COPY_AND_ASSIGN(DataUseTabModel); |
168 }; | 166 }; |
169 | 167 |
170 } // namespace android | 168 } // namespace android |
171 | 169 |
172 } // namespace chrome | 170 } // namespace chrome |
173 | 171 |
174 #endif // CHROME_BROWSER_ANDROID_DATA_USAGE_DATA_USE_TAB_MODEL_H_ | 172 #endif // CHROME_BROWSER_ANDROID_DATA_USAGE_DATA_USE_TAB_MODEL_H_ |
OLD | NEW |