Add a function to create a bookmark app from a WebApplicationInfo.
[chromium-blink-merge.git] / net / http / http_pipelined_stream.cc
blobcc267e2510ec78b07e10764ff4e616c649a9d67f
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
3 // found in the LICENSE file.
5 #include "net/http/http_pipelined_stream.h"
7 #include "base/logging.h"
8 #include "base/strings/stringprintf.h"
9 #include "net/base/net_errors.h"
10 #include "net/http/http_pipelined_connection_impl.h"
11 #include "net/http/http_request_headers.h"
12 #include "net/http/http_request_info.h"
13 #include "net/http/http_util.h"
15 namespace net {
17 HttpPipelinedStream::HttpPipelinedStream(HttpPipelinedConnectionImpl* pipeline,
18 int pipeline_id)
19 : pipeline_(pipeline),
20 pipeline_id_(pipeline_id),
21 request_info_(NULL) {
24 HttpPipelinedStream::~HttpPipelinedStream() {
25 pipeline_->OnStreamDeleted(pipeline_id_);
28 int HttpPipelinedStream::InitializeStream(
29 const HttpRequestInfo* request_info,
30 RequestPriority priority,
31 const BoundNetLog& net_log,
32 const CompletionCallback& callback) {
33 request_info_ = request_info;
34 pipeline_->InitializeParser(pipeline_id_, request_info, net_log);
35 return OK;
39 int HttpPipelinedStream::SendRequest(const HttpRequestHeaders& headers,
40 HttpResponseInfo* response,
41 const CompletionCallback& callback) {
42 CHECK(pipeline_id_);
43 CHECK(request_info_);
44 // TODO(simonjam): Proxy support will be needed here.
45 const std::string path = HttpUtil::PathForRequest(request_info_->url);
46 std::string request_line_ = base::StringPrintf("%s %s HTTP/1.1\r\n",
47 request_info_->method.c_str(),
48 path.c_str());
49 return pipeline_->SendRequest(pipeline_id_, request_line_, headers, response,
50 callback);
53 UploadProgress HttpPipelinedStream::GetUploadProgress() const {
54 return pipeline_->GetUploadProgress(pipeline_id_);
57 int HttpPipelinedStream::ReadResponseHeaders(
58 const CompletionCallback& callback) {
59 return pipeline_->ReadResponseHeaders(pipeline_id_, callback);
62 const HttpResponseInfo* HttpPipelinedStream::GetResponseInfo() const {
63 return pipeline_->GetResponseInfo(pipeline_id_);
66 int HttpPipelinedStream::ReadResponseBody(IOBuffer* buf, int buf_len,
67 const CompletionCallback& callback) {
68 return pipeline_->ReadResponseBody(pipeline_id_, buf, buf_len, callback);
71 void HttpPipelinedStream::Close(bool not_reusable) {
72 pipeline_->Close(pipeline_id_, not_reusable);
75 HttpStream* HttpPipelinedStream::RenewStreamForAuth() {
76 if (pipeline_->usable()) {
77 return pipeline_->CreateNewStream();
79 return NULL;
82 bool HttpPipelinedStream::IsResponseBodyComplete() const {
83 return pipeline_->IsResponseBodyComplete(pipeline_id_);
86 bool HttpPipelinedStream::CanFindEndOfResponse() const {
87 return pipeline_->CanFindEndOfResponse(pipeline_id_);
90 bool HttpPipelinedStream::IsConnectionReused() const {
91 return pipeline_->IsConnectionReused(pipeline_id_);
94 void HttpPipelinedStream::SetConnectionReused() {
95 pipeline_->SetConnectionReused(pipeline_id_);
98 bool HttpPipelinedStream::IsConnectionReusable() const {
99 return pipeline_->usable();
102 int64 HttpPipelinedStream::GetTotalReceivedBytes() const {
103 return pipeline_->GetTotalReceivedBytes(pipeline_id_);
106 bool HttpPipelinedStream::GetLoadTimingInfo(
107 LoadTimingInfo* load_timing_info) const {
108 return pipeline_->GetLoadTimingInfo(pipeline_id_, load_timing_info);
111 void HttpPipelinedStream::GetSSLInfo(SSLInfo* ssl_info) {
112 pipeline_->GetSSLInfo(pipeline_id_, ssl_info);
115 void HttpPipelinedStream::GetSSLCertRequestInfo(
116 SSLCertRequestInfo* cert_request_info) {
117 pipeline_->GetSSLCertRequestInfo(pipeline_id_, cert_request_info);
120 bool HttpPipelinedStream::IsSpdyHttpStream() const {
121 return false;
124 void HttpPipelinedStream::Drain(HttpNetworkSession* session) {
125 pipeline_->Drain(this, session);
128 void HttpPipelinedStream::SetPriority(RequestPriority priority) {
129 // TODO(akalin): Plumb this through to |pipeline_| and its
130 // underlying ClientSocketHandle.
133 const SSLConfig& HttpPipelinedStream::used_ssl_config() const {
134 return pipeline_->used_ssl_config();
137 const ProxyInfo& HttpPipelinedStream::used_proxy_info() const {
138 return pipeline_->used_proxy_info();
141 const BoundNetLog& HttpPipelinedStream::net_log() const {
142 return pipeline_->net_log();
145 bool HttpPipelinedStream::was_npn_negotiated() const {
146 return pipeline_->was_npn_negotiated();
149 NextProto HttpPipelinedStream::protocol_negotiated() const {
150 return pipeline_->protocol_negotiated();
153 } // namespace net