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

Side by Side Diff: content/public/test/test_download_request_handler.cc

Issue 1563633002: Make URLRequestJob::SetStatus private. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix stuff Created 4 years, 11 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "content/public/test/test_download_request_handler.h" 5 #include "content/public/test/test_download_request_handler.h"
6 6
7 #include <inttypes.h> 7 #include <inttypes.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 } 278 }
279 279
280 int64_t range_end = 280 int64_t range_end =
281 std::min(requested_range_end_, offset_of_next_read_ + buf_size - 1); 281 std::min(requested_range_end_, offset_of_next_read_ + buf_size - 1);
282 282
283 if (!parameters_->injected_errors.empty()) { 283 if (!parameters_->injected_errors.empty()) {
284 const InjectedError& injected_error = parameters_->injected_errors.front(); 284 const InjectedError& injected_error = parameters_->injected_errors.front();
285 285
286 if (offset_of_next_read_ == injected_error.offset) { 286 if (offset_of_next_read_ == injected_error.offset) {
287 int error = injected_error.error; 287 int error = injected_error.error;
288 SetStatus(net::URLRequestStatus(net::URLRequestStatus::FAILED, error));
289 DVLOG(1) << "Returning error " << net::ErrorToString(error); 288 DVLOG(1) << "Returning error " << net::ErrorToString(error);
290 ReportCompletedRequest(injected_error.offset - requested_range_begin_); 289 ReportCompletedRequest(injected_error.offset - requested_range_begin_);
291 parameters_->injected_errors.pop(); 290 parameters_->injected_errors.pop();
292 return error; 291 return error;
293 } 292 }
294 293
295 if (offset_of_next_read_ < injected_error.offset && 294 if (offset_of_next_read_ < injected_error.offset &&
296 injected_error.offset <= range_end) 295 injected_error.offset <= range_end)
297 range_end = injected_error.offset - 1; 296 range_end = injected_error.offset - 1;
298 } 297 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 return; 345 return;
347 } 346 }
348 347
349 response_info_.headers = new net::HttpResponseHeaders( 348 response_info_.headers = new net::HttpResponseHeaders(
350 net::HttpUtil::AssembleRawHeaders(headers.c_str(), headers.size())); 349 net::HttpUtil::AssembleRawHeaders(headers.c_str(), headers.size()));
351 NotifyHeadersCompleteAndPrepareToRead(); 350 NotifyHeadersCompleteAndPrepareToRead();
352 } 351 }
353 352
354 void TestDownloadRequestHandler::PartialResponseJob::HandleOnStartDefault() { 353 void TestDownloadRequestHandler::PartialResponseJob::HandleOnStartDefault() {
355 DCHECK_CURRENTLY_ON(BrowserThread::IO); 354 DCHECK_CURRENTLY_ON(BrowserThread::IO);
356 SetStatus(net::URLRequestStatus());
357 355
358 const net::HttpRequestHeaders& extra_headers = 356 const net::HttpRequestHeaders& extra_headers =
359 request()->extra_request_headers(); 357 request()->extra_request_headers();
360 358
361 DCHECK(request()->method() == "GET") << "PartialResponseJob only " 359 DCHECK(request()->method() == "GET") << "PartialResponseJob only "
362 "knows how to respond to GET " 360 "knows how to respond to GET "
363 "requests"; 361 "requests";
364 std::string value; 362 std::string value;
365 363
366 // If the request contains an 'If-Range' header and the value matches our 364 // If the request contains an 'If-Range' header and the value matches our
367 // ETag, then try to handle the range request. 365 // ETag, then try to handle the range request.
368 if (parameters_->support_byte_ranges && 366 if (parameters_->support_byte_ranges &&
369 extra_headers.GetHeader(net::HttpRequestHeaders::kIfRange, &value) && 367 extra_headers.GetHeader(net::HttpRequestHeaders::kIfRange, &value) &&
370 value == parameters_->etag && HandleRangeAssumingValidatorMatch()) 368 value == parameters_->etag && HandleRangeAssumingValidatorMatch()) {
371 return; 369 return;
370 }
372 371
373 if (parameters_->support_byte_ranges && 372 if (parameters_->support_byte_ranges &&
374 extra_headers.GetHeader("If-Match", &value)) { 373 extra_headers.GetHeader("If-Match", &value)) {
375 if (value == parameters_->etag && HandleRangeAssumingValidatorMatch()) 374 if (value == parameters_->etag && HandleRangeAssumingValidatorMatch())
376 return; 375 return;
377 376
378 // Unlike If-Range, If-Match returns an error if the validators don't match. 377 // Unlike If-Range, If-Match returns an error if the validators don't match.
379 response_info_.headers = HeadersFromString( 378 response_info_.headers = HeadersFromString(
380 "HTTP/1.1 412 Precondition failed\r\n" 379 "HTTP/1.1 412 Precondition failed\r\n"
381 "Content-Length: 0\r\n"); 380 "Content-Length: 0\r\n");
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 base::RunLoop run_loop; 663 base::RunLoop run_loop;
665 BrowserThread::PostTaskAndReply( 664 BrowserThread::PostTaskAndReply(
666 BrowserThread::IO, FROM_HERE, 665 BrowserThread::IO, FROM_HERE,
667 base::Bind(&Interceptor::GetAndResetCompletedRequests, interceptor_, 666 base::Bind(&Interceptor::GetAndResetCompletedRequests, interceptor_,
668 requests), 667 requests),
669 run_loop.QuitClosure()); 668 run_loop.QuitClosure());
670 run_loop.Run(); 669 run_loop.Run();
671 } 670 }
672 671
673 } // namespace content 672 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698