Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1235)

Side by Side Diff: net/http/http_pipelined_stream.cc

Issue 8990001: base::Bind: Convert most of net/http. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clang. Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_pipelined_stream.h" 5 #include "net/http/http_pipelined_stream.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "net/http/http_pipelined_connection_impl.h" 10 #include "net/http/http_pipelined_connection_impl.h"
11 #include "net/http/http_request_headers.h" 11 #include "net/http/http_request_headers.h"
12 #include "net/http/http_request_info.h" 12 #include "net/http/http_request_info.h"
13 #include "net/http/http_util.h" 13 #include "net/http/http_util.h"
14 14
15 namespace net { 15 namespace net {
16 16
17 HttpPipelinedStream::HttpPipelinedStream(HttpPipelinedConnectionImpl* pipeline, 17 HttpPipelinedStream::HttpPipelinedStream(HttpPipelinedConnectionImpl* pipeline,
18 int pipeline_id) 18 int pipeline_id)
19 : pipeline_(pipeline), 19 : pipeline_(pipeline),
20 pipeline_id_(pipeline_id), 20 pipeline_id_(pipeline_id),
21 request_info_(NULL) { 21 request_info_(NULL) {
22 } 22 }
23 23
24 HttpPipelinedStream::~HttpPipelinedStream() { 24 HttpPipelinedStream::~HttpPipelinedStream() {
25 pipeline_->OnStreamDeleted(pipeline_id_); 25 pipeline_->OnStreamDeleted(pipeline_id_);
26 } 26 }
27 27
28 int HttpPipelinedStream::InitializeStream(const HttpRequestInfo* request_info, 28 int HttpPipelinedStream::InitializeStream(
29 const BoundNetLog& net_log, 29 const HttpRequestInfo* request_info, const BoundNetLog& net_log,
30 OldCompletionCallback* callback) { 30 const CompletionCallback& callback) {
31 request_info_ = request_info; 31 request_info_ = request_info;
32 pipeline_->InitializeParser(pipeline_id_, request_info, net_log); 32 pipeline_->InitializeParser(pipeline_id_, request_info, net_log);
33 return OK; 33 return OK;
34 } 34 }
35 35
36 36
37 int HttpPipelinedStream::SendRequest(const HttpRequestHeaders& headers, 37 int HttpPipelinedStream::SendRequest(
38 UploadDataStream* request_body, 38 const HttpRequestHeaders& headers, UploadDataStream* request_body,
39 HttpResponseInfo* response, 39 HttpResponseInfo* response, const CompletionCallback& callback) {
40 OldCompletionCallback* callback) {
41 CHECK(pipeline_id_); 40 CHECK(pipeline_id_);
42 CHECK(request_info_); 41 CHECK(request_info_);
43 // TODO(simonjam): Proxy support will be needed here. 42 // TODO(simonjam): Proxy support will be needed here.
44 const std::string path = HttpUtil::PathForRequest(request_info_->url); 43 const std::string path = HttpUtil::PathForRequest(request_info_->url);
45 std::string request_line_ = base::StringPrintf("%s %s HTTP/1.1\r\n", 44 std::string request_line_ = base::StringPrintf("%s %s HTTP/1.1\r\n",
46 request_info_->method.c_str(), 45 request_info_->method.c_str(),
47 path.c_str()); 46 path.c_str());
48 return pipeline_->SendRequest(pipeline_id_, request_line_, headers, 47 return pipeline_->SendRequest(pipeline_id_, request_line_, headers,
49 request_body, response, callback); 48 request_body, response, callback);
50 } 49 }
51 50
52 uint64 HttpPipelinedStream::GetUploadProgress() const { 51 uint64 HttpPipelinedStream::GetUploadProgress() const {
53 return pipeline_->GetUploadProgress(pipeline_id_); 52 return pipeline_->GetUploadProgress(pipeline_id_);
54 } 53 }
55 54
56 int HttpPipelinedStream::ReadResponseHeaders(OldCompletionCallback* callback) { 55 int HttpPipelinedStream::ReadResponseHeaders(
56 const CompletionCallback& callback) {
57 return pipeline_->ReadResponseHeaders(pipeline_id_, callback); 57 return pipeline_->ReadResponseHeaders(pipeline_id_, callback);
58 } 58 }
59 59
60 const HttpResponseInfo* HttpPipelinedStream::GetResponseInfo() const { 60 const HttpResponseInfo* HttpPipelinedStream::GetResponseInfo() const {
61 return pipeline_->GetResponseInfo(pipeline_id_); 61 return pipeline_->GetResponseInfo(pipeline_id_);
62 } 62 }
63 63
64 int HttpPipelinedStream::ReadResponseBody(IOBuffer* buf, int buf_len, 64 int HttpPipelinedStream::ReadResponseBody(IOBuffer* buf, int buf_len,
65 OldCompletionCallback* callback) { 65 const CompletionCallback& callback) {
66 return pipeline_->ReadResponseBody(pipeline_id_, buf, buf_len, callback); 66 return pipeline_->ReadResponseBody(pipeline_id_, buf, buf_len, callback);
67 } 67 }
68 68
69 void HttpPipelinedStream::Close(bool not_reusable) { 69 void HttpPipelinedStream::Close(bool not_reusable) {
70 pipeline_->Close(pipeline_id_, not_reusable); 70 pipeline_->Close(pipeline_id_, not_reusable);
71 } 71 }
72 72
73 HttpStream* HttpPipelinedStream::RenewStreamForAuth() { 73 HttpStream* HttpPipelinedStream::RenewStreamForAuth() {
74 if (pipeline_->usable()) { 74 if (pipeline_->usable()) {
75 return pipeline_->CreateNewStream(); 75 return pipeline_->CreateNewStream();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 132
133 const BoundNetLog& HttpPipelinedStream::net_log() const { 133 const BoundNetLog& HttpPipelinedStream::net_log() const {
134 return pipeline_->net_log(); 134 return pipeline_->net_log();
135 } 135 }
136 136
137 bool HttpPipelinedStream::was_npn_negotiated() const { 137 bool HttpPipelinedStream::was_npn_negotiated() const {
138 return pipeline_->was_npn_negotiated(); 138 return pipeline_->was_npn_negotiated();
139 } 139 }
140 140
141 } // namespace net 141 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698