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

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

Issue 344793006: Generate Cronet Version.java based on VERSION and LASTCHANGE files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add Version to HttpUrlConnectionFactory.getName(). Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « components/cronet/android/url_request_context_peer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_peer.h" 5 #include "url_request_peer.h"
6 6
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "net/base/load_flags.h" 8 #include "net/base/load_flags.h"
9 #include "net/http/http_status_code.h" 9 #include "net/http/http_status_code.h"
10 10
11 namespace cronet { 11 namespace cronet {
12 12
13 static const size_t kBufferSizeIncrement = 8192; 13 static const size_t kBufferSizeIncrement = 8192;
14 14
15 // Fragment automatically inserted in the User-Agent header to indicate
16 // that the request is coming from this network stack.
17 static const char kUserAgentFragment[] = "; ChromiumJNI/";
18
19 URLRequestPeer::URLRequestPeer(URLRequestContextPeer* context, 15 URLRequestPeer::URLRequestPeer(URLRequestContextPeer* context,
20 URLRequestPeerDelegate* delegate, 16 URLRequestPeerDelegate* delegate,
21 GURL url, 17 GURL url,
22 net::RequestPriority priority) 18 net::RequestPriority priority)
23 : method_("GET"), 19 : method_("GET"),
24 url_request_(NULL), 20 url_request_(NULL),
25 read_buffer_(new net::GrowableIOBuffer()), 21 read_buffer_(new net::GrowableIOBuffer()),
26 bytes_read_(0), 22 bytes_read_(0),
27 total_bytes_read_(0), 23 total_bytes_read_(0),
28 error_code_(0), 24 error_code_(0),
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 url_, net::DEFAULT_PRIORITY, this, context_->GetURLRequestContext()); 103 url_, net::DEFAULT_PRIORITY, this, context_->GetURLRequestContext());
108 url_request_->SetLoadFlags(net::LOAD_DISABLE_CACHE | 104 url_request_->SetLoadFlags(net::LOAD_DISABLE_CACHE |
109 net::LOAD_DO_NOT_SAVE_COOKIES | 105 net::LOAD_DO_NOT_SAVE_COOKIES |
110 net::LOAD_DO_NOT_SEND_COOKIES); 106 net::LOAD_DO_NOT_SEND_COOKIES);
111 url_request_->set_method(method_); 107 url_request_->set_method(method_);
112 url_request_->SetExtraRequestHeaders(headers_); 108 url_request_->SetExtraRequestHeaders(headers_);
113 std::string user_agent; 109 std::string user_agent;
114 if (headers_.HasHeader(net::HttpRequestHeaders::kUserAgent)) { 110 if (headers_.HasHeader(net::HttpRequestHeaders::kUserAgent)) {
115 headers_.GetHeader(net::HttpRequestHeaders::kUserAgent, &user_agent); 111 headers_.GetHeader(net::HttpRequestHeaders::kUserAgent, &user_agent);
116 } else { 112 } else {
117 user_agent = context_->GetUserAgent(url_); 113 user_agent = context_->GetUserAgent(url_);
mmenke 2014/06/20 17:41:16 We never run this line, since we always pass in th
mef 2014/06/20 18:34:04 Isn't it possible, that there is no User-Agent hea
mmenke 2014/06/20 19:03:59 Ahh...you're right. I was thinking we were adding
118 } 114 }
119 size_t pos = user_agent.find(')');
120 if (pos != std::string::npos) {
121 user_agent.insert(pos, context_->version());
122 user_agent.insert(pos, kUserAgentFragment);
123 }
124 url_request_->SetExtraRequestHeaderByName( 115 url_request_->SetExtraRequestHeaderByName(
125 net::HttpRequestHeaders::kUserAgent, user_agent, true /* override */); 116 net::HttpRequestHeaders::kUserAgent, user_agent, true /* override */);
mmenke 2014/06/20 17:41:16 I don't believe this does anything if headers_.Has
mef 2014/06/20 18:34:04 Done. It used to stick Cronet version into it, but
126 117
127 VLOG(context_->logging_level()) << "User agent: " << user_agent; 118 VLOG(context_->logging_level()) << "User agent: " << user_agent;
mmenke 2014/06/20 17:41:16 nit: I don't think this is worth a VLOG, while we
mef 2014/06/20 18:34:04 Done. I guess it was there for debugging?
128 119
129 if (upload_data_stream_) { 120 if (upload_data_stream_) {
130 url_request_->set_upload(make_scoped_ptr(upload_data_stream_.release())); 121 url_request_->set_upload(make_scoped_ptr(upload_data_stream_.release()));
131 } else if (streaming_upload_) { 122 } else if (streaming_upload_) {
132 url_request_->EnableChunkedUpload(); 123 url_request_->EnableChunkedUpload();
133 } 124 }
134 125
135 url_request_->SetPriority(priority_); 126 url_request_->SetPriority(priority_);
136 127
137 url_request_->Start(); 128 url_request_->Start();
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 275
285 delegate_->OnBytesRead(this); 276 delegate_->OnBytesRead(this);
286 delegate_->OnRequestFinished(this); 277 delegate_->OnRequestFinished(this);
287 } 278 }
288 279
289 unsigned char* URLRequestPeer::Data() const { 280 unsigned char* URLRequestPeer::Data() const {
290 return reinterpret_cast<unsigned char*>(read_buffer_->StartOfBuffer()); 281 return reinterpret_cast<unsigned char*>(read_buffer_->StartOfBuffer());
291 } 282 }
292 283
293 } // namespace cronet 284 } // namespace cronet
OLDNEW
« no previous file with comments | « components/cronet/android/url_request_context_peer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698