| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 // names. |label| must not be null. If a match is found, the |label| is set | 96 // names. |label| must not be null. If a match is found, the |label| is set |
| 97 // to the matching rule's label. | 97 // to the matching rule's label. |
| 98 bool MatchesAppPackageName(const std::string& app_package_name, | 98 bool MatchesAppPackageName(const std::string& app_package_name, |
| 99 std::string* label) const; | 99 std::string* label) const; |
| 100 | 100 |
| 101 DataUseTabModel* GetDataUseTabModel() const; | 101 DataUseTabModel* GetDataUseTabModel() const; |
| 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(DataUseUITabModelTest, ReportTabEventsTest); | |
| 107 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, BufferDataUseReports); | 106 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, BufferDataUseReports); |
| 108 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, BufferSize); | 107 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, BufferSize); |
| 109 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, ChangeRegex); | 108 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, ChangeRegex); |
| 109 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, DataUseReportTimedOut); |
| 110 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, HashFunction); | 110 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, HashFunction); |
| 111 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, LabelRemoved); | 111 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, LabelRemoved); |
| 112 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, MultipleMatchingRules); | 112 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, MultipleMatchingRules); |
| 113 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, MultipleRegex); | 113 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, MultipleRegex); |
| 114 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, | 114 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, |
| 115 PeriodicFetchMatchingRules); | 115 PeriodicFetchMatchingRules); |
| 116 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, ReportsMergedCorrectly); | 116 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, ReportsMergedCorrectly); |
| 117 FRIEND_TEST_ALL_PREFIXES(DataUseUITabModelTest, ReportTabEventsTest); |
| 117 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, SingleRegex); | 118 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, SingleRegex); |
| 118 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, | 119 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, |
| 119 TimestampsMergedCorrectly); | 120 TimestampsMergedCorrectly); |
| 120 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, TwoRegex); | 121 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, TwoRegex); |
| 121 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, Variations); | 122 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, Variations); |
| 122 | 123 |
| 123 // DataUseReportKey is a unique identifier for a data use report. | 124 // DataUseReportKey is a unique identifier for a data use report. |
| 124 struct DataUseReportKey { | 125 struct DataUseReportKey { |
| 125 DataUseReportKey(const std::string& label, | 126 DataUseReportKey(const std::string& label, |
| 126 net::NetworkChangeNotifier::ConnectionType connection_type, | 127 net::NetworkChangeNotifier::ConnectionType connection_type, |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 // expressions are applied to the request URLs, and filtered data use is | 273 // expressions are applied to the request URLs, and filtered data use is |
| 273 // notified to |j_external_data_use_observer_|. | 274 // notified to |j_external_data_use_observer_|. |
| 274 base::android::ScopedJavaGlobalRef<jobject> j_external_data_use_observer_; | 275 base::android::ScopedJavaGlobalRef<jobject> j_external_data_use_observer_; |
| 275 | 276 |
| 276 // Maintains tab sessions. | 277 // Maintains tab sessions. |
| 277 scoped_ptr<DataUseTabModel> data_use_tab_model_; | 278 scoped_ptr<DataUseTabModel> data_use_tab_model_; |
| 278 | 279 |
| 279 // True if callback from |FetchMatchingRulesDone| is currently pending. | 280 // True if callback from |FetchMatchingRulesDone| is currently pending. |
| 280 bool matching_rules_fetch_pending_; | 281 bool matching_rules_fetch_pending_; |
| 281 | 282 |
| 282 // True if callback from |SubmitDataUseReportCallback| is currently pending. | 283 // Time when the currently pending data use report was submitted. |
| 283 bool submit_data_report_pending_; | 284 // |last_data_report_submitted_ticks_| is null if no data use report is |
| 285 // currently pending. |
| 286 base::TimeTicks last_data_report_submitted_ticks_; |
| 287 |
| 288 // |pending_report_bytes_| is the total byte count in the data use report that |
| 289 // is currently pending. |
| 290 int64_t pending_report_bytes_; |
| 284 | 291 |
| 285 // Contains matching rules. | 292 // Contains matching rules. |
| 286 std::vector<scoped_ptr<MatchingRule>> matching_rules_; | 293 std::vector<scoped_ptr<MatchingRule>> matching_rules_; |
| 287 | 294 |
| 288 // Buffered data reports that need to be submitted to the Java data use | 295 // Buffered data reports that need to be submitted to the Java data use |
| 289 // observer. | 296 // observer. |
| 290 DataUseReports buffered_data_reports_; | 297 DataUseReports buffered_data_reports_; |
| 291 | 298 |
| 292 // True if |this| is currently registered as a data use observer. | 299 // True if |this| is currently registered as a data use observer. |
| 293 bool registered_as_observer_; | 300 bool registered_as_observer_; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 310 // reports. | 317 // reports. |
| 311 int64_t total_bytes_buffered_; | 318 int64_t total_bytes_buffered_; |
| 312 | 319 |
| 313 // Duration after which matching rules are periodically fetched. | 320 // Duration after which matching rules are periodically fetched. |
| 314 const base::TimeDelta fetch_matching_rules_duration_; | 321 const base::TimeDelta fetch_matching_rules_duration_; |
| 315 | 322 |
| 316 // Minimum number of bytes that should be buffered before a data use report is | 323 // Minimum number of bytes that should be buffered before a data use report is |
| 317 // submitted. | 324 // submitted. |
| 318 const int64_t data_use_report_min_bytes_; | 325 const int64_t data_use_report_min_bytes_; |
| 319 | 326 |
| 327 // If a data use report is pending for more than |data_report_submit_timeout_| |
| 328 // duration, it is considered as timed out. |
| 329 const base::TimeDelta data_report_submit_timeout_; |
| 330 |
| 320 base::ThreadChecker thread_checker_; | 331 base::ThreadChecker thread_checker_; |
| 321 | 332 |
| 322 // |io_weak_factory_| and |ui_weak_factory_| are used for posting tasks on the | 333 // |io_weak_factory_| and |ui_weak_factory_| are used for posting tasks on the |
| 323 // IO and UI thread, respectively. | 334 // IO and UI thread, respectively. |
| 324 base::WeakPtrFactory<ExternalDataUseObserver> io_weak_factory_; | 335 base::WeakPtrFactory<ExternalDataUseObserver> io_weak_factory_; |
| 325 base::WeakPtrFactory<ExternalDataUseObserver> ui_weak_factory_; | 336 base::WeakPtrFactory<ExternalDataUseObserver> ui_weak_factory_; |
| 326 | 337 |
| 327 DISALLOW_COPY_AND_ASSIGN(ExternalDataUseObserver); | 338 DISALLOW_COPY_AND_ASSIGN(ExternalDataUseObserver); |
| 328 }; | 339 }; |
| 329 | 340 |
| 330 bool RegisterExternalDataUseObserver(JNIEnv* env); | 341 bool RegisterExternalDataUseObserver(JNIEnv* env); |
| 331 | 342 |
| 332 } // namespace android | 343 } // namespace android |
| 333 | 344 |
| 334 } // namespace chrome | 345 } // namespace chrome |
| 335 | 346 |
| 336 #endif // CHROME_BROWSER_ANDROID_DATA_USAGE_EXTERNAL_DATA_USE_OBSERVER_H_ | 347 #endif // CHROME_BROWSER_ANDROID_DATA_USAGE_EXTERNAL_DATA_USE_OBSERVER_H_ |
| OLD | NEW |