| 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/http/http_stream_factory_impl_job.h" | 5 #include "net/http/http_stream_factory_impl_job.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "base/location.h" | 12 #include "base/location.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.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/profiler/scoped_tracker.h" | 16 #include "base/profiler/scoped_tracker.h" |
| 17 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
| 18 #include "base/stl_util.h" | 18 #include "base/stl_util.h" |
| 19 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
| 20 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.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 "build/build_config.h" | 24 #include "build/build_config.h" |
| 25 #include "net/base/port_util.h" | 25 #include "net/base/port_util.h" |
| 26 #include "net/base/proxy_delegate.h" | 26 #include "net/base/proxy_delegate.h" |
| 27 #include "net/base/trace_constants.h" |
| 27 #include "net/cert/cert_verifier.h" | 28 #include "net/cert/cert_verifier.h" |
| 28 #include "net/http/bidirectional_stream_impl.h" | 29 #include "net/http/bidirectional_stream_impl.h" |
| 29 #include "net/http/http_basic_stream.h" | 30 #include "net/http/http_basic_stream.h" |
| 30 #include "net/http/http_network_session.h" | 31 #include "net/http/http_network_session.h" |
| 31 #include "net/http/http_proxy_client_socket.h" | 32 #include "net/http/http_proxy_client_socket.h" |
| 32 #include "net/http/http_proxy_client_socket_pool.h" | 33 #include "net/http/http_proxy_client_socket_pool.h" |
| 33 #include "net/http/http_request_info.h" | 34 #include "net/http/http_request_info.h" |
| 34 #include "net/http/http_server_properties.h" | 35 #include "net/http/http_server_properties.h" |
| 35 #include "net/http/http_stream_factory.h" | 36 #include "net/http/http_stream_factory.h" |
| 36 #include "net/http/http_stream_factory_impl_request.h" | 37 #include "net/http/http_stream_factory_impl_request.h" |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 // It is OK to dereference spdy_session_pool, because the | 494 // It is OK to dereference spdy_session_pool, because the |
| 494 // ClientSocketPoolManager will be destroyed in the same callback that | 495 // ClientSocketPoolManager will be destroyed in the same callback that |
| 495 // destroys the SpdySessionPool. | 496 // destroys the SpdySessionPool. |
| 496 return spdy_session_pool->FindAvailableSession(spdy_session_key, origin_url, | 497 return spdy_session_pool->FindAvailableSession(spdy_session_key, origin_url, |
| 497 net_log) | 498 net_log) |
| 498 ? ERR_SPDY_SESSION_ALREADY_EXISTS | 499 ? ERR_SPDY_SESSION_ALREADY_EXISTS |
| 499 : OK; | 500 : OK; |
| 500 } | 501 } |
| 501 | 502 |
| 502 void HttpStreamFactoryImpl::Job::OnIOComplete(int result) { | 503 void HttpStreamFactoryImpl::Job::OnIOComplete(int result) { |
| 503 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), | 504 TRACE_EVENT0(kNetTracingCategory, "HttpStreamFactoryImpl::Job::OnIOComplete"); |
| 504 "HttpStreamFactoryImpl::Job::OnIOComplete"); | |
| 505 RunLoop(result); | 505 RunLoop(result); |
| 506 } | 506 } |
| 507 | 507 |
| 508 int HttpStreamFactoryImpl::Job::RunLoop(int result) { | 508 int HttpStreamFactoryImpl::Job::RunLoop(int result) { |
| 509 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("net"), | 509 TRACE_EVENT0(kNetTracingCategory, "HttpStreamFactoryImpl::Job::RunLoop"); |
| 510 "HttpStreamFactoryImpl::Job::RunLoop"); | |
| 511 result = DoLoop(result); | 510 result = DoLoop(result); |
| 512 | 511 |
| 513 if (result == ERR_IO_PENDING) | 512 if (result == ERR_IO_PENDING) |
| 514 return result; | 513 return result; |
| 515 | 514 |
| 516 if (job_type_ == PRECONNECT) { | 515 if (job_type_ == PRECONNECT) { |
| 517 base::ThreadTaskRunnerHandle::Get()->PostTask( | 516 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 518 FROM_HERE, | 517 FROM_HERE, |
| 519 base::Bind(&HttpStreamFactoryImpl::Job::OnPreconnectsComplete, | 518 base::Bind(&HttpStreamFactoryImpl::Job::OnPreconnectsComplete, |
| 520 ptr_factory_.GetWeakPtr())); | 519 ptr_factory_.GetWeakPtr())); |
| (...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1499 | 1498 |
| 1500 ConnectionAttempts socket_attempts = connection_->connection_attempts(); | 1499 ConnectionAttempts socket_attempts = connection_->connection_attempts(); |
| 1501 if (connection_->socket()) { | 1500 if (connection_->socket()) { |
| 1502 connection_->socket()->GetConnectionAttempts(&socket_attempts); | 1501 connection_->socket()->GetConnectionAttempts(&socket_attempts); |
| 1503 } | 1502 } |
| 1504 | 1503 |
| 1505 delegate_->AddConnectionAttemptsToRequest(this, socket_attempts); | 1504 delegate_->AddConnectionAttemptsToRequest(this, socket_attempts); |
| 1506 } | 1505 } |
| 1507 | 1506 |
| 1508 } // namespace net | 1507 } // namespace net |
| OLD | NEW |