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_EXTERNAL_DATA_USE_OBSERVER_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_DATA_USAGE_EXTERNAL_DATA_USE_OBSERVER_H_ |
| 6 #define CHROME_BROWSER_ANDROID_DATA_USAGE_EXTERNAL_DATA_USE_OBSERVER_H_ | 6 #define CHROME_BROWSER_ANDROID_DATA_USAGE_EXTERNAL_DATA_USE_OBSERVER_H_ |
| 7 | 7 |
| 8 #include <deque> | |
| 9 #include <memory> | |
| 10 | |
| 8 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 9 #include "base/macros.h" | 12 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 12 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
| 13 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 14 #include "components/data_usage/core/data_use_aggregator.h" | 17 #include "components/data_usage/core/data_use_aggregator.h" |
| 15 | 18 |
| 16 namespace base { | 19 namespace base { |
| 17 class SingleThreadTaskRunner; | 20 class SingleThreadTaskRunner; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, | 87 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, |
| 85 PeriodicFetchMatchingRules); | 88 PeriodicFetchMatchingRules); |
| 86 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, | 89 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, |
| 87 RegisteredAsDataUseObserver); | 90 RegisteredAsDataUseObserver); |
| 88 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, Variations); | 91 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, Variations); |
| 89 FRIEND_TEST_ALL_PREFIXES(DataUseUITabModelTest, ReportTabEventsTest); | 92 FRIEND_TEST_ALL_PREFIXES(DataUseUITabModelTest, ReportTabEventsTest); |
| 90 | 93 |
| 91 // data_usage::DataUseAggregator::Observer implementation: | 94 // data_usage::DataUseAggregator::Observer implementation: |
| 92 void OnDataUse(const data_usage::DataUse& data_use) override; | 95 void OnDataUse(const data_usage::DataUse& data_use) override; |
| 93 | 96 |
| 97 // Called when a batch of data use objects are added to |data_use_list|. | |
|
tbansal1
2016/07/21 04:40:30
s/list/list_/
Raj
2016/07/21 05:58:22
Done.
| |
| 98 void OnDataUseBatchComplete(); | |
| 99 | |
| 94 // Aggregator that sends data use observations to |this|. | 100 // Aggregator that sends data use observations to |this|. |
| 95 data_usage::DataUseAggregator* data_use_aggregator_; | 101 data_usage::DataUseAggregator* data_use_aggregator_; |
| 96 | 102 |
| 97 // |external_data_use_observer_bridge_| is owned by |this|, and interacts with | 103 // |external_data_use_observer_bridge_| is owned by |this|, and interacts with |
| 98 // the Java code. It is created on IO thread but afterwards, should only be | 104 // the Java code. It is created on IO thread but afterwards, should only be |
| 99 // accessed on UI thread. | 105 // accessed on UI thread. |
| 100 ExternalDataUseObserverBridge* external_data_use_observer_bridge_; | 106 ExternalDataUseObserverBridge* external_data_use_observer_bridge_; |
| 101 | 107 |
| 102 // Maintains tab sessions and is owned by |this|. It is created on IO thread | 108 // Maintains tab sessions and is owned by |this|. It is created on IO thread |
| 103 // but afterwards, should only be accessed on UI thread. | 109 // but afterwards, should only be accessed on UI thread. |
| 104 DataUseTabModel* data_use_tab_model_; | 110 DataUseTabModel* data_use_tab_model_; |
| 105 | 111 |
| 106 // Labels, buffers and reports the data usage. It is owned by |this|. It is | 112 // Labels, buffers and reports the data usage. It is owned by |this|. It is |
| 107 // created on IO thread but afterwards, should only be accessed on UI thread. | 113 // created on IO thread but afterwards, should only be accessed on UI thread. |
| 108 ExternalDataUseReporter* external_data_use_reporter_; | 114 ExternalDataUseReporter* external_data_use_reporter_; |
| 109 | 115 |
| 116 // Batches the data use objects reported by DataUseAggregator. | |
| 117 std::unique_ptr<std::deque<const data_usage::DataUse>> data_use_list; | |
|
tbansal1
2016/07/21 04:40:30
s/list/list_/
tbansal1
2016/07/21 04:40:30
Add a comment that when this variable is null, it
Raj
2016/07/21 05:58:22
Done.
Raj
2016/07/21 05:58:22
Done.
| |
| 118 | |
| 119 // |io_task_runner_| is used to call methods on IO thread. | |
| 120 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | |
| 121 | |
| 110 // |ui_task_runner_| is used to call methods on UI thread. | 122 // |ui_task_runner_| is used to call methods on UI thread. |
| 111 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; | 123 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; |
| 112 | 124 |
| 113 // Time when the matching rules were last fetched. | 125 // Time when the matching rules were last fetched. |
| 114 base::TimeTicks last_matching_rules_fetch_time_; | 126 base::TimeTicks last_matching_rules_fetch_time_; |
| 115 | 127 |
| 116 // Duration after which matching rules are periodically fetched. | 128 // Duration after which matching rules are periodically fetched. |
| 117 const base::TimeDelta fetch_matching_rules_duration_; | 129 const base::TimeDelta fetch_matching_rules_duration_; |
| 118 | 130 |
| 119 // True if |this| is currently registered as a data use observer. | 131 // True if |this| is currently registered as a data use observer. |
| 120 bool registered_as_data_use_observer_; | 132 bool registered_as_data_use_observer_; |
| 121 | 133 |
| 122 base::ThreadChecker thread_checker_; | 134 base::ThreadChecker thread_checker_; |
| 123 | 135 |
| 124 base::WeakPtrFactory<ExternalDataUseObserver> weak_factory_; | 136 base::WeakPtrFactory<ExternalDataUseObserver> weak_factory_; |
| 125 | 137 |
| 126 DISALLOW_COPY_AND_ASSIGN(ExternalDataUseObserver); | 138 DISALLOW_COPY_AND_ASSIGN(ExternalDataUseObserver); |
| 127 }; | 139 }; |
| 128 | 140 |
| 129 } // namespace android | 141 } // namespace android |
| 130 | 142 |
| 131 } // namespace chrome | 143 } // namespace chrome |
| 132 | 144 |
| 133 #endif // CHROME_BROWSER_ANDROID_DATA_USAGE_EXTERNAL_DATA_USE_OBSERVER_H_ | 145 #endif // CHROME_BROWSER_ANDROID_DATA_USAGE_EXTERNAL_DATA_USE_OBSERVER_H_ |
| OLD | NEW |