Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/cronet/android/cronet_url_request_context_adapter.h" | 5 #include "components/cronet/android/cronet_url_request_context_adapter.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 | 198 |
| 199 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 199 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 200 FROM_HERE, | 200 FROM_HERE, |
| 201 base::Bind( | 201 base::Bind( |
| 202 &NetworkQualitiesPrefDelegateImpl::SchedulePendingLossyWrites, | 202 &NetworkQualitiesPrefDelegateImpl::SchedulePendingLossyWrites, |
| 203 weak_ptr_factory_.GetWeakPtr()), | 203 weak_ptr_factory_.GetWeakPtr()), |
| 204 base::TimeDelta::FromSeconds(kUpdatePrefsDelaySeconds)); | 204 base::TimeDelta::FromSeconds(kUpdatePrefsDelaySeconds)); |
| 205 } | 205 } |
| 206 std::unique_ptr<base::DictionaryValue> GetDictionaryValue() override { | 206 std::unique_ptr<base::DictionaryValue> GetDictionaryValue() override { |
| 207 DCHECK(thread_checker_.CalledOnValidThread()); | 207 DCHECK(thread_checker_.CalledOnValidThread()); |
| 208 // TODO(tbansal): Add logic to read prefs if the embedder has enabled cached | 208 UMA_HISTOGRAM_EXACT_LINEAR("NQE.Prefs.ReadCount", 1, 2); |
| 209 // estimates. | 209 return pref_service_->GetDictionary(kNetworkQualities)->CreateDeepCopy(); |
|
xunjieli
2017/02/07 21:05:59
Does |pref_service_| return empty DictionaryValue
tbansal1
2017/02/09 17:36:26
Yes, it will return an empty map.
Prefs are read
| |
| 210 return base::WrapUnique(new base::DictionaryValue()); | |
| 211 } | 210 } |
| 212 | 211 |
| 213 private: | 212 private: |
| 214 // Schedules the writing of the lossy prefs. | 213 // Schedules the writing of the lossy prefs. |
| 215 void SchedulePendingLossyWrites() { | 214 void SchedulePendingLossyWrites() { |
| 216 DCHECK(thread_checker_.CalledOnValidThread()); | 215 DCHECK(thread_checker_.CalledOnValidThread()); |
| 216 UMA_HISTOGRAM_EXACT_LINEAR("NQE.Prefs.WriteCount", 1, 2); | |
| 217 pref_service_->SchedulePendingLossyWrites(); | 217 pref_service_->SchedulePendingLossyWrites(); |
| 218 lossy_prefs_writing_task_posted_ = false; | 218 lossy_prefs_writing_task_posted_ = false; |
| 219 } | 219 } |
| 220 | 220 |
| 221 PrefService* pref_service_; | 221 PrefService* pref_service_; |
| 222 | 222 |
| 223 // True if the task that schedules the writing of the lossy prefs has been | 223 // True if the task that schedules the writing of the lossy prefs has been |
| 224 // posted. | 224 // posted. |
| 225 bool lossy_prefs_writing_task_posted_; | 225 bool lossy_prefs_writing_task_posted_; |
| 226 | 226 |
| (...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1190 JNIEnv* env, | 1190 JNIEnv* env, |
| 1191 const JavaParamRef<jclass>& jcaller) { | 1191 const JavaParamRef<jclass>& jcaller) { |
| 1192 base::StatisticsRecorder::Initialize(); | 1192 base::StatisticsRecorder::Initialize(); |
| 1193 std::vector<uint8_t> data; | 1193 std::vector<uint8_t> data; |
| 1194 if (!HistogramManager::GetInstance()->GetDeltas(&data)) | 1194 if (!HistogramManager::GetInstance()->GetDeltas(&data)) |
| 1195 return ScopedJavaLocalRef<jbyteArray>(); | 1195 return ScopedJavaLocalRef<jbyteArray>(); |
| 1196 return base::android::ToJavaByteArray(env, &data[0], data.size()); | 1196 return base::android::ToJavaByteArray(env, &data[0], data.size()); |
| 1197 } | 1197 } |
| 1198 | 1198 |
| 1199 } // namespace cronet | 1199 } // namespace cronet |
| OLD | NEW |