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