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

Side by Side Diff: chrome/browser/android/data_usage/external_data_use_observer_bridge.cc

Issue 1772273002: Remove one thread hop while fetching matching rules (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments 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 #include "chrome/browser/android/data_usage/external_data_use_observer_bridge.h" 5 #include "chrome/browser/android/data_usage/external_data_use_observer_bridge.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/android/context_utils.h" 9 #include "base/android/context_utils.h"
10 #include "base/android/jni_string.h" 10 #include "base/android/jni_string.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 return; 121 return;
122 122
123 if (is_first_matching_rule_fetch_) { 123 if (is_first_matching_rule_fetch_) {
124 is_first_matching_rule_fetch_ = false; 124 is_first_matching_rule_fetch_ = false;
125 UMA_HISTOGRAM_TIMES("DataUsage.Perf.MatchingRuleFirstFetchDuration", 125 UMA_HISTOGRAM_TIMES("DataUsage.Perf.MatchingRuleFirstFetchDuration",
126 base::TimeTicks::Now() - construct_time_); 126 base::TimeTicks::Now() - construct_time_);
127 } 127 }
128 128
129 data_use_tab_model_->RegisterURLRegexes( 129 data_use_tab_model_->RegisterURLRegexes(
130 app_package_name_native, domain_path_regex_native, label_native); 130 app_package_name_native, domain_path_regex_native, label_native);
131
132 io_task_runner_->PostTask(
133 FROM_HERE, base::Bind(&ExternalDataUseObserver::OnFetchMatchingRulesDone,
tbansal1 2016/03/10 01:00:58 Why is this callback needed? This is not preventi
Raj 2016/03/10 02:13:34 This callback updates the last_matching_rules_fetc
134 external_data_use_observer_));
131 } 135 }
132 136
133 void ExternalDataUseObserverBridge::ReportDataUse( 137 void ExternalDataUseObserverBridge::ReportDataUse(
134 const std::string& label, 138 const std::string& label,
135 net::NetworkChangeNotifier::ConnectionType connection_type, 139 net::NetworkChangeNotifier::ConnectionType connection_type,
136 const std::string& mcc_mnc, 140 const std::string& mcc_mnc,
137 const base::Time& start_time, 141 const base::Time& start_time,
138 const base::Time& end_time, 142 const base::Time& end_time,
139 int64_t bytes_downloaded, 143 int64_t bytes_downloaded,
140 int64_t bytes_uploaded) const { 144 int64_t bytes_uploaded) const {
(...skipping 27 matching lines...) Expand all
168 } 172 }
169 173
170 void ExternalDataUseObserverBridge::OnControlAppInstallStateChange( 174 void ExternalDataUseObserverBridge::OnControlAppInstallStateChange(
171 JNIEnv* env, 175 JNIEnv* env,
172 jobject obj, 176 jobject obj,
173 bool is_control_app_installed) const { 177 bool is_control_app_installed) const {
174 DCHECK(thread_checker_.CalledOnValidThread()); 178 DCHECK(thread_checker_.CalledOnValidThread());
175 data_use_tab_model_->OnControlAppInstallStateChange(is_control_app_installed); 179 data_use_tab_model_->OnControlAppInstallStateChange(is_control_app_installed);
176 } 180 }
177 181
182 void ExternalDataUseObserverBridge::ShouldRegisterAsDataUseObserver(
183 bool should_register) const {
184 DCHECK(thread_checker_.CalledOnValidThread());
185 io_task_runner_->PostTask(
186 FROM_HERE,
187 base::Bind(&ExternalDataUseObserver::ShouldRegisterAsDataUseObserver,
188 external_data_use_observer_, should_register));
189 }
190
178 bool RegisterExternalDataUseObserver(JNIEnv* env) { 191 bool RegisterExternalDataUseObserver(JNIEnv* env) {
179 return RegisterNativesImpl(env); 192 return RegisterNativesImpl(env);
180 } 193 }
181 194
182 } // namespace android 195 } // namespace android
183 196
184 } // namespace chrome 197 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698