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

Side by Side Diff: components/cronet/android/url_request_adapter.cc

Issue 544223003: Add SetSupportsQuic method to explicitly specify server that supports QUIC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments. Created 6 years, 3 months 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
OLDNEW
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
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 if (url_request_ == NULL)
105 return std::string();
106 return url_request_->response_info().npn_negotiated_protocol;
107 }
108
103 void URLRequestAdapter::Start() { 109 void URLRequestAdapter::Start() {
104 context_->GetNetworkTaskRunner()->PostTask( 110 context_->GetNetworkTaskRunner()->PostTask(
105 FROM_HERE, 111 FROM_HERE,
106 base::Bind(&URLRequestAdapter::OnInitiateConnection, 112 base::Bind(&URLRequestAdapter::OnInitiateConnection,
107 base::Unretained(this))); 113 base::Unretained(this)));
108 } 114 }
109 115
110 void URLRequestAdapter::OnAppendChunk(const scoped_ptr<char[]> bytes, 116 void URLRequestAdapter::OnAppendChunk(const scoped_ptr<char[]> bytes,
111 int bytes_len, bool is_last_chunk) { 117 int bytes_len, bool is_last_chunk) {
112 url_request_->AppendChunkToUpload(bytes.get(), bytes_len, is_last_chunk); 118 url_request_->AppendChunkToUpload(bytes.get(), bytes_len, is_last_chunk);
113 } 119 }
114 120
115 void URLRequestAdapter::OnInitiateConnection() { 121 void URLRequestAdapter::OnInitiateConnection() {
116 if (canceled_) { 122 if (canceled_) {
117 return; 123 return;
118 } 124 }
119 125
126 DCHECK(url_.is_valid());
127
120 VLOG(1) << "Starting chromium request: " 128 VLOG(1) << "Starting chromium request: "
121 << url_.possibly_invalid_spec().c_str() 129 << url_.possibly_invalid_spec().c_str()
122 << " priority: " << RequestPriorityToString(priority_); 130 << " priority: " << RequestPriorityToString(priority_);
123 url_request_ = context_->GetURLRequestContext()->CreateRequest( 131 url_request_ = context_->GetURLRequestContext()->CreateRequest(
124 url_, net::DEFAULT_PRIORITY, this, NULL); 132 url_, net::DEFAULT_PRIORITY, this, NULL);
125 url_request_->SetLoadFlags(net::LOAD_DISABLE_CACHE | 133 url_request_->SetLoadFlags(net::LOAD_DISABLE_CACHE |
126 net::LOAD_DO_NOT_SAVE_COOKIES | 134 net::LOAD_DO_NOT_SAVE_COOKIES |
127 net::LOAD_DO_NOT_SEND_COOKIES); 135 net::LOAD_DO_NOT_SEND_COOKIES);
128 url_request_->set_method(method_); 136 url_request_->set_method(method_);
129 url_request_->SetExtraRequestHeaders(headers_); 137 url_request_->SetExtraRequestHeaders(headers_);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 292
285 delegate_->OnBytesRead(this); 293 delegate_->OnBytesRead(this);
286 delegate_->OnRequestFinished(this); 294 delegate_->OnRequestFinished(this);
287 } 295 }
288 296
289 unsigned char* URLRequestAdapter::Data() const { 297 unsigned char* URLRequestAdapter::Data() const {
290 return reinterpret_cast<unsigned char*>(read_buffer_->StartOfBuffer()); 298 return reinterpret_cast<unsigned char*>(read_buffer_->StartOfBuffer());
291 } 299 }
292 300
293 } // namespace cronet 301 } // namespace cronet
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698