| OLD | NEW | 
|     1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |     1 // Copyright (c) 2011 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 "base/logging.h" |     7 #include "base/logging.h" | 
|     8 #include "base/stl_util-inl.h" |     8 #include "base/stl_util-inl.h" | 
|     9 #include "base/string_util.h" |     9 #include "base/string_util.h" | 
|    10 #include "base/stringprintf.h" |    10 #include "base/stringprintf.h" | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
|    23 #include "net/socket/client_socket_pool.h" |    23 #include "net/socket/client_socket_pool.h" | 
|    24 #include "net/socket/socks_client_socket_pool.h" |    24 #include "net/socket/socks_client_socket_pool.h" | 
|    25 #include "net/socket/ssl_client_socket.h" |    25 #include "net/socket/ssl_client_socket.h" | 
|    26 #include "net/socket/ssl_client_socket_pool.h" |    26 #include "net/socket/ssl_client_socket_pool.h" | 
|    27 #include "net/spdy/spdy_http_stream.h" |    27 #include "net/spdy/spdy_http_stream.h" | 
|    28 #include "net/spdy/spdy_session.h" |    28 #include "net/spdy/spdy_session.h" | 
|    29 #include "net/spdy/spdy_session_pool.h" |    29 #include "net/spdy/spdy_session_pool.h" | 
|    30  |    30  | 
|    31 namespace net { |    31 namespace net { | 
|    32  |    32  | 
|    33 namespace { |    33 // Parameters associated with the start of a HTTP stream job. | 
 |    34 class HttpStreamJobParameters : public NetLog::EventParameters { | 
 |    35  public: | 
 |    36   static scoped_refptr<HttpStreamJobParameters> Create( | 
 |    37       const GURL& original_url, | 
 |    38       const GURL& url) { | 
 |    39     return make_scoped_refptr(new HttpStreamJobParameters(original_url, url)); | 
 |    40   } | 
|    34  |    41  | 
|    35 }  // namespace |    42   virtual Value* ToValue() const; | 
 |    43  | 
 |    44  private: | 
 |    45   HttpStreamJobParameters(const GURL& original_url, const GURL& url) | 
 |    46       : original_url_(original_url.GetOrigin().spec()), | 
 |    47         url_(url.GetOrigin().spec()) {} | 
 |    48  | 
 |    49   const std::string original_url_; | 
 |    50   const std::string url_; | 
 |    51 }; | 
 |    52  | 
 |    53 Value* HttpStreamJobParameters::ToValue() const { | 
 |    54   DictionaryValue* dict = new DictionaryValue(); | 
 |    55   dict->SetString("original_url", original_url_); | 
 |    56   dict->SetString("url", url_); | 
 |    57   return dict; | 
 |    58 } | 
|    36  |    59  | 
|    37 HttpStreamFactoryImpl::Job::Job(HttpStreamFactoryImpl* stream_factory, |    60 HttpStreamFactoryImpl::Job::Job(HttpStreamFactoryImpl* stream_factory, | 
|    38                                 HttpNetworkSession* session, |    61                                 HttpNetworkSession* session, | 
|    39                                 const HttpRequestInfo& request_info, |    62                                 const HttpRequestInfo& request_info, | 
|    40                                 const SSLConfig& ssl_config, |    63                                 const SSLConfig& ssl_config, | 
|    41                                 const BoundNetLog& net_log) |    64                                 const BoundNetLog& net_log) | 
|    42     : request_(NULL), |    65     : request_(NULL), | 
|    43       request_info_(request_info), |    66       request_info_(request_info), | 
|    44       ssl_config_(ssl_config), |    67       ssl_config_(ssl_config), | 
|    45       net_log_(BoundNetLog::Make(net_log.net_log(), |    68       net_log_(BoundNetLog::Make(net_log.net_log(), | 
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   433         NOTREACHED() << "bad state"; |   456         NOTREACHED() << "bad state"; | 
|   434         rv = ERR_FAILED; |   457         rv = ERR_FAILED; | 
|   435         break; |   458         break; | 
|   436     } |   459     } | 
|   437   } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE); |   460   } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE); | 
|   438   return rv; |   461   return rv; | 
|   439 } |   462 } | 
|   440  |   463  | 
|   441 int HttpStreamFactoryImpl::Job::StartInternal() { |   464 int HttpStreamFactoryImpl::Job::StartInternal() { | 
|   442   CHECK_EQ(STATE_NONE, next_state_); |   465   CHECK_EQ(STATE_NONE, next_state_); | 
 |   466  | 
 |   467   origin_ = HostPortPair(request_info_.url.HostNoBrackets(), | 
 |   468                          request_info_.url.EffectiveIntPort()); | 
 |   469   origin_url_ = HttpStreamFactory::ApplyHostMappingRules( | 
 |   470       request_info_.url, &origin_); | 
 |   471  | 
|   443   net_log_.BeginEvent(NetLog::TYPE_HTTP_STREAM_JOB, |   472   net_log_.BeginEvent(NetLog::TYPE_HTTP_STREAM_JOB, | 
|   444                       make_scoped_refptr(new NetLogStringParameter( |   473                       HttpStreamJobParameters::Create(request_info_.url, | 
|   445                           "url", request_info_.url.GetOrigin().spec()))); |   474                                                       origin_url_)); | 
|   446   next_state_ = STATE_RESOLVE_PROXY; |   475   next_state_ = STATE_RESOLVE_PROXY; | 
|   447   int rv = RunLoop(OK); |   476   int rv = RunLoop(OK); | 
|   448   DCHECK_EQ(ERR_IO_PENDING, rv); |   477   DCHECK_EQ(ERR_IO_PENDING, rv); | 
|   449   return rv; |   478   return rv; | 
|   450 } |   479 } | 
|   451  |   480  | 
|   452 int HttpStreamFactoryImpl::Job::DoResolveProxy() { |   481 int HttpStreamFactoryImpl::Job::DoResolveProxy() { | 
|   453   DCHECK(!pac_request_); |   482   DCHECK(!pac_request_); | 
|   454  |   483  | 
|   455   next_state_ = STATE_RESOLVE_PROXY_COMPLETE; |   484   next_state_ = STATE_RESOLVE_PROXY_COMPLETE; | 
|   456  |   485  | 
|   457   origin_ = HostPortPair(request_info_.url.HostNoBrackets(), |  | 
|   458                          request_info_.url.EffectiveIntPort()); |  | 
|   459  |  | 
|   460   if (request_info_.load_flags & LOAD_BYPASS_PROXY) { |   486   if (request_info_.load_flags & LOAD_BYPASS_PROXY) { | 
|   461     proxy_info_.UseDirect(); |   487     proxy_info_.UseDirect(); | 
|   462     return OK; |   488     return OK; | 
|   463   } |   489   } | 
|   464  |   490  | 
|   465   return session_->proxy_service()->ResolveProxy( |   491   return session_->proxy_service()->ResolveProxy( | 
|   466       request_info_.url, &proxy_info_, &io_callback_, &pac_request_, |   492       request_info_.url, &proxy_info_, &io_callback_, &pac_request_, | 
|   467       net_log_); |   493       net_log_); | 
|   468 } |   494 } | 
|   469  |   495  | 
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   569   if (proxy_info_.is_https()) { |   595   if (proxy_info_.is_https()) { | 
|   570     InitSSLConfig(proxy_info_.proxy_server().host_port_pair(), |   596     InitSSLConfig(proxy_info_.proxy_server().host_port_pair(), | 
|   571                   &ssl_config_for_proxy); |   597                   &ssl_config_for_proxy); | 
|   572   } |   598   } | 
|   573   if (using_ssl_) { |   599   if (using_ssl_) { | 
|   574     InitSSLConfig(origin_, &ssl_config_); |   600     InitSSLConfig(origin_, &ssl_config_); | 
|   575   } |   601   } | 
|   576  |   602  | 
|   577   if (IsPreconnecting()) { |   603   if (IsPreconnecting()) { | 
|   578     return ClientSocketPoolManager::PreconnectSocketsForHttpRequest( |   604     return ClientSocketPoolManager::PreconnectSocketsForHttpRequest( | 
|   579         request_info_, |   605         origin_url_, | 
 |   606         request_info_.referrer, | 
 |   607         request_info_.extra_headers, | 
 |   608         request_info_.load_flags, | 
 |   609         request_info_.priority, | 
|   580         session_, |   610         session_, | 
|   581         proxy_info_, |   611         proxy_info_, | 
|   582         ShouldForceSpdySSL(), |   612         ShouldForceSpdySSL(), | 
|   583         want_spdy_over_npn, |   613         want_spdy_over_npn, | 
|   584         ssl_config_, |   614         ssl_config_, | 
|   585         ssl_config_for_proxy, |   615         ssl_config_for_proxy, | 
|   586         net_log_, |   616         net_log_, | 
|   587         num_streams_); |   617         num_streams_); | 
|   588   } else { |   618   } else { | 
|   589     return ClientSocketPoolManager::InitSocketHandleForHttpRequest( |   619     return ClientSocketPoolManager::InitSocketHandleForHttpRequest( | 
|   590         request_info_, |   620         origin_url_, | 
 |   621         request_info_.referrer, | 
 |   622         request_info_.extra_headers, | 
 |   623         request_info_.load_flags, | 
 |   624         request_info_.priority, | 
|   591         session_, |   625         session_, | 
|   592         proxy_info_, |   626         proxy_info_, | 
|   593         ShouldForceSpdySSL(), |   627         ShouldForceSpdySSL(), | 
|   594         want_spdy_over_npn, |   628         want_spdy_over_npn, | 
|   595         ssl_config_, |   629         ssl_config_, | 
|   596         ssl_config_for_proxy, |   630         ssl_config_for_proxy, | 
|   597         net_log_, |   631         net_log_, | 
|   598         connection_.get(), |   632         connection_.get(), | 
|   599         &io_callback_); |   633         &io_callback_); | 
|   600   } |   634   } | 
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1058 bool HttpStreamFactoryImpl::Job::IsPreconnecting() const { |  1092 bool HttpStreamFactoryImpl::Job::IsPreconnecting() const { | 
|  1059   DCHECK_GE(num_streams_, 0); |  1093   DCHECK_GE(num_streams_, 0); | 
|  1060   return num_streams_ > 0; |  1094   return num_streams_ > 0; | 
|  1061 } |  1095 } | 
|  1062  |  1096  | 
|  1063 bool HttpStreamFactoryImpl::Job::IsOrphaned() const { |  1097 bool HttpStreamFactoryImpl::Job::IsOrphaned() const { | 
|  1064   return !IsPreconnecting() && !request_; |  1098   return !IsPreconnecting() && !request_; | 
|  1065 } |  1099 } | 
|  1066  |  1100  | 
|  1067 }  // namespace net |  1101 }  // namespace net | 
| OLD | NEW |