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/spdy/spdy_http_stream.h" | 5 #include "net/spdy/spdy_http_stream.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <list> | 8 #include <list> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
15 #include "base/stringprintf.h" | |
16 #include "base/values.h" | |
15 #include "net/base/address_list.h" | 17 #include "net/base/address_list.h" |
16 #include "net/base/host_port_pair.h" | 18 #include "net/base/host_port_pair.h" |
17 #include "net/base/load_flags.h" | 19 #include "net/base/load_flags.h" |
20 #include "net/base/net_log.h" | |
18 #include "net/base/net_util.h" | 21 #include "net/base/net_util.h" |
19 #include "net/http/http_request_headers.h" | 22 #include "net/http/http_request_headers.h" |
20 #include "net/http/http_request_info.h" | 23 #include "net/http/http_request_info.h" |
21 #include "net/http/http_response_info.h" | 24 #include "net/http/http_response_info.h" |
22 #include "net/http/http_util.h" | 25 #include "net/http/http_util.h" |
23 #include "net/spdy/spdy_http_utils.h" | 26 #include "net/spdy/spdy_http_utils.h" |
24 #include "net/spdy/spdy_session.h" | 27 #include "net/spdy/spdy_session.h" |
25 | 28 |
26 namespace net { | 29 namespace net { |
27 | 30 |
31 namespace { | |
32 | |
33 Value* NetLogSpdySendRequestCallback(const SpdyHeaderBlock& headers, | |
eroman
2012/07/31 19:45:39
IMPORTANT: Define this parameter as a |const SpdyH
szym
2012/07/31 22:49:34
I believe that the same can be accomplished with b
eroman
2012/08/01 00:20:29
Thanks for the info szym, I didn't know about that
| |
34 NetLog::LogLevel /* log_level */) { | |
ramant (doing other things)
2012/07/31 19:48:57
nit: +1 to eroman's comments. Was wondering why we
| |
35 DictionaryValue* dict = new DictionaryValue(); | |
36 ListValue* headers_list = new ListValue(); | |
37 for (SpdyHeaderBlock::const_iterator it = headers.begin(); | |
38 it != headers.end(); ++it) { | |
39 headers_list->Append(new StringValue(base::StringPrintf( | |
40 "%s: %s", it->first.c_str(), it->second.c_str()))); | |
41 } | |
42 dict->Set("headers", headers_list); | |
43 return dict; | |
44 } | |
45 | |
46 } // namespace | |
47 | |
28 SpdyHttpStream::SpdyHttpStream(SpdySession* spdy_session, | 48 SpdyHttpStream::SpdyHttpStream(SpdySession* spdy_session, |
29 bool direct) | 49 bool direct) |
30 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), | 50 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), |
31 stream_(NULL), | 51 stream_(NULL), |
32 spdy_session_(spdy_session), | 52 spdy_session_(spdy_session), |
33 response_info_(NULL), | 53 response_info_(NULL), |
34 download_finished_(false), | 54 download_finished_(false), |
35 response_headers_received_(false), | 55 response_headers_received_(false), |
36 user_buffer_len_(0), | 56 user_buffer_len_(0), |
37 buffered_read_callback_pending_(false), | 57 buffered_read_callback_pending_(false), |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
191 const CompletionCallback& callback) { | 211 const CompletionCallback& callback) { |
192 base::Time request_time = base::Time::Now(); | 212 base::Time request_time = base::Time::Now(); |
193 CHECK(stream_.get()); | 213 CHECK(stream_.get()); |
194 | 214 |
195 stream_->SetDelegate(this); | 215 stream_->SetDelegate(this); |
196 | 216 |
197 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock); | 217 scoped_ptr<SpdyHeaderBlock> headers(new SpdyHeaderBlock); |
198 CreateSpdyHeadersFromHttpRequest(*request_info_, request_headers, | 218 CreateSpdyHeadersFromHttpRequest(*request_info_, request_headers, |
199 headers.get(), stream_->GetProtocolVersion(), | 219 headers.get(), stream_->GetProtocolVersion(), |
200 direct_); | 220 direct_); |
221 stream_->net_log().AddEvent( | |
222 NetLog::TYPE_HTTP_TRANSACTION_SPDY_SEND_REQUEST_HEADERS, | |
223 base::Bind(&NetLogSpdySendRequestCallback, *headers)); | |
201 stream_->set_spdy_headers(headers.Pass()); | 224 stream_->set_spdy_headers(headers.Pass()); |
202 | 225 |
203 stream_->SetRequestTime(request_time); | 226 stream_->SetRequestTime(request_time); |
204 // This should only get called in the case of a request occurring | 227 // This should only get called in the case of a request occurring |
205 // during server push that has already begun but hasn't finished, | 228 // during server push that has already begun but hasn't finished, |
206 // so we set the response's request time to be the actual one | 229 // so we set the response's request time to be the actual one |
207 if (response_info_) | 230 if (response_info_) |
208 response_info_->request_time = request_time; | 231 response_info_->request_time = request_time; |
209 | 232 |
210 CHECK(!request_body_stream_.get()); | 233 CHECK(!request_body_stream_.get()); |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
527 bool SpdyHttpStream::IsSpdyHttpStream() const { | 550 bool SpdyHttpStream::IsSpdyHttpStream() const { |
528 return true; | 551 return true; |
529 } | 552 } |
530 | 553 |
531 void SpdyHttpStream::Drain(HttpNetworkSession* session) { | 554 void SpdyHttpStream::Drain(HttpNetworkSession* session) { |
532 Close(false); | 555 Close(false); |
533 delete this; | 556 delete this; |
534 } | 557 } |
535 | 558 |
536 } // namespace net | 559 } // namespace net |
OLD | NEW |