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 <stddef.h> |
| 8 |
7 #include <map> | 9 #include <map> |
8 | 10 |
9 #include "base/android/jni_android.h" | 11 #include "base/android/jni_android.h" |
10 #include "base/android/jni_array.h" | 12 #include "base/android/jni_array.h" |
11 #include "base/android/jni_string.h" | 13 #include "base/android/jni_string.h" |
12 #include "base/bind.h" | 14 #include "base/bind.h" |
13 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
14 #include "base/files/file_util.h" | 16 #include "base/files/file_util.h" |
15 #include "base/files/scoped_file.h" | 17 #include "base/files/scoped_file.h" |
16 #include "base/logging.h" | 18 #include "base/logging.h" |
| 19 #include "base/macros.h" |
17 #include "base/memory/scoped_vector.h" | 20 #include "base/memory/scoped_vector.h" |
18 #include "base/message_loop/message_loop.h" | 21 #include "base/message_loop/message_loop.h" |
19 #include "base/metrics/statistics_recorder.h" | 22 #include "base/metrics/statistics_recorder.h" |
20 #include "base/prefs/pref_filter.h" | 23 #include "base/prefs/pref_filter.h" |
21 #include "base/prefs/pref_registry_simple.h" | 24 #include "base/prefs/pref_registry_simple.h" |
22 #include "base/prefs/pref_service.h" | 25 #include "base/prefs/pref_service.h" |
23 #include "base/prefs/pref_service_factory.h" | 26 #include "base/prefs/pref_service_factory.h" |
24 #include "base/single_thread_task_runner.h" | 27 #include "base/single_thread_task_runner.h" |
25 #include "base/time/time.h" | 28 #include "base/time/time.h" |
26 #include "base/values.h" | 29 #include "base/values.h" |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 } | 354 } |
352 | 355 |
353 url::CanonHostInfo host_info; | 356 url::CanonHostInfo host_info; |
354 std::string canon_host(net::CanonicalizeHost(quic_hint.host, &host_info)); | 357 std::string canon_host(net::CanonicalizeHost(quic_hint.host, &host_info)); |
355 if (!host_info.IsIPAddress() && | 358 if (!host_info.IsIPAddress() && |
356 !net::IsCanonicalizedHostCompliant(canon_host)) { | 359 !net::IsCanonicalizedHostCompliant(canon_host)) { |
357 LOG(ERROR) << "Invalid QUIC hint host: " << quic_hint.host; | 360 LOG(ERROR) << "Invalid QUIC hint host: " << quic_hint.host; |
358 continue; | 361 continue; |
359 } | 362 } |
360 | 363 |
361 if (quic_hint.port <= std::numeric_limits<uint16>::min() || | 364 if (quic_hint.port <= std::numeric_limits<uint16_t>::min() || |
362 quic_hint.port > std::numeric_limits<uint16>::max()) { | 365 quic_hint.port > std::numeric_limits<uint16_t>::max()) { |
363 LOG(ERROR) << "Invalid QUIC hint port: " | 366 LOG(ERROR) << "Invalid QUIC hint port: " |
364 << quic_hint.port; | 367 << quic_hint.port; |
365 continue; | 368 continue; |
366 } | 369 } |
367 | 370 |
368 if (quic_hint.alternate_port <= std::numeric_limits<uint16>::min() || | 371 if (quic_hint.alternate_port <= std::numeric_limits<uint16_t>::min() || |
369 quic_hint.alternate_port > std::numeric_limits<uint16>::max()) { | 372 quic_hint.alternate_port > std::numeric_limits<uint16_t>::max()) { |
370 LOG(ERROR) << "Invalid QUIC hint alternate port: " | 373 LOG(ERROR) << "Invalid QUIC hint alternate port: " |
371 << quic_hint.alternate_port; | 374 << quic_hint.alternate_port; |
372 continue; | 375 continue; |
373 } | 376 } |
374 | 377 |
375 net::HostPortPair quic_hint_host_port_pair(canon_host, | 378 net::HostPortPair quic_hint_host_port_pair(canon_host, |
376 quic_hint.port); | 379 quic_hint.port); |
377 net::AlternativeService alternative_service( | 380 net::AlternativeService alternative_service( |
378 net::AlternateProtocol::QUIC, "", | 381 net::AlternateProtocol::QUIC, "", |
379 static_cast<uint16>(quic_hint.alternate_port)); | 382 static_cast<uint16_t>(quic_hint.alternate_port)); |
380 context_->http_server_properties()->SetAlternativeService( | 383 context_->http_server_properties()->SetAlternativeService( |
381 quic_hint_host_port_pair, alternative_service, 1.0f, | 384 quic_hint_host_port_pair, alternative_service, 1.0f, |
382 base::Time::Max()); | 385 base::Time::Max()); |
383 } | 386 } |
384 } | 387 } |
385 | 388 |
386 // Iterate through PKP configuration for every host. | 389 // Iterate through PKP configuration for every host. |
387 for (const auto& pkp : config->pkp_list) { | 390 for (const auto& pkp : config->pkp_list) { |
388 // Add the host pinning. | 391 // Add the host pinning. |
389 context_->transport_security_state()->AddHPKP( | 392 context_->transport_security_state()->AddHPKP( |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 jint old_log_level = static_cast<jint>(logging::GetMinLogLevel()); | 650 jint old_log_level = static_cast<jint>(logging::GetMinLogLevel()); |
648 // MinLogLevel is global, shared by all URLRequestContexts. | 651 // MinLogLevel is global, shared by all URLRequestContexts. |
649 logging::SetMinLogLevel(static_cast<int>(jlog_level)); | 652 logging::SetMinLogLevel(static_cast<int>(jlog_level)); |
650 return old_log_level; | 653 return old_log_level; |
651 } | 654 } |
652 | 655 |
653 static ScopedJavaLocalRef<jbyteArray> GetHistogramDeltas( | 656 static ScopedJavaLocalRef<jbyteArray> GetHistogramDeltas( |
654 JNIEnv* env, | 657 JNIEnv* env, |
655 const JavaParamRef<jclass>& jcaller) { | 658 const JavaParamRef<jclass>& jcaller) { |
656 base::StatisticsRecorder::Initialize(); | 659 base::StatisticsRecorder::Initialize(); |
657 std::vector<uint8> data; | 660 std::vector<uint8_t> data; |
658 if (!HistogramManager::GetInstance()->GetDeltas(&data)) | 661 if (!HistogramManager::GetInstance()->GetDeltas(&data)) |
659 return ScopedJavaLocalRef<jbyteArray>(); | 662 return ScopedJavaLocalRef<jbyteArray>(); |
660 return base::android::ToJavaByteArray(env, &data[0], data.size()); | 663 return base::android::ToJavaByteArray(env, &data[0], data.size()); |
661 } | 664 } |
662 | 665 |
663 } // namespace cronet | 666 } // namespace cronet |
OLD | NEW |