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_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
12 #include "base/values.h" | |
12 #include "net/base/connection_type_histograms.h" | 13 #include "net/base/connection_type_histograms.h" |
13 #include "net/base/net_log.h" | 14 #include "net/base/net_log.h" |
14 #include "net/base/net_util.h" | 15 #include "net/base/net_util.h" |
15 #include "net/base/ssl_cert_request_info.h" | 16 #include "net/base/ssl_cert_request_info.h" |
16 #include "net/http/http_basic_stream.h" | 17 #include "net/http/http_basic_stream.h" |
17 #include "net/http/http_network_session.h" | 18 #include "net/http/http_network_session.h" |
18 #include "net/http/http_proxy_client_socket.h" | 19 #include "net/http/http_proxy_client_socket.h" |
19 #include "net/http/http_proxy_client_socket_pool.h" | 20 #include "net/http/http_proxy_client_socket_pool.h" |
20 #include "net/http/http_request_info.h" | 21 #include "net/http/http_request_info.h" |
21 #include "net/http/http_stream_factory_impl_request.h" | 22 #include "net/http/http_stream_factory_impl_request.h" |
(...skipping 15 matching lines...) Expand all Loading... | |
37 GURL::Replacements replacements; | 38 GURL::Replacements replacements; |
38 // new_sheme and new_port need to be in scope here because GURL::Replacements | 39 // new_sheme and new_port need to be in scope here because GURL::Replacements |
39 // references the memory contained by them directly. | 40 // references the memory contained by them directly. |
40 const std::string new_scheme = "https"; | 41 const std::string new_scheme = "https"; |
41 const std::string new_port = base::IntToString(443); | 42 const std::string new_port = base::IntToString(443); |
42 replacements.SetSchemeStr(new_scheme); | 43 replacements.SetSchemeStr(new_scheme); |
43 replacements.SetPortStr(new_port); | 44 replacements.SetPortStr(new_port); |
44 return original_url.ReplaceComponents(replacements); | 45 return original_url.ReplaceComponents(replacements); |
45 } | 46 } |
46 | 47 |
48 // Parameters associated with the creation of a Job. | |
49 class JobCreationParameters : public NetLog::EventParameters { | |
mmenke
2011/02/28 15:57:28
This class isn't needed - see below.
| |
50 public: | |
51 JobCreationParameters(const std::string& url) : url_(url) {} | |
52 | |
53 virtual Value* ToValue() const { | |
54 DictionaryValue* dict = new DictionaryValue(); | |
55 dict->SetString("url", url_); | |
56 return dict; | |
57 } | |
58 | |
59 private: | |
60 const std::string url_; | |
61 }; | |
62 | |
47 } // namespace | 63 } // namespace |
48 | 64 |
49 HttpStreamFactoryImpl::Job::Job(HttpStreamFactoryImpl* stream_factory, | 65 HttpStreamFactoryImpl::Job::Job(HttpStreamFactoryImpl* stream_factory, |
50 HttpNetworkSession* session) | 66 HttpNetworkSession* session) |
51 : request_(NULL), | 67 : request_(NULL), |
52 ALLOW_THIS_IN_INITIALIZER_LIST(io_callback_(this, &Job::OnIOComplete)), | 68 ALLOW_THIS_IN_INITIALIZER_LIST(io_callback_(this, &Job::OnIOComplete)), |
53 connection_(new ClientSocketHandle), | 69 connection_(new ClientSocketHandle), |
54 session_(session), | 70 session_(session), |
55 stream_factory_(stream_factory), | 71 stream_factory_(stream_factory), |
56 next_state_(STATE_NONE), | 72 next_state_(STATE_NONE), |
(...skipping 12 matching lines...) Expand all Loading... | |
69 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { | 85 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { |
70 DCHECK(stream_factory); | 86 DCHECK(stream_factory); |
71 DCHECK(session); | 87 DCHECK(session); |
72 if (HttpStreamFactory::use_alternate_protocols()) | 88 if (HttpStreamFactory::use_alternate_protocols()) |
73 alternate_protocol_mode_ = kUnspecified; | 89 alternate_protocol_mode_ = kUnspecified; |
74 else | 90 else |
75 alternate_protocol_mode_ = kDoNotUseAlternateProtocol; | 91 alternate_protocol_mode_ = kDoNotUseAlternateProtocol; |
76 } | 92 } |
77 | 93 |
78 HttpStreamFactoryImpl::Job::~Job() { | 94 HttpStreamFactoryImpl::Job::~Job() { |
95 net_log_.EndEvent(NetLog::TYPE_HTTP_STREAM_JOB, NULL); | |
96 | |
79 // When we're in a partially constructed state, waiting for the user to | 97 // When we're in a partially constructed state, waiting for the user to |
80 // provide certificate handling information or authentication, we can't reuse | 98 // provide certificate handling information or authentication, we can't reuse |
81 // this stream at all. | 99 // this stream at all. |
82 if (next_state_ == STATE_WAITING_USER_ACTION) { | 100 if (next_state_ == STATE_WAITING_USER_ACTION) { |
83 connection_->socket()->Disconnect(); | 101 connection_->socket()->Disconnect(); |
84 connection_.reset(); | 102 connection_.reset(); |
85 } | 103 } |
86 | 104 |
87 if (pac_request_) | 105 if (pac_request_) |
88 session_->proxy_service()->CancelPacRequest(pac_request_); | 106 session_->proxy_service()->CancelPacRequest(pac_request_); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
157 DCHECK(connection_.get() && connection_->socket()); | 175 DCHECK(connection_.get() && connection_->socket()); |
158 SSLClientSocket* ssl_socket = | 176 SSLClientSocket* ssl_socket = |
159 static_cast<SSLClientSocket*>(connection_->socket()); | 177 static_cast<SSLClientSocket*>(connection_->socket()); |
160 ssl_socket->GetSSLInfo(&ssl_info_); | 178 ssl_socket->GetSSLInfo(&ssl_info_); |
161 } | 179 } |
162 | 180 |
163 void HttpStreamFactoryImpl::Job::OnStreamReadyCallback() { | 181 void HttpStreamFactoryImpl::Job::OnStreamReadyCallback() { |
164 DCHECK(stream_.get()); | 182 DCHECK(stream_.get()); |
165 request_->Complete(was_alternate_protocol_available(), | 183 request_->Complete(was_alternate_protocol_available(), |
166 was_npn_negotiated(), | 184 was_npn_negotiated(), |
167 using_spdy()); | 185 using_spdy(), |
186 net_log_.source()); | |
168 request_->OnStreamReady(ssl_config_, proxy_info_, stream_.release()); | 187 request_->OnStreamReady(ssl_config_, proxy_info_, stream_.release()); |
169 // |this| may be deleted after this call. | 188 // |this| may be deleted after this call. |
170 } | 189 } |
171 | 190 |
172 void HttpStreamFactoryImpl::Job::OnSpdySessionReadyCallback() { | 191 void HttpStreamFactoryImpl::Job::OnSpdySessionReadyCallback() { |
173 DCHECK(!stream_.get()); | 192 DCHECK(!stream_.get()); |
174 DCHECK(using_spdy()); | 193 DCHECK(using_spdy()); |
175 DCHECK(new_spdy_session_); | 194 DCHECK(new_spdy_session_); |
176 scoped_refptr<SpdySession> spdy_session = new_spdy_session_; | 195 scoped_refptr<SpdySession> spdy_session = new_spdy_session_; |
177 new_spdy_session_ = NULL; | 196 new_spdy_session_ = NULL; |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 return rv; | 387 return rv; |
369 } | 388 } |
370 | 389 |
371 int HttpStreamFactoryImpl::Job::StartInternal( | 390 int HttpStreamFactoryImpl::Job::StartInternal( |
372 const HttpRequestInfo& request_info, | 391 const HttpRequestInfo& request_info, |
373 const SSLConfig& ssl_config, | 392 const SSLConfig& ssl_config, |
374 const BoundNetLog& net_log) { | 393 const BoundNetLog& net_log) { |
375 CHECK_EQ(STATE_NONE, next_state_); | 394 CHECK_EQ(STATE_NONE, next_state_); |
376 request_info_ = request_info; | 395 request_info_ = request_info; |
377 ssl_config_ = ssl_config; | 396 ssl_config_ = ssl_config; |
378 net_log_ = net_log; | 397 net_log_ = BoundNetLog::Make(net_log.net_log(), |
398 NetLog::SOURCE_HTTP_STREAM_JOB); | |
399 net_log_.BeginEvent(NetLog::TYPE_HTTP_STREAM_JOB, | |
400 make_scoped_refptr(new JobCreationParameters( | |
401 request_info.url.GetOrigin().spec()))); | |
mmenke
2011/02/28 15:57:28
You can just use:
new NetLogStringParameter("url",
| |
379 next_state_ = STATE_RESOLVE_PROXY; | 402 next_state_ = STATE_RESOLVE_PROXY; |
380 int rv = RunLoop(OK); | 403 int rv = RunLoop(OK); |
381 DCHECK_EQ(ERR_IO_PENDING, rv); | 404 DCHECK_EQ(ERR_IO_PENDING, rv); |
382 return rv; | 405 return rv; |
383 } | 406 } |
384 | 407 |
385 int HttpStreamFactoryImpl::Job::DoResolveProxy() { | 408 int HttpStreamFactoryImpl::Job::DoResolveProxy() { |
386 DCHECK(!pac_request_); | 409 DCHECK(!pac_request_); |
387 | 410 |
388 next_state_ = STATE_RESOLVE_PROXY_COMPLETE; | 411 next_state_ = STATE_RESOLVE_PROXY_COMPLETE; |
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1120 break; | 1143 break; |
1121 } | 1144 } |
1122 } | 1145 } |
1123 | 1146 |
1124 bool HttpStreamFactoryImpl::Job::IsPreconnecting() const { | 1147 bool HttpStreamFactoryImpl::Job::IsPreconnecting() const { |
1125 DCHECK_GE(num_streams_, 0); | 1148 DCHECK_GE(num_streams_, 0); |
1126 return num_streams_ > 0; | 1149 return num_streams_ > 0; |
1127 } | 1150 } |
1128 | 1151 |
1129 } // namespace net | 1152 } // namespace net |
OLD | NEW |