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 <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/containers/hash_tables.h" | 13 #include "base/containers/hash_tables.h" |
14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
tbansal1
2016/03/10 01:00:57
Is this include still needed?
Raj
2016/03/10 02:13:34
Done.
| |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "base/observer_list.h" | 19 #include "base/observer_list.h" |
20 #include "base/threading/thread_checker.h" | 20 #include "base/threading/thread_checker.h" |
21 #include "base/time/time.h" | 21 #include "base/time/time.h" |
22 #include "chrome/browser/android/data_usage/tab_data_use_entry.h" | 22 #include "chrome/browser/android/data_usage/tab_data_use_entry.h" |
23 #include "components/sessions/core/session_id.h" | 23 #include "components/sessions/core/session_id.h" |
24 #include "url/gurl.h" | |
24 | 25 |
25 namespace base { | 26 namespace base { |
26 class SingleThreadTaskRunner; | 27 class SingleThreadTaskRunner; |
27 class TickClock; | 28 class TickClock; |
28 } | 29 } |
29 | 30 |
30 class GURL; | |
31 | |
32 namespace chrome { | 31 namespace chrome { |
33 | 32 |
34 namespace android { | 33 namespace android { |
35 | 34 |
36 class DataUseMatcher; | 35 class DataUseMatcher; |
37 class ExternalDataUseObserver; | 36 class ExternalDataUseObserverBridge; |
38 | 37 |
39 // Models tracking and labeling of data usage within each Tab. Within each tab, | 38 // Models tracking and labeling of data usage within each Tab. Within each tab, |
40 // the model tracks the data use of a sequence of navigations in a "tracking | 39 // the model tracks the data use of a sequence of navigations in a "tracking |
41 // session" beginning with an entry event and ending with an exit event. | 40 // session" beginning with an entry event and ending with an exit event. |
42 // Typically, these events are navigations matching a URL pattern, or various | 41 // Typically, these events are navigations matching a URL pattern, or various |
43 // types of browser-initiated navigations. A single tab may have several | 42 // types of browser-initiated navigations. A single tab may have several |
44 // disjoint "tracking sessions" depending on the sequence of entry and exit | 43 // disjoint "tracking sessions" depending on the sequence of entry and exit |
45 // events that took place. | 44 // events that took place. |
46 class DataUseTabModel { | 45 class DataUseTabModel { |
47 public: | 46 public: |
(...skipping 30 matching lines...) Expand all Loading... | |
78 | 77 |
79 // Notification callback when tab tracking sessions are started and ended. | 78 // Notification callback when tab tracking sessions are started and ended. |
80 // The callback will be received on the same thread AddObserver was called | 79 // The callback will be received on the same thread AddObserver was called |
81 // from. | 80 // from. |
82 virtual void NotifyTrackingStarting(SessionID::id_type tab_id) = 0; | 81 virtual void NotifyTrackingStarting(SessionID::id_type tab_id) = 0; |
83 virtual void NotifyTrackingEnding(SessionID::id_type tab_id) = 0; | 82 virtual void NotifyTrackingEnding(SessionID::id_type tab_id) = 0; |
84 }; | 83 }; |
85 | 84 |
86 DataUseTabModel(); | 85 DataUseTabModel(); |
87 | 86 |
88 // Initializes |this| on UI thread. |external_data_use_observer| is the weak | 87 // Initializes |this| on UI thread. |external_data_use_observer_bridge| is the |
89 // pointer to ExternalDataUseObserver object that owns |this|. | 88 // pointer to ExternalDataUseObserverBridge object. DataUseTabModel and |
89 // ExternalDataUseObserverBridge objects are owned by ExternalDataUseObserver | |
90 // and DataUseTabModel is destroyed first followed by | |
91 // ExternalDataUseObserverBridge. | |
90 void InitOnUIThread( | 92 void InitOnUIThread( |
91 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, | 93 const ExternalDataUseObserverBridge* external_data_use_observer_bridge); |
92 const base::WeakPtr<ExternalDataUseObserver>& external_data_use_observer); | |
93 | 94 |
94 virtual ~DataUseTabModel(); | 95 virtual ~DataUseTabModel(); |
95 | 96 |
96 base::WeakPtr<DataUseTabModel> GetWeakPtr(); | 97 base::WeakPtr<DataUseTabModel> GetWeakPtr(); |
97 | 98 |
98 // Notifies the DataUseTabModel of navigation events. |tab_id| is the source | 99 // Notifies the DataUseTabModel of navigation events. |tab_id| is the source |
99 // tab of the generated event, |transition| indicates the type of the UI | 100 // tab of the generated event, |transition| indicates the type of the UI |
100 // event/transition, |url| is the URL in the source tab, |package| indicates | 101 // event/transition, |url| is the URL in the source tab, |package| indicates |
101 // the android package name of external application that initiated the event. | 102 // the android package name of external application that initiated the event. |
102 void OnNavigationEvent(SessionID::id_type tab_id, | 103 void OnNavigationEvent(SessionID::id_type tab_id, |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
263 base::WeakPtrFactory<DataUseTabModel> weak_factory_; | 264 base::WeakPtrFactory<DataUseTabModel> weak_factory_; |
264 | 265 |
265 DISALLOW_COPY_AND_ASSIGN(DataUseTabModel); | 266 DISALLOW_COPY_AND_ASSIGN(DataUseTabModel); |
266 }; | 267 }; |
267 | 268 |
268 } // namespace android | 269 } // namespace android |
269 | 270 |
270 } // namespace chrome | 271 } // namespace chrome |
271 | 272 |
272 #endif // CHROME_BROWSER_ANDROID_DATA_USAGE_DATA_USE_TAB_MODEL_H_ | 273 #endif // CHROME_BROWSER_ANDROID_DATA_USAGE_DATA_USE_TAB_MODEL_H_ |
OLD | NEW |