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

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

Issue 10310124: Implement a ResourceThrottle for URL overriding in Chrome on Android. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: incorporated feedback Created 8 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
« net/url_request/url_request.h ('K') | « net/url_request/url_request.h ('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 (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/url_request/url_request.h" 5 #include "net/url_request/url_request.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 RestartWithJob(URLRequestJobManager::GetInstance()->CreateJob(this)); 471 RestartWithJob(URLRequestJobManager::GetInstance()->CreateJob(this));
472 } 472 }
473 473
474 void URLRequest::RestartWithJob(URLRequestJob *job) { 474 void URLRequest::RestartWithJob(URLRequestJob *job) {
475 DCHECK(job->request() == this); 475 DCHECK(job->request() == this);
476 PrepareToRestart(); 476 PrepareToRestart();
477 StartJob(job); 477 StartJob(job);
478 } 478 }
479 479
480 void URLRequest::Cancel() { 480 void URLRequest::Cancel() {
481 DoCancel(ERR_ABORTED, SSLInfo()); 481 DoCancel(URLRequestStatus(URLRequestStatus::CANCELED, ERR_ABORTED),
482 SSLInfo());
482 } 483 }
483 484
484 void URLRequest::CancelWithError(int error) { 485 void URLRequest::CancelWithError(int error) {
485 DoCancel(error, SSLInfo()); 486 DCHECK(error < 0);
487 DoCancel(URLRequestStatus(URLRequestStatus::CANCELED, error),
488 SSLInfo());
486 } 489 }
487 490
488 void URLRequest::CancelWithSSLError(int error, const SSLInfo& ssl_info) { 491 void URLRequest::CancelWithSSLError(int error, const SSLInfo& ssl_info) {
492 DCHECK(error < 0);
489 // This should only be called on a started request. 493 // This should only be called on a started request.
490 if (!is_pending_ || !job_ || job_->has_response_started()) { 494 if (!is_pending_ || !job_ || job_->has_response_started()) {
491 NOTREACHED(); 495 NOTREACHED();
492 return; 496 return;
493 } 497 }
494 DoCancel(error, ssl_info); 498 DoCancel(URLRequestStatus(URLRequestStatus::CANCELED, error),
499 SSLInfo());
495 } 500 }
496 501
497 void URLRequest::DoCancel(int error, const SSLInfo& ssl_info) { 502 void URLRequest::CancelWithHandledExternallyStatus() {
498 DCHECK(error < 0); 503 DoCancel(URLRequestStatus(URLRequestStatus::HANDLED_EXTERNALLY, OK),
504 SSLInfo());
505 }
499 506
507 void URLRequest::DoCancel(const URLRequestStatus& status,
508 const SSLInfo& ssl_info) {
500 // If the URL request already has an error status, then canceling is a no-op. 509 // If the URL request already has an error status, then canceling is a no-op.
501 // Plus, we don't want to change the error status once it has been set. 510 // Plus, we don't want to change the error status once it has been set.
502 if (status_.is_success()) { 511 if (status_.is_success()) {
503 status_.set_status(URLRequestStatus::CANCELED); 512 status_ = status;
504 status_.set_error(error);
505 response_info_.ssl_info = ssl_info; 513 response_info_.ssl_info = ssl_info;
506 } 514 }
507 515
508 if (is_pending_ && job_) 516 if (is_pending_ && job_)
509 job_->Kill(); 517 job_->Kill();
510 518
511 // We need to notify about the end of this job here synchronously. The 519 // We need to notify about the end of this job here synchronously. The
512 // Job sends an asynchronous notification but by the time this is processed, 520 // Job sends an asynchronous notification but by the time this is processed,
513 // our |context_| is NULL. 521 // our |context_| is NULL.
514 NotifyRequestCompleted(); 522 NotifyRequestCompleted();
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 new base::debug::StackTrace(NULL, 0); 930 new base::debug::StackTrace(NULL, 0);
923 *stack_trace_copy = stack_trace; 931 *stack_trace_copy = stack_trace;
924 stack_trace_.reset(stack_trace_copy); 932 stack_trace_.reset(stack_trace_copy);
925 } 933 }
926 934
927 const base::debug::StackTrace* URLRequest::stack_trace() const { 935 const base::debug::StackTrace* URLRequest::stack_trace() const {
928 return stack_trace_.get(); 936 return stack_trace_.get();
929 } 937 }
930 938
931 } // namespace net 939 } // namespace net
OLDNEW
« net/url_request/url_request.h ('K') | « net/url_request/url_request.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698