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

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

Issue 7846007: net: Rename URLRequestStatus::os_error_. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix os_error_code Created 9 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 | Annotate | Revision Log
« no previous file with comments | « net/url_request/url_request.h ('k') | net/url_request/url_request_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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/memory/singleton.h" 8 #include "base/memory/singleton.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/metrics/stats_counters.h" 10 #include "base/metrics/stats_counters.h"
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 void URLRequest::RestartWithJob(URLRequestJob *job) { 476 void URLRequest::RestartWithJob(URLRequestJob *job) {
477 DCHECK(job->request() == this); 477 DCHECK(job->request() == this);
478 PrepareToRestart(); 478 PrepareToRestart();
479 StartJob(job); 479 StartJob(job);
480 } 480 }
481 481
482 void URLRequest::Cancel() { 482 void URLRequest::Cancel() {
483 DoCancel(ERR_ABORTED, SSLInfo()); 483 DoCancel(ERR_ABORTED, SSLInfo());
484 } 484 }
485 485
486 void URLRequest::SimulateError(int os_error) { 486 void URLRequest::SimulateError(int error) {
487 DoCancel(os_error, SSLInfo()); 487 DoCancel(error, SSLInfo());
488 } 488 }
489 489
490 void URLRequest::SimulateSSLError(int os_error, const SSLInfo& ssl_info) { 490 void URLRequest::SimulateSSLError(int error, const SSLInfo& ssl_info) {
491 // This should only be called on a started request. 491 // This should only be called on a started request.
492 if (!is_pending_ || !job_ || job_->has_response_started()) { 492 if (!is_pending_ || !job_ || job_->has_response_started()) {
493 NOTREACHED(); 493 NOTREACHED();
494 return; 494 return;
495 } 495 }
496 DoCancel(os_error, ssl_info); 496 DoCancel(error, ssl_info);
497 } 497 }
498 498
499 void URLRequest::DoCancel(int os_error, const SSLInfo& ssl_info) { 499 void URLRequest::DoCancel(int error, const SSLInfo& ssl_info) {
500 DCHECK(os_error < 0); 500 DCHECK(error < 0);
501 501
502 // If the URL request already has an error status, then canceling is a no-op. 502 // If the URL request already has an error status, then canceling is a no-op.
503 // Plus, we don't want to change the error status once it has been set. 503 // Plus, we don't want to change the error status once it has been set.
504 if (status_.is_success()) { 504 if (status_.is_success()) {
505 status_.set_status(URLRequestStatus::CANCELED); 505 status_.set_status(URLRequestStatus::CANCELED);
506 status_.set_os_error(os_error); 506 status_.set_error(error);
507 response_info_.ssl_info = ssl_info; 507 response_info_.ssl_info = ssl_info;
508 } 508 }
509 509
510 // There's nothing to do if we are not waiting on a Job. 510 // There's nothing to do if we are not waiting on a Job.
511 if (!is_pending_ || !job_) 511 if (!is_pending_ || !job_)
512 return; 512 return;
513 513
514 job_->Kill(); 514 job_->Kill();
515 515
516 // We need to notify about the end of this job here synchronously. The 516 // We need to notify about the end of this job here synchronously. The
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 if (job) { 561 if (job) {
562 RestartWithJob(job); 562 RestartWithJob(job);
563 } else if (delegate_) { 563 } else if (delegate_) {
564 delegate_->OnReceivedRedirect(this, location, defer_redirect); 564 delegate_->OnReceivedRedirect(this, location, defer_redirect);
565 } 565 }
566 } 566 }
567 567
568 void URLRequest::NotifyResponseStarted() { 568 void URLRequest::NotifyResponseStarted() {
569 scoped_refptr<NetLog::EventParameters> params; 569 scoped_refptr<NetLog::EventParameters> params;
570 if (!status_.is_success()) 570 if (!status_.is_success())
571 params = new NetLogIntegerParameter("net_error", status_.os_error()); 571 params = new NetLogIntegerParameter("net_error", status_.error());
572 net_log_.EndEvent(NetLog::TYPE_URL_REQUEST_START_JOB, params); 572 net_log_.EndEvent(NetLog::TYPE_URL_REQUEST_START_JOB, params);
573 573
574 URLRequestJob* job = 574 URLRequestJob* job =
575 URLRequestJobManager::GetInstance()->MaybeInterceptResponse(this); 575 URLRequestJobManager::GetInstance()->MaybeInterceptResponse(this);
576 if (job) { 576 if (job) {
577 RestartWithJob(job); 577 RestartWithJob(job);
578 } else { 578 } else {
579 if (delegate_) { 579 if (delegate_) {
580 // In some cases (e.g. an event was canceled), we might have sent the 580 // In some cases (e.g. an event was canceled), we might have sent the
581 // completion event and receive a NotifyResponseStarted() later. 581 // completion event and receive a NotifyResponseStarted() later.
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 scoped_refptr<const URLRequestContext> prev_context = context_; 718 scoped_refptr<const URLRequestContext> prev_context = context_;
719 719
720 context_ = context; 720 context_ = context;
721 721
722 // If the context this request belongs to has changed, update the tracker. 722 // If the context this request belongs to has changed, update the tracker.
723 if (prev_context != context) { 723 if (prev_context != context) {
724 int net_error = OK; 724 int net_error = OK;
725 // Log error only on failure, not cancellation, as even successful requests 725 // Log error only on failure, not cancellation, as even successful requests
726 // are "cancelled" on destruction. 726 // are "cancelled" on destruction.
727 if (status_.status() == URLRequestStatus::FAILED) 727 if (status_.status() == URLRequestStatus::FAILED)
728 net_error = status_.os_error(); 728 net_error = status_.error();
729 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_REQUEST_ALIVE, net_error); 729 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_REQUEST_ALIVE, net_error);
730 net_log_ = BoundNetLog(); 730 net_log_ = BoundNetLog();
731 731
732 if (context) { 732 if (context) {
733 net_log_ = BoundNetLog::Make(context->net_log(), 733 net_log_ = BoundNetLog::Make(context->net_log(),
734 NetLog::SOURCE_URL_REQUEST); 734 NetLog::SOURCE_URL_REQUEST);
735 net_log_.BeginEvent(NetLog::TYPE_REQUEST_ALIVE, NULL); 735 net_log_.BeginEvent(NetLog::TYPE_REQUEST_ALIVE, NULL);
736 } 736 }
737 } 737 }
738 } 738 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 net_log_.BeginEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE, NULL); 827 net_log_.BeginEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE, NULL);
828 } 828 }
829 829
830 void URLRequest::SetUnblockedOnDelegate() { 830 void URLRequest::SetUnblockedOnDelegate() {
831 blocked_on_delegate_ = false; 831 blocked_on_delegate_ = false;
832 load_state_param_.clear(); 832 load_state_param_.clear();
833 net_log_.EndEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE, NULL); 833 net_log_.EndEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE, NULL);
834 } 834 }
835 835
836 } // namespace net 836 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request.h ('k') | net/url_request/url_request_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698