OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "url_request_adapter.h" | 5 #include "url_request_adapter.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
93 return value; | 93 return value; |
94 } | 94 } |
95 | 95 |
96 net::HttpResponseHeaders* URLRequestAdapter::GetResponseHeaders() const { | 96 net::HttpResponseHeaders* URLRequestAdapter::GetResponseHeaders() const { |
97 if (url_request_ == NULL) { | 97 if (url_request_ == NULL) { |
98 return NULL; | 98 return NULL; |
99 } | 99 } |
100 return url_request_->response_headers(); | 100 return url_request_->response_headers(); |
101 } | 101 } |
102 | 102 |
103 std::string URLRequestAdapter::GetNegotiatedProtocol() const { | |
104 DCHECK(url_request_); | |
105 if (url_request_ == NULL) | |
mmenke
2014/09/10 18:21:27
The general chrome philosophy is to not both have
mef
2014/09/10 20:18:48
Done. It was my test aid. :)
| |
106 return std::string(); | |
107 return url_request_->response_info().npn_negotiated_protocol; | |
108 } | |
109 | |
103 void URLRequestAdapter::Start() { | 110 void URLRequestAdapter::Start() { |
104 context_->GetNetworkTaskRunner()->PostTask( | 111 context_->GetNetworkTaskRunner()->PostTask( |
105 FROM_HERE, | 112 FROM_HERE, |
106 base::Bind(&URLRequestAdapter::OnInitiateConnection, | 113 base::Bind(&URLRequestAdapter::OnInitiateConnection, |
107 base::Unretained(this))); | 114 base::Unretained(this))); |
108 } | 115 } |
109 | 116 |
110 void URLRequestAdapter::OnAppendChunk(const scoped_ptr<char[]> bytes, | 117 void URLRequestAdapter::OnAppendChunk(const scoped_ptr<char[]> bytes, |
111 int bytes_len, bool is_last_chunk) { | 118 int bytes_len, bool is_last_chunk) { |
112 url_request_->AppendChunkToUpload(bytes.get(), bytes_len, is_last_chunk); | 119 url_request_->AppendChunkToUpload(bytes.get(), bytes_len, is_last_chunk); |
113 } | 120 } |
114 | 121 |
115 void URLRequestAdapter::OnInitiateConnection() { | 122 void URLRequestAdapter::OnInitiateConnection() { |
116 if (canceled_) { | 123 if (canceled_) { |
117 return; | 124 return; |
118 } | 125 } |
119 | 126 |
127 DCHECK(url_.is_valid()); | |
128 | |
120 VLOG(1) << "Starting chromium request: " | 129 VLOG(1) << "Starting chromium request: " |
121 << url_.possibly_invalid_spec().c_str() | 130 << url_.possibly_invalid_spec().c_str() |
122 << " priority: " << RequestPriorityToString(priority_); | 131 << " priority: " << RequestPriorityToString(priority_); |
123 url_request_ = context_->GetURLRequestContext()->CreateRequest( | 132 url_request_ = context_->GetURLRequestContext()->CreateRequest( |
124 url_, net::DEFAULT_PRIORITY, this, NULL); | 133 url_, net::DEFAULT_PRIORITY, this, NULL); |
125 url_request_->SetLoadFlags(net::LOAD_DISABLE_CACHE | | 134 url_request_->SetLoadFlags(net::LOAD_DISABLE_CACHE | |
126 net::LOAD_DO_NOT_SAVE_COOKIES | | 135 net::LOAD_DO_NOT_SAVE_COOKIES | |
127 net::LOAD_DO_NOT_SEND_COOKIES); | 136 net::LOAD_DO_NOT_SEND_COOKIES); |
128 url_request_->set_method(method_); | 137 url_request_->set_method(method_); |
129 url_request_->SetExtraRequestHeaders(headers_); | 138 url_request_->SetExtraRequestHeaders(headers_); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
284 | 293 |
285 delegate_->OnBytesRead(this); | 294 delegate_->OnBytesRead(this); |
286 delegate_->OnRequestFinished(this); | 295 delegate_->OnRequestFinished(this); |
287 } | 296 } |
288 | 297 |
289 unsigned char* URLRequestAdapter::Data() const { | 298 unsigned char* URLRequestAdapter::Data() const { |
290 return reinterpret_cast<unsigned char*>(read_buffer_->StartOfBuffer()); | 299 return reinterpret_cast<unsigned char*>(read_buffer_->StartOfBuffer()); |
291 } | 300 } |
292 | 301 |
293 } // namespace cronet | 302 } // namespace cronet |
OLD | NEW |