| 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 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 jboolean use_local_host_requests, | 460 jboolean use_local_host_requests, |
| 461 jboolean use_smaller_responses) { | 461 jboolean use_smaller_responses) { |
| 462 PostTaskToNetworkThread( | 462 PostTaskToNetworkThread( |
| 463 FROM_HERE, | 463 FROM_HERE, |
| 464 base::Bind(&CronetURLRequestContextAdapter:: | 464 base::Bind(&CronetURLRequestContextAdapter:: |
| 465 ConfigureNetworkQualityEstimatorOnNetworkThreadForTesting, | 465 ConfigureNetworkQualityEstimatorOnNetworkThreadForTesting, |
| 466 base::Unretained(this), use_local_host_requests, | 466 base::Unretained(this), use_local_host_requests, |
| 467 use_smaller_responses)); | 467 use_smaller_responses)); |
| 468 } | 468 } |
| 469 | 469 |
| 470 void CronetURLRequestContextAdapter:: | |
| 471 EnableNetworkQualityEstimatorOnNetworkThread() { | |
| 472 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); | |
| 473 DCHECK(!network_quality_estimator_); | |
| 474 network_quality_estimator_.reset(new net::NetworkQualityEstimator( | |
| 475 std::unique_ptr<net::ExternalEstimateProvider>(), | |
| 476 std::map<std::string, std::string>())); | |
| 477 context_->set_network_quality_estimator(network_quality_estimator_.get()); | |
| 478 } | |
| 479 | |
| 480 void CronetURLRequestContextAdapter::EnableNetworkQualityEstimator( | |
| 481 JNIEnv* env, | |
| 482 const JavaParamRef<jobject>& jcaller) { | |
| 483 PostTaskToNetworkThread( | |
| 484 FROM_HERE, base::Bind(&CronetURLRequestContextAdapter:: | |
| 485 EnableNetworkQualityEstimatorOnNetworkThread, | |
| 486 base::Unretained(this))); | |
| 487 } | |
| 488 | |
| 489 void CronetURLRequestContextAdapter::ProvideRTTObservationsOnNetworkThread( | 470 void CronetURLRequestContextAdapter::ProvideRTTObservationsOnNetworkThread( |
| 490 bool should) { | 471 bool should) { |
| 491 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); | 472 DCHECK(GetNetworkTaskRunner()->BelongsToCurrentThread()); |
| 492 if (!network_quality_estimator_) | 473 if (!network_quality_estimator_) |
| 493 return; | 474 return; |
| 494 if (should) { | 475 if (should) { |
| 495 network_quality_estimator_->AddRTTObserver(this); | 476 network_quality_estimator_->AddRTTObserver(this); |
| 496 } else { | 477 } else { |
| 497 network_quality_estimator_->RemoveRTTObserver(this); | 478 network_quality_estimator_->RemoveRTTObserver(this); |
| 498 } | 479 } |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 997 JNIEnv* env, | 978 JNIEnv* env, |
| 998 const JavaParamRef<jclass>& jcaller) { | 979 const JavaParamRef<jclass>& jcaller) { |
| 999 base::StatisticsRecorder::Initialize(); | 980 base::StatisticsRecorder::Initialize(); |
| 1000 std::vector<uint8_t> data; | 981 std::vector<uint8_t> data; |
| 1001 if (!HistogramManager::GetInstance()->GetDeltas(&data)) | 982 if (!HistogramManager::GetInstance()->GetDeltas(&data)) |
| 1002 return ScopedJavaLocalRef<jbyteArray>(); | 983 return ScopedJavaLocalRef<jbyteArray>(); |
| 1003 return base::android::ToJavaByteArray(env, &data[0], data.size()); | 984 return base::android::ToJavaByteArray(env, &data[0], data.size()); |
| 1004 } | 985 } |
| 1005 | 986 |
| 1006 } // namespace cronet | 987 } // namespace cronet |
| OLD | NEW |