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

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

Issue 7276: Adding security info to canceled requests (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/process_util.h" 9 #include "base/process_util.h"
10 #include "base/singleton.h" 10 #include "base/singleton.h"
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 response_info_.was_cached = false; 221 response_info_.was_cached = false;
222 222
223 // Don't allow errors to be sent from within Start(). 223 // Don't allow errors to be sent from within Start().
224 // TODO(brettw) this may cause NotifyDone to be sent synchronously, 224 // TODO(brettw) this may cause NotifyDone to be sent synchronously,
225 // we probably don't want this: they should be sent asynchronously so 225 // we probably don't want this: they should be sent asynchronously so
226 // the caller does not get reentered. 226 // the caller does not get reentered.
227 job_->Start(); 227 job_->Start();
228 } 228 }
229 229
230 void URLRequest::Cancel() { 230 void URLRequest::Cancel() {
231 CancelWithError(net::ERR_ABORTED); 231 DoCancel(net::ERR_ABORTED, net::SSLInfo());
232 } 232 }
233 233
234 void URLRequest::CancelWithError(int os_error) { 234 void URLRequest::SimulateError(int os_error) {
235 SimulateSSLError(os_error, net::SSLInfo());
236 }
237
238 void URLRequest::SimulateSSLError(int os_error, const net::SSLInfo& ssl_info) {
239 // This should only be called on a started request.
240 if (!is_pending_ || !job_ || job_->has_response_started()) {
241 NOTREACHED();
242 return;
243 }
244 DoCancel(os_error, ssl_info);
245 }
246
247 void URLRequest::DoCancel(int os_error, const net::SSLInfo& ssl_info) {
235 DCHECK(os_error < 0); 248 DCHECK(os_error < 0);
236 249
237 // If the URL request already has an error status, then canceling is a no-op. 250 // If the URL request already has an error status, then canceling is a no-op.
238 // Plus, we don't want to change the error status once it has been set. 251 // Plus, we don't want to change the error status once it has been set.
239 if (status_.is_success()) { 252 if (status_.is_success()) {
240 status_.set_status(URLRequestStatus::CANCELED); 253 status_.set_status(URLRequestStatus::CANCELED);
241 status_.set_os_error(os_error); 254 status_.set_os_error(os_error);
255 response_info_.ssl_info = ssl_info;
242 } 256 }
243 257
244 // There's nothing to do if we are not waiting on a Job. 258 // There's nothing to do if we are not waiting on a Job.
245 if (!is_pending_ || !job_) 259 if (!is_pending_ || !job_)
246 return; 260 return;
247 261
248 job_->Kill(); 262 job_->Kill();
249 263
250 // The Job will call our NotifyDone method asynchronously. This is done so 264 // The Job will call our NotifyDone method asynchronously. This is done so
251 // that the Delegate implementation can call Cancel without having to worry 265 // that the Delegate implementation can call Cancel without having to worry
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 return net::OK; 391 return net::OK;
378 } 392 }
379 393
380 int64 URLRequest::GetExpectedContentSize() const { 394 int64 URLRequest::GetExpectedContentSize() const {
381 int64 expected_content_size = -1; 395 int64 expected_content_size = -1;
382 if (job_) 396 if (job_)
383 expected_content_size = job_->expected_content_size(); 397 expected_content_size = job_->expected_content_size();
384 398
385 return expected_content_size; 399 return expected_content_size;
386 } 400 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698