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

Side by Side Diff: net/test/url_request/url_request_slow_download_job.cc

Issue 1172753003: Move LowerCaseEqualsASCII to base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@string_util
Patch Set: Created 5 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
« no previous file with comments | « net/proxy/proxy_server.cc ('k') | net/url_request/url_request_file_job.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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/test/url_request/url_request_slow_download_job.h" 5 #include "net/test/url_request/url_request_slow_download_job.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 NetworkDelegate* network_delegate) 108 NetworkDelegate* network_delegate)
109 : URLRequestJob(request, network_delegate), 109 : URLRequestJob(request, network_delegate),
110 bytes_already_sent_(0), 110 bytes_already_sent_(0),
111 should_error_download_(false), 111 should_error_download_(false),
112 should_finish_download_(false), 112 should_finish_download_(false),
113 buffer_size_(0), 113 buffer_size_(0),
114 weak_factory_(this) { 114 weak_factory_(this) {
115 } 115 }
116 116
117 void URLRequestSlowDownloadJob::StartAsync() { 117 void URLRequestSlowDownloadJob::StartAsync() {
118 if (LowerCaseEqualsASCII(kFinishDownloadUrl, request_->url().spec().c_str())) 118 if (base::LowerCaseEqualsASCII(kFinishDownloadUrl,
119 request_->url().spec().c_str()))
119 URLRequestSlowDownloadJob::FinishPendingRequests(); 120 URLRequestSlowDownloadJob::FinishPendingRequests();
120 if (LowerCaseEqualsASCII(kErrorDownloadUrl, request_->url().spec().c_str())) 121 if (base::LowerCaseEqualsASCII(kErrorDownloadUrl,
122 request_->url().spec().c_str()))
121 URLRequestSlowDownloadJob::ErrorPendingRequests(); 123 URLRequestSlowDownloadJob::ErrorPendingRequests();
122 124
123 NotifyHeadersComplete(); 125 NotifyHeadersComplete();
124 } 126 }
125 127
126 // ReadRawData and CheckDoneStatus together implement a state 128 // ReadRawData and CheckDoneStatus together implement a state
127 // machine. ReadRawData may be called arbitrarily by the network stack. 129 // machine. ReadRawData may be called arbitrarily by the network stack.
128 // It responds by: 130 // It responds by:
129 // * If there are bytes remaining in the first chunk, they are 131 // * If there are bytes remaining in the first chunk, they are
130 // returned. 132 // returned.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 bytes_already_sent_ += bytes_to_write; 173 bytes_already_sent_ += bytes_to_write;
172 return BUFFER_FILLED; 174 return BUFFER_FILLED;
173 } 175 }
174 176
175 return REQUEST_COMPLETE; 177 return REQUEST_COMPLETE;
176 } 178 }
177 179
178 bool URLRequestSlowDownloadJob::ReadRawData(IOBuffer* buf, 180 bool URLRequestSlowDownloadJob::ReadRawData(IOBuffer* buf,
179 int buf_size, 181 int buf_size,
180 int* bytes_read) { 182 int* bytes_read) {
181 if (LowerCaseEqualsASCII(kFinishDownloadUrl, 183 if (base::LowerCaseEqualsASCII(kFinishDownloadUrl,
182 request_->url().spec().c_str()) || 184 request_->url().spec().c_str()) ||
183 LowerCaseEqualsASCII(kErrorDownloadUrl, request_->url().spec().c_str())) { 185 base::LowerCaseEqualsASCII(kErrorDownloadUrl,
186 request_->url().spec().c_str())) {
184 VLOG(10) << __FUNCTION__ << " called w/ kFinish/ErrorDownloadUrl."; 187 VLOG(10) << __FUNCTION__ << " called w/ kFinish/ErrorDownloadUrl.";
185 *bytes_read = 0; 188 *bytes_read = 0;
186 return true; 189 return true;
187 } 190 }
188 191
189 VLOG(10) << __FUNCTION__ << " called at position " << bytes_already_sent_ 192 VLOG(10) << __FUNCTION__ << " called at position " << bytes_already_sent_
190 << " in the stream."; 193 << " in the stream.";
191 ReadStatus status = FillBufferHelper(buf, buf_size, bytes_read); 194 ReadStatus status = FillBufferHelper(buf, buf_size, bytes_read);
192 switch (status) { 195 switch (status) {
193 case BUFFER_FILLED: 196 case BUFFER_FILLED:
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 243
241 URLRequestSlowDownloadJob::~URLRequestSlowDownloadJob() { 244 URLRequestSlowDownloadJob::~URLRequestSlowDownloadJob() {
242 pending_requests_.Get().erase(this); 245 pending_requests_.Get().erase(this);
243 } 246 }
244 247
245 // Private const version. 248 // Private const version.
246 void URLRequestSlowDownloadJob::GetResponseInfoConst( 249 void URLRequestSlowDownloadJob::GetResponseInfoConst(
247 HttpResponseInfo* info) const { 250 HttpResponseInfo* info) const {
248 // Send back mock headers. 251 // Send back mock headers.
249 std::string raw_headers; 252 std::string raw_headers;
250 if (LowerCaseEqualsASCII(kFinishDownloadUrl, 253 if (base::LowerCaseEqualsASCII(kFinishDownloadUrl,
251 request_->url().spec().c_str()) || 254 request_->url().spec().c_str()) ||
252 LowerCaseEqualsASCII(kErrorDownloadUrl, request_->url().spec().c_str())) { 255 base::LowerCaseEqualsASCII(kErrorDownloadUrl,
256 request_->url().spec().c_str())) {
253 raw_headers.append( 257 raw_headers.append(
254 "HTTP/1.1 200 OK\n" 258 "HTTP/1.1 200 OK\n"
255 "Content-type: text/plain\n"); 259 "Content-type: text/plain\n");
256 } else { 260 } else {
257 raw_headers.append( 261 raw_headers.append(
258 "HTTP/1.1 200 OK\n" 262 "HTTP/1.1 200 OK\n"
259 "Content-type: application/octet-stream\n" 263 "Content-type: application/octet-stream\n"
260 "Cache-Control: max-age=0\n"); 264 "Cache-Control: max-age=0\n");
261 265
262 if (LowerCaseEqualsASCII(kKnownSizeUrl, request_->url().spec().c_str())) { 266 if (base::LowerCaseEqualsASCII(kKnownSizeUrl,
267 request_->url().spec().c_str())) {
263 raw_headers.append(base::StringPrintf( 268 raw_headers.append(base::StringPrintf(
264 "Content-Length: %d\n", kFirstDownloadSize + kSecondDownloadSize)); 269 "Content-Length: %d\n", kFirstDownloadSize + kSecondDownloadSize));
265 } 270 }
266 } 271 }
267 272
268 // ParseRawHeaders expects \0 to end each header line. 273 // ParseRawHeaders expects \0 to end each header line.
269 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1)); 274 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1));
270 info->headers = new HttpResponseHeaders(raw_headers); 275 info->headers = new HttpResponseHeaders(raw_headers);
271 } 276 }
272 277
273 bool URLRequestSlowDownloadJob::GetMimeType(std::string* mime_type) const { 278 bool URLRequestSlowDownloadJob::GetMimeType(std::string* mime_type) const {
274 HttpResponseInfo info; 279 HttpResponseInfo info;
275 GetResponseInfoConst(&info); 280 GetResponseInfoConst(&info);
276 return info.headers.get() && info.headers->GetMimeType(mime_type); 281 return info.headers.get() && info.headers->GetMimeType(mime_type);
277 } 282 }
278 283
279 } // namespace net 284 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/proxy_server.cc ('k') | net/url_request/url_request_file_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698