| 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 "net/quic/chromium/quic_stream_factory.h" | 5 #include "net/quic/chromium/quic_stream_factory.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <tuple> | 8 #include <tuple> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/metrics/field_trial.h" | 13 #include "base/metrics/field_trial.h" |
| 14 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
| 15 #include "base/metrics/sparse_histogram.h" | 15 #include "base/metrics/sparse_histogram.h" |
| 16 #include "base/rand_util.h" | 16 #include "base/rand_util.h" |
| 17 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
| 18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
| 20 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
| 21 #include "base/threading/thread_task_runner_handle.h" | 21 #include "base/threading/thread_task_runner_handle.h" |
| 22 #include "base/trace_event/trace_event.h" | 22 #include "base/trace_event/trace_event.h" |
| 23 #include "base/values.h" | 23 #include "base/values.h" |
| 24 #include "crypto/openssl_util.h" | 24 #include "crypto/openssl_util.h" |
| 25 #include "net/base/ip_address.h" | 25 #include "net/base/ip_address.h" |
| 26 #include "net/base/net_errors.h" | 26 #include "net/base/net_errors.h" |
| 27 #include "net/base/proxy_delegate.h" | 27 #include "net/base/proxy_delegate.h" |
| 28 #include "net/base/trace_constants.h" |
| 28 #include "net/cert/cert_verifier.h" | 29 #include "net/cert/cert_verifier.h" |
| 29 #include "net/cert/ct_verifier.h" | 30 #include "net/cert/ct_verifier.h" |
| 30 #include "net/dns/host_resolver.h" | 31 #include "net/dns/host_resolver.h" |
| 31 #include "net/http/bidirectional_stream_impl.h" | 32 #include "net/http/bidirectional_stream_impl.h" |
| 32 #include "net/log/net_log_capture_mode.h" | 33 #include "net/log/net_log_capture_mode.h" |
| 33 #include "net/log/net_log_event_type.h" | 34 #include "net/log/net_log_event_type.h" |
| 34 #include "net/log/net_log_source_type.h" | 35 #include "net/log/net_log_source_type.h" |
| 35 #include "net/quic/chromium/bidirectional_stream_quic_impl.h" | 36 #include "net/quic/chromium/bidirectional_stream_quic_impl.h" |
| 36 #include "net/quic/chromium/crypto/channel_id_chromium.h" | 37 #include "net/quic/chromium/crypto/channel_id_chromium.h" |
| 37 #include "net/quic/chromium/crypto/proof_verifier_chromium.h" | 38 #include "net/quic/chromium/crypto/proof_verifier_chromium.h" |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 | 394 |
| 394 int QuicStreamFactory::Job::Run(const CompletionCallback& callback) { | 395 int QuicStreamFactory::Job::Run(const CompletionCallback& callback) { |
| 395 int rv = DoLoop(OK); | 396 int rv = DoLoop(OK); |
| 396 if (rv == ERR_IO_PENDING) | 397 if (rv == ERR_IO_PENDING) |
| 397 callback_ = callback; | 398 callback_ = callback; |
| 398 | 399 |
| 399 return rv > 0 ? OK : rv; | 400 return rv > 0 ? OK : rv; |
| 400 } | 401 } |
| 401 | 402 |
| 402 int QuicStreamFactory::Job::DoLoop(int rv) { | 403 int QuicStreamFactory::Job::DoLoop(int rv) { |
| 403 TRACE_EVENT0("net", "QuicStreamFactory::Job::DoLoop"); | 404 TRACE_EVENT0(kNetTracingCategory, "QuicStreamFactory::Job::DoLoop"); |
| 404 do { | 405 do { |
| 405 IoState state = io_state_; | 406 IoState state = io_state_; |
| 406 io_state_ = STATE_NONE; | 407 io_state_ = STATE_NONE; |
| 407 switch (state) { | 408 switch (state) { |
| 408 case STATE_RESOLVE_HOST: | 409 case STATE_RESOLVE_HOST: |
| 409 CHECK_EQ(OK, rv); | 410 CHECK_EQ(OK, rv); |
| 410 rv = DoResolveHost(); | 411 rv = DoResolveHost(); |
| 411 break; | 412 break; |
| 412 case STATE_RESOLVE_HOST_COMPLETE: | 413 case STATE_RESOLVE_HOST_COMPLETE: |
| 413 rv = DoResolveHostComplete(rv); | 414 rv = DoResolveHostComplete(rv); |
| (...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1605 QuicChromiumClientSession** session) { | 1606 QuicChromiumClientSession** session) { |
| 1606 if (need_to_evaluate_consecutive_disabled_count_) { | 1607 if (need_to_evaluate_consecutive_disabled_count_) { |
| 1607 task_runner_->PostDelayedTask( | 1608 task_runner_->PostDelayedTask( |
| 1608 FROM_HERE, | 1609 FROM_HERE, |
| 1609 base::Bind(&QuicStreamFactory::MaybeClearConsecutiveDisabledCount, | 1610 base::Bind(&QuicStreamFactory::MaybeClearConsecutiveDisabledCount, |
| 1610 weak_factory_.GetWeakPtr()), | 1611 weak_factory_.GetWeakPtr()), |
| 1611 base::TimeDelta::FromSeconds(kDisableQuicTimeoutSecs)); | 1612 base::TimeDelta::FromSeconds(kDisableQuicTimeoutSecs)); |
| 1612 | 1613 |
| 1613 need_to_evaluate_consecutive_disabled_count_ = false; | 1614 need_to_evaluate_consecutive_disabled_count_ = false; |
| 1614 } | 1615 } |
| 1615 TRACE_EVENT0("net", "QuicStreamFactory::CreateSession"); | 1616 TRACE_EVENT0(kNetTracingCategory, "QuicStreamFactory::CreateSession"); |
| 1616 IPEndPoint addr = *address_list.begin(); | 1617 IPEndPoint addr = *address_list.begin(); |
| 1617 const QuicServerId& server_id = key.server_id(); | 1618 const QuicServerId& server_id = key.server_id(); |
| 1618 DatagramSocket::BindType bind_type = DatagramSocket::DEFAULT_BIND; | 1619 DatagramSocket::BindType bind_type = DatagramSocket::DEFAULT_BIND; |
| 1619 std::unique_ptr<DatagramClientSocket> socket( | 1620 std::unique_ptr<DatagramClientSocket> socket( |
| 1620 client_socket_factory_->CreateDatagramClientSocket( | 1621 client_socket_factory_->CreateDatagramClientSocket( |
| 1621 bind_type, RandIntCallback(), net_log.net_log(), net_log.source())); | 1622 bind_type, RandIntCallback(), net_log.net_log(), net_log.source())); |
| 1622 | 1623 |
| 1623 // Passing in kInvalidNetworkHandle binds socket to default network. | 1624 // Passing in kInvalidNetworkHandle binds socket to default network. |
| 1624 int rv = ConfigureSocket(socket.get(), addr, | 1625 int rv = ConfigureSocket(socket.get(), addr, |
| 1625 NetworkChangeNotifier::kInvalidNetworkHandle); | 1626 NetworkChangeNotifier::kInvalidNetworkHandle); |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1899 void QuicStreamFactory::OpenFactory() { | 1900 void QuicStreamFactory::OpenFactory() { |
| 1900 status_ = OPEN; | 1901 status_ = OPEN; |
| 1901 } | 1902 } |
| 1902 | 1903 |
| 1903 void QuicStreamFactory::MaybeClearConsecutiveDisabledCount() { | 1904 void QuicStreamFactory::MaybeClearConsecutiveDisabledCount() { |
| 1904 if (status_ == OPEN) | 1905 if (status_ == OPEN) |
| 1905 consecutive_disabled_count_ = 0; | 1906 consecutive_disabled_count_ = 0; |
| 1906 } | 1907 } |
| 1907 | 1908 |
| 1908 } // namespace net | 1909 } // namespace net |
| OLD | NEW |