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 <jni.h> | 8 #include <jni.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 // |label| must not be null. If a match is found, the |label| is set to the | 89 // |label| must not be null. If a match is found, the |label| is set to the |
90 // matching rule's label. | 90 // matching rule's label. |
91 bool Matches(const GURL& gurl, std::string* label) const; | 91 bool Matches(const GURL& gurl, std::string* label) const; |
92 | 92 |
93 // Returns true if the |app_package_name| matches the registered package | 93 // Returns true if the |app_package_name| matches the registered package |
94 // names. |label| must not be null. If a match is found, the |label| is set | 94 // names. |label| must not be null. If a match is found, the |label| is set |
95 // to the matching rule's label. | 95 // to the matching rule's label. |
96 bool MatchesAppPackageName(const std::string& app_package_name, | 96 bool MatchesAppPackageName(const std::string& app_package_name, |
97 std::string* label) const; | 97 std::string* label) const; |
98 | 98 |
99 DataUseTabModel* data_use_tab_model() const { | 99 const base::WeakPtr<DataUseTabModel>& data_use_tab_model_weak_ptr() const { |
sclittle
2015/11/23 23:06:16
nit: Why can't this just be as it was before? Or m
tbansal1
2015/11/24 00:42:03
weak ptr has to be generated on IO thread, stored
sclittle
2015/11/24 04:11:50
I'm confused - this method is run on the IO thread
| |
100 return data_use_tab_model_.get(); | 100 return data_use_tab_model_weak_ptr_; |
101 } | 101 } |
102 | 102 |
103 private: | 103 private: |
104 friend class DataUseTabModelTest; | 104 friend class DataUseTabModelTest; |
105 friend class ExternalDataUseObserverTest; | 105 friend class ExternalDataUseObserverTest; |
106 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, SingleRegex); | |
107 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, TwoRegex); | |
108 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, MultipleRegex); | |
109 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, ChangeRegex); | |
110 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, LabelRemoved); | |
111 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, | 106 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, |
112 AtMostOneDataUseSubmitRequest); | 107 AtMostOneDataUseSubmitRequest); |
108 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, BufferDataUseReports); | |
109 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, BufferSize); | |
110 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, ChangeRegex); | |
111 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, HashFunction); | |
112 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, LabelRemoved); | |
113 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, MultipleMatchingRules); | 113 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, MultipleMatchingRules); |
114 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, MultipleRegex); | |
115 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, | |
116 PeriodicFetchMatchingRules); | |
114 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, ReportsMergedCorrectly); | 117 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, ReportsMergedCorrectly); |
118 FRIEND_TEST_ALL_PREFIXES(DataUseUITabModelTest, ReportTabEventsTest); | |
119 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, SingleRegex); | |
115 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, | 120 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, |
116 TimestampsMergedCorrectly); | 121 TimestampsMergedCorrectly); |
117 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, HashFunction); | 122 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, TwoRegex); |
118 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, BufferSize); | |
119 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, | |
120 PeriodicFetchMatchingRules); | |
121 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, BufferDataUseReports); | |
122 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, Variations); | 123 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, Variations); |
123 | 124 |
124 // DataUseReportKey is a unique identifier for a data use report. | 125 // DataUseReportKey is a unique identifier for a data use report. |
125 struct DataUseReportKey { | 126 struct DataUseReportKey { |
126 DataUseReportKey(const std::string& label, | 127 DataUseReportKey(const std::string& label, |
127 net::NetworkChangeNotifier::ConnectionType connection_type, | 128 net::NetworkChangeNotifier::ConnectionType connection_type, |
128 const std::string& mcc_mnc); | 129 const std::string& mcc_mnc); |
129 | 130 |
130 bool operator==(const DataUseReportKey& other) const; | 131 bool operator==(const DataUseReportKey& other) const; |
131 | 132 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
270 // Aggregator that sends data use observations to |this|. | 271 // Aggregator that sends data use observations to |this|. |
271 data_usage::DataUseAggregator* data_use_aggregator_; | 272 data_usage::DataUseAggregator* data_use_aggregator_; |
272 | 273 |
273 // Java listener that provides regular expressions to |this|. The regular | 274 // Java listener that provides regular expressions to |this|. The regular |
274 // expressions are applied to the request URLs, and filtered data use is | 275 // expressions are applied to the request URLs, and filtered data use is |
275 // notified to |j_external_data_use_observer_|. | 276 // notified to |j_external_data_use_observer_|. |
276 base::android::ScopedJavaGlobalRef<jobject> j_external_data_use_observer_; | 277 base::android::ScopedJavaGlobalRef<jobject> j_external_data_use_observer_; |
277 | 278 |
278 // Maintains tab sessions. | 279 // Maintains tab sessions. |
279 scoped_ptr<DataUseTabModel> data_use_tab_model_; | 280 scoped_ptr<DataUseTabModel> data_use_tab_model_; |
281 base::WeakPtr<DataUseTabModel> data_use_tab_model_weak_ptr_; | |
280 | 282 |
281 // True if callback from |FetchMatchingRulesDone| is currently pending. | 283 // True if callback from |FetchMatchingRulesDone| is currently pending. |
282 bool matching_rules_fetch_pending_; | 284 bool matching_rules_fetch_pending_; |
283 | 285 |
284 // True if callback from |SubmitDataUseReportCallback| is currently pending. | 286 // True if callback from |SubmitDataUseReportCallback| is currently pending. |
285 bool submit_data_report_pending_; | 287 bool submit_data_report_pending_; |
286 | 288 |
287 // Contains matching rules. | 289 // Contains matching rules. |
288 std::vector<scoped_ptr<MatchingRule>> matching_rules_; | 290 std::vector<scoped_ptr<MatchingRule>> matching_rules_; |
289 | 291 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
329 DISALLOW_COPY_AND_ASSIGN(ExternalDataUseObserver); | 331 DISALLOW_COPY_AND_ASSIGN(ExternalDataUseObserver); |
330 }; | 332 }; |
331 | 333 |
332 bool RegisterExternalDataUseObserver(JNIEnv* env); | 334 bool RegisterExternalDataUseObserver(JNIEnv* env); |
333 | 335 |
334 } // namespace android | 336 } // namespace android |
335 | 337 |
336 } // namespace chrome | 338 } // namespace chrome |
337 | 339 |
338 #endif // CHROME_BROWSER_ANDROID_DATA_USAGE_EXTERNAL_DATA_USE_OBSERVER_H_ | 340 #endif // CHROME_BROWSER_ANDROID_DATA_USAGE_EXTERNAL_DATA_USE_OBSERVER_H_ |
OLD | NEW |