OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/io_thread.h" | 5 #include "chrome/browser/io_thread.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 // specifies a different value via SETTINGS. | 307 // specifies a different value via SETTINGS. |
308 void ConfigureSpdyGlobalsFromUseSpdyArgument(const std::string& mode, | 308 void ConfigureSpdyGlobalsFromUseSpdyArgument(const std::string& mode, |
309 IOThread::Globals* globals) { | 309 IOThread::Globals* globals) { |
310 static const char kOff[] = "off"; | 310 static const char kOff[] = "off"; |
311 static const char kDisablePing[] = "no-ping"; | 311 static const char kDisablePing[] = "no-ping"; |
312 static const char kExclude[] = "exclude"; // Hosts to exclude | 312 static const char kExclude[] = "exclude"; // Hosts to exclude |
313 static const char kDisableCompression[] = "no-compress"; | 313 static const char kDisableCompression[] = "no-compress"; |
314 static const char kDisableAltProtocols[] = "no-alt-protocols"; | 314 static const char kDisableAltProtocols[] = "no-alt-protocols"; |
315 static const char kInitialMaxConcurrentStreams[] = "init-max-streams"; | 315 static const char kInitialMaxConcurrentStreams[] = "init-max-streams"; |
316 | 316 |
317 std::vector<std::string> spdy_options; | 317 for (const base::StringPiece& element : base::SplitStringPiece( |
318 base::SplitString(mode, ',', &spdy_options); | 318 mode, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { |
319 | 319 std::vector<base::StringPiece> name_value = base::SplitStringPiece( |
320 for (const std::string& element : spdy_options) { | 320 element, "=", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
321 std::vector<std::string> name_value; | 321 const base::StringPiece option = |
322 base::SplitString(element, '=', &name_value); | 322 name_value.size() > 0 ? name_value[0] : base::StringPiece(); |
323 const std::string& option = | 323 const base::StringPiece value = |
324 name_value.size() > 0 ? name_value[0] : std::string(); | 324 name_value.size() > 1 ? name_value[1] : base::StringPiece(); |
325 const std::string value = | |
326 name_value.size() > 1 ? name_value[1] : std::string(); | |
327 | 325 |
328 if (option == kOff) { | 326 if (option == kOff) { |
329 net::HttpStreamFactory::set_spdy_enabled(false); | 327 net::HttpStreamFactory::set_spdy_enabled(false); |
330 continue; | 328 continue; |
331 } | 329 } |
332 if (option == kDisablePing) { | 330 if (option == kDisablePing) { |
333 globals->enable_spdy_ping_based_connection_checking.set(false); | 331 globals->enable_spdy_ping_based_connection_checking.set(false); |
334 continue; | 332 continue; |
335 } | 333 } |
336 if (option == kExclude) { | 334 if (option == kExclude) { |
337 globals->forced_spdy_exclusions.insert( | 335 globals->forced_spdy_exclusions.insert( |
338 net::HostPortPair::FromURL(GURL(value))); | 336 net::HostPortPair::FromURL(GURL(value.as_string()))); |
339 continue; | 337 continue; |
340 } | 338 } |
341 if (option == kDisableCompression) { | 339 if (option == kDisableCompression) { |
342 globals->enable_spdy_compression.set(false); | 340 globals->enable_spdy_compression.set(false); |
343 continue; | 341 continue; |
344 } | 342 } |
345 if (option == kDisableAltProtocols) { | 343 if (option == kDisableAltProtocols) { |
346 globals->use_alternate_protocols.set(false); | 344 globals->use_alternate_protocols.set(false); |
347 continue; | 345 continue; |
348 } | 346 } |
349 if (option == kInitialMaxConcurrentStreams) { | 347 if (option == kInitialMaxConcurrentStreams) { |
350 int streams; | 348 int streams; |
351 if (base::StringToInt(value, &streams)) { | 349 if (base::StringToInt(value, &streams)) { |
352 globals->initial_max_spdy_concurrent_streams.set(streams); | 350 globals->initial_max_spdy_concurrent_streams.set(streams); |
353 continue; | 351 continue; |
354 } | 352 } |
355 } | 353 } |
356 LOG(DFATAL) << "Unrecognized spdy option: " << option; | 354 LOG(DFATAL) << "Unrecognized spdy option: " << option.as_string(); |
357 } | 355 } |
358 } | 356 } |
359 | 357 |
360 } // namespace | 358 } // namespace |
361 | 359 |
362 class IOThread::LoggingNetworkChangeObserver | 360 class IOThread::LoggingNetworkChangeObserver |
363 : public net::NetworkChangeNotifier::IPAddressObserver, | 361 : public net::NetworkChangeNotifier::IPAddressObserver, |
364 public net::NetworkChangeNotifier::ConnectionTypeObserver, | 362 public net::NetworkChangeNotifier::ConnectionTypeObserver, |
365 public net::NetworkChangeNotifier::NetworkChangeObserver { | 363 public net::NetworkChangeNotifier::NetworkChangeObserver { |
366 public: | 364 public: |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 tracked_objects::ScopedTracker tracking_profile8( | 679 tracked_objects::ScopedTracker tracking_profile8( |
682 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 680 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
683 "466432 IOThread::InitAsync::CreateLogVerifiers::Start")); | 681 "466432 IOThread::InitAsync::CreateLogVerifiers::Start")); |
684 std::vector<scoped_refptr<net::CTLogVerifier>> ct_logs( | 682 std::vector<scoped_refptr<net::CTLogVerifier>> ct_logs( |
685 net::ct::CreateLogVerifiersForKnownLogs()); | 683 net::ct::CreateLogVerifiersForKnownLogs()); |
686 | 684 |
687 // Add logs from command line | 685 // Add logs from command line |
688 if (command_line.HasSwitch(switches::kCertificateTransparencyLog)) { | 686 if (command_line.HasSwitch(switches::kCertificateTransparencyLog)) { |
689 std::string switch_value = command_line.GetSwitchValueASCII( | 687 std::string switch_value = command_line.GetSwitchValueASCII( |
690 switches::kCertificateTransparencyLog); | 688 switches::kCertificateTransparencyLog); |
691 std::vector<std::string> logs; | 689 for (const base::StringPiece& curr_log : base::SplitStringPiece( |
692 base::SplitString(switch_value, ',', &logs); | 690 switch_value, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { |
693 for (std::vector<std::string>::iterator it = logs.begin(); it != logs.end(); | 691 std::vector<std::string> log_metadata = base::SplitString( |
694 ++it) { | 692 curr_log, ":", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
695 const std::string& curr_log = *it; | |
696 std::vector<std::string> log_metadata; | |
697 base::SplitString(curr_log, ':', &log_metadata); | |
698 CHECK_GE(log_metadata.size(), 3u) | 693 CHECK_GE(log_metadata.size(), 3u) |
699 << "CT log metadata missing: Switch format is " | 694 << "CT log metadata missing: Switch format is " |
700 << "'description:base64_key:url_without_schema'."; | 695 << "'description:base64_key:url_without_schema'."; |
701 std::string log_description(log_metadata[0]); | 696 std::string log_description(log_metadata[0]); |
702 std::string log_url(std::string("https://") + log_metadata[2]); | 697 std::string log_url(std::string("https://") + log_metadata[2]); |
703 std::string ct_public_key_data; | 698 std::string ct_public_key_data; |
704 CHECK(base::Base64Decode(log_metadata[1], &ct_public_key_data)) | 699 CHECK(base::Base64Decode(log_metadata[1], &ct_public_key_data)) |
705 << "Unable to decode CT public key."; | 700 << "Unable to decode CT public key."; |
706 scoped_refptr<net::CTLogVerifier> external_log_verifier( | 701 scoped_refptr<net::CTLogVerifier> external_log_verifier( |
707 net::CTLogVerifier::Create(ct_public_key_data, log_description, | 702 net::CTLogVerifier::Create(ct_public_key_data, log_description, |
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1584 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); | 1579 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); |
1585 for (size_t i = 0; i < supported_versions.size(); ++i) { | 1580 for (size_t i = 0; i < supported_versions.size(); ++i) { |
1586 net::QuicVersion version = supported_versions[i]; | 1581 net::QuicVersion version = supported_versions[i]; |
1587 if (net::QuicVersionToString(version) == quic_version) { | 1582 if (net::QuicVersionToString(version) == quic_version) { |
1588 return version; | 1583 return version; |
1589 } | 1584 } |
1590 } | 1585 } |
1591 | 1586 |
1592 return net::QUIC_VERSION_UNSUPPORTED; | 1587 return net::QUIC_VERSION_UNSUPPORTED; |
1593 } | 1588 } |
OLD | NEW |