Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Side by Side Diff: chrome/browser/android/data_usage/external_data_use_observer.h

Issue 1772273002: Remove one thread hop while fetching matching rules (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed nits Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 75
76 // Returns the pointer to the DataUseTabModel object owned by |this|. The 76 // Returns the pointer to the DataUseTabModel object owned by |this|. The
77 // caller does not owns the returned pointer. 77 // caller does not owns the returned pointer.
78 DataUseTabModel* GetDataUseTabModel() const; 78 DataUseTabModel* GetDataUseTabModel() const;
79 79
80 // Called by ExternalDataUseObserverBridge::OnReportDataUseDone when a data 80 // Called by ExternalDataUseObserverBridge::OnReportDataUseDone when a data
81 // use report has been submitted. |success| is true if the request was 81 // use report has been submitted. |success| is true if the request was
82 // successfully submitted to the external data use observer by Java. 82 // successfully submitted to the external data use observer by Java.
83 void OnReportDataUseDone(bool success); 83 void OnReportDataUseDone(bool success);
84 84
85 // Called by DataUseMatcher. |should_register| is true if |this| should 85 // Called by ExternalDataUseObserverBridge. |should_register| is true if
86 // register as a data use observer. 86 // |this| should register as a data use observer.
87 void ShouldRegisterAsDataUseObserver(bool should_register); 87 void ShouldRegisterAsDataUseObserver(bool should_register);
88 88
89 // Fetches the matching rules asynchronously. 89 // Fetches the matching rules asynchronously.
90 void FetchMatchingRules(); 90 void FetchMatchingRules();
91 91
92 base::WeakPtr<ExternalDataUseObserver> GetWeakPtr(); 92 base::WeakPtr<ExternalDataUseObserver> GetWeakPtr();
93 93
94 private: 94 private:
95 friend class DataUseTabModelTest; 95 friend class DataUseTabModelTest;
96 friend class DataUseUITabModelTest;
96 friend class ExternalDataUseObserverTest; 97 friend class ExternalDataUseObserverTest;
97 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, BufferDataUseReports); 98 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, BufferDataUseReports);
98 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, BufferSize); 99 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, BufferSize);
99 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, DataUseReportTimedOut); 100 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, DataUseReportTimedOut);
100 #if defined(OS_ANDROID) 101 #if defined(OS_ANDROID)
101 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, 102 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest,
102 DataUseReportingOnApplicationStatusChange); 103 DataUseReportingOnApplicationStatusChange);
103 #endif 104 #endif
104 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, HashFunction); 105 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, HashFunction);
105 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest, 106 FRIEND_TEST_ALL_PREFIXES(ExternalDataUseObserverTest,
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 212
212 #if defined(OS_ANDROID) 213 #if defined(OS_ANDROID)
213 // Called whenever the application transitions from foreground to background 214 // Called whenever the application transitions from foreground to background
214 // or vice versa. 215 // or vice versa.
215 void OnApplicationStateChange(base::android::ApplicationState new_state); 216 void OnApplicationStateChange(base::android::ApplicationState new_state);
216 #endif 217 #endif
217 218
218 // Aggregator that sends data use observations to |this|. 219 // Aggregator that sends data use observations to |this|.
219 data_usage::DataUseAggregator* data_use_aggregator_; 220 data_usage::DataUseAggregator* data_use_aggregator_;
220 221
222 // |external_data_use_observer_bridge_| is owned by |this|, and interacts with
223 // the Java code. It is created on IO thread but afterwards, should only be
224 // accessed on UI thread.
225 ExternalDataUseObserverBridge* external_data_use_observer_bridge_;
226
221 // Maintains tab sessions and is owned by |this|. It is created on IO thread 227 // Maintains tab sessions and is owned by |this|. It is created on IO thread
222 // but afterwards, should only be accessed on UI thread. 228 // but afterwards, should only be accessed on UI thread.
223 DataUseTabModel* data_use_tab_model_; 229 DataUseTabModel* data_use_tab_model_;
224 230
225 // Time when the currently pending data use report was submitted. 231 // Time when the currently pending data use report was submitted.
226 // |last_data_report_submitted_ticks_| is null if no data use report is 232 // |last_data_report_submitted_ticks_| is null if no data use report is
227 // currently pending. 233 // currently pending.
228 base::TimeTicks last_data_report_submitted_ticks_; 234 base::TimeTicks last_data_report_submitted_ticks_;
229 235
230 // |pending_report_bytes_| is the total byte count in the data use report that 236 // |pending_report_bytes_| is the total byte count in the data use report that
231 // is currently pending. 237 // is currently pending.
232 int64_t pending_report_bytes_; 238 int64_t pending_report_bytes_;
233 239
234 // Buffered data reports that need to be submitted to the 240 // Buffered data reports that need to be submitted to the
235 // |external_data_use_observer_bridge_|. 241 // |external_data_use_observer_bridge_|.
236 DataUseReports buffered_data_reports_; 242 DataUseReports buffered_data_reports_;
237 243
238 // |ui_task_runner_| is used to call methods on UI thread. 244 // |ui_task_runner_| is used to call methods on UI thread.
239 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; 245 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
240 246
241 // Time when the data use reports were last received from DataUseAggregator. 247 // Time when the data use reports were last received from DataUseAggregator.
242 base::Time previous_report_time_; 248 base::Time previous_report_time_;
243 249
244 // Time when the matching rules were last fetched. 250 // Time when the matching rules were last fetched.
245 base::TimeTicks last_matching_rules_fetch_time_; 251 base::TimeTicks last_matching_rules_fetch_time_;
246 252
247 // |external_data_use_observer_bridge_| is owned by |this|, and interacts with
248 // the Java code. It is created on IO thread but afterwards, should only be
249 // accessed on UI thread.
250 ExternalDataUseObserverBridge* external_data_use_observer_bridge_;
251
252 // Total number of bytes transmitted or received across all the buffered 253 // Total number of bytes transmitted or received across all the buffered
253 // reports. 254 // reports.
254 int64_t total_bytes_buffered_; 255 int64_t total_bytes_buffered_;
255 256
256 // Duration after which matching rules are periodically fetched. 257 // Duration after which matching rules are periodically fetched.
257 const base::TimeDelta fetch_matching_rules_duration_; 258 const base::TimeDelta fetch_matching_rules_duration_;
258 259
259 // Minimum number of bytes that should be buffered before a data use report is 260 // Minimum number of bytes that should be buffered before a data use report is
260 // submitted. 261 // submitted.
261 const int64_t data_use_report_min_bytes_; 262 const int64_t data_use_report_min_bytes_;
(...skipping 16 matching lines...) Expand all
278 base::WeakPtrFactory<ExternalDataUseObserver> weak_factory_; 279 base::WeakPtrFactory<ExternalDataUseObserver> weak_factory_;
279 280
280 DISALLOW_COPY_AND_ASSIGN(ExternalDataUseObserver); 281 DISALLOW_COPY_AND_ASSIGN(ExternalDataUseObserver);
281 }; 282 };
282 283
283 } // namespace android 284 } // namespace android
284 285
285 } // namespace chrome 286 } // namespace chrome
286 287
287 #endif // CHROME_BROWSER_ANDROID_DATA_USAGE_EXTERNAL_DATA_USE_OBSERVER_H_ 288 #endif // CHROME_BROWSER_ANDROID_DATA_USAGE_EXTERNAL_DATA_USE_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698