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

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

Issue 706203003: Update from https://crrev.com/303153 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 (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_job.h" 5 #include "net/url_request/url_request_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/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/power_monitor/power_monitor.h" 10 #include "base/power_monitor/power_monitor.h"
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 request_->response_info_.response_time = base::Time::Now(); 319 request_->response_info_.response_time = base::Time::Now();
320 GetResponseInfo(&request_->response_info_); 320 GetResponseInfo(&request_->response_info_);
321 321
322 // When notifying the delegate, the delegate can release the request 322 // When notifying the delegate, the delegate can release the request
323 // (and thus release 'this'). After calling to the delgate, we must 323 // (and thus release 'this'). After calling to the delgate, we must
324 // check the request pointer to see if it still exists, and return 324 // check the request pointer to see if it still exists, and return
325 // immediately if it has been destroyed. self_preservation ensures our 325 // immediately if it has been destroyed. self_preservation ensures our
326 // survival until we can get out of this method. 326 // survival until we can get out of this method.
327 scoped_refptr<URLRequestJob> self_preservation(this); 327 scoped_refptr<URLRequestJob> self_preservation(this);
328 328
329 if (request_) 329 if (request_) {
330 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed.
331 tracked_objects::ScopedTracker tracking_profile1(
332 FROM_HERE_WITH_EXPLICIT_FUNCTION(
333 "423948 URLRequestJob::NotifyHeadersComplete 1"));
334
330 request_->OnHeadersComplete(); 335 request_->OnHeadersComplete();
336 }
337
338 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed.
339 tracked_objects::ScopedTracker tracking_profile2(
340 FROM_HERE_WITH_EXPLICIT_FUNCTION(
341 "423948 URLRequestJob::NotifyHeadersComplete 2"));
331 342
332 GURL new_location; 343 GURL new_location;
333 int http_status_code; 344 int http_status_code;
334 if (IsRedirectResponse(&new_location, &http_status_code)) { 345 if (IsRedirectResponse(&new_location, &http_status_code)) {
346 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed.
347 tracked_objects::ScopedTracker tracking_profile3(
348 FROM_HERE_WITH_EXPLICIT_FUNCTION(
349 "423948 URLRequestJob::NotifyHeadersComplete 3"));
350
335 // Redirect response bodies are not read. Notify the transaction 351 // Redirect response bodies are not read. Notify the transaction
336 // so it does not treat being stopped as an error. 352 // so it does not treat being stopped as an error.
337 DoneReadingRedirectResponse(); 353 DoneReadingRedirectResponse();
338 354
355 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed.
356 tracked_objects::ScopedTracker tracking_profile4(
357 FROM_HERE_WITH_EXPLICIT_FUNCTION(
358 "423948 URLRequestJob::NotifyHeadersComplete 4"));
359
339 RedirectInfo redirect_info = 360 RedirectInfo redirect_info =
340 ComputeRedirectInfo(new_location, http_status_code); 361 ComputeRedirectInfo(new_location, http_status_code);
341 362
363 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed.
364 tracked_objects::ScopedTracker tracking_profile5(
365 FROM_HERE_WITH_EXPLICIT_FUNCTION(
366 "423948 URLRequestJob::NotifyHeadersComplete 5"));
367
342 bool defer_redirect = false; 368 bool defer_redirect = false;
343 request_->NotifyReceivedRedirect(redirect_info, &defer_redirect); 369 request_->NotifyReceivedRedirect(redirect_info, &defer_redirect);
344 370
345 // Ensure that the request wasn't detached or destroyed in 371 // Ensure that the request wasn't detached or destroyed in
346 // NotifyReceivedRedirect 372 // NotifyReceivedRedirect
347 if (!request_ || !request_->has_delegate()) 373 if (!request_ || !request_->has_delegate())
348 return; 374 return;
349 375
376 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed.
377 tracked_objects::ScopedTracker tracking_profile6(
378 FROM_HERE_WITH_EXPLICIT_FUNCTION(
379 "423948 URLRequestJob::NotifyHeadersComplete 6"));
380
350 // If we were not cancelled, then maybe follow the redirect. 381 // If we were not cancelled, then maybe follow the redirect.
351 if (request_->status().is_success()) { 382 if (request_->status().is_success()) {
352 if (defer_redirect) { 383 if (defer_redirect) {
353 deferred_redirect_info_ = redirect_info; 384 deferred_redirect_info_ = redirect_info;
354 } else { 385 } else {
355 FollowRedirect(redirect_info); 386 FollowRedirect(redirect_info);
356 } 387 }
357 return; 388 return;
358 } 389 }
359 } else if (NeedsAuth()) { 390 } else if (NeedsAuth()) {
391 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed.
392 tracked_objects::ScopedTracker tracking_profile7(
393 FROM_HERE_WITH_EXPLICIT_FUNCTION(
394 "423948 URLRequestJob::NotifyHeadersComplete 7"));
395
360 scoped_refptr<AuthChallengeInfo> auth_info; 396 scoped_refptr<AuthChallengeInfo> auth_info;
361 GetAuthChallengeInfo(&auth_info); 397 GetAuthChallengeInfo(&auth_info);
398
399 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed.
400 tracked_objects::ScopedTracker tracking_profile8(
401 FROM_HERE_WITH_EXPLICIT_FUNCTION(
402 "423948 URLRequestJob::NotifyHeadersComplete 8"));
403
362 // Need to check for a NULL auth_info because the server may have failed 404 // Need to check for a NULL auth_info because the server may have failed
363 // to send a challenge with the 401 response. 405 // to send a challenge with the 401 response.
364 if (auth_info.get()) { 406 if (auth_info.get()) {
365 request_->NotifyAuthRequired(auth_info.get()); 407 request_->NotifyAuthRequired(auth_info.get());
366 // Wait for SetAuth or CancelAuth to be called. 408 // Wait for SetAuth or CancelAuth to be called.
367 return; 409 return;
368 } 410 }
369 } 411 }
370 412
413 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed.
414 tracked_objects::ScopedTracker tracking_profile9(
415 FROM_HERE_WITH_EXPLICIT_FUNCTION(
416 "423948 URLRequestJob::NotifyHeadersComplete 9"));
417
371 has_handled_response_ = true; 418 has_handled_response_ = true;
372 if (request_->status().is_success()) 419 if (request_->status().is_success())
373 filter_.reset(SetupFilter()); 420 filter_.reset(SetupFilter());
374 421
375 if (!filter_.get()) { 422 if (!filter_.get()) {
376 std::string content_length; 423 std::string content_length;
377 request_->GetResponseHeaderByName("content-length", &content_length); 424 request_->GetResponseHeaderByName("content-length", &content_length);
378 if (!content_length.empty()) 425 if (!content_length.empty())
379 base::StringToInt64(content_length, &expected_content_size_); 426 base::StringToInt64(content_length, &expected_content_size_);
380 } 427 }
381 428
429 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed.
430 tracked_objects::ScopedTracker tracking_profile10(
431 FROM_HERE_WITH_EXPLICIT_FUNCTION(
432 "423948 URLRequestJob::NotifyHeadersComplete 10"));
433
382 request_->NotifyResponseStarted(); 434 request_->NotifyResponseStarted();
383 } 435 }
384 436
385 void URLRequestJob::NotifyReadComplete(int bytes_read) { 437 void URLRequestJob::NotifyReadComplete(int bytes_read) {
386 if (!request_ || !request_->has_delegate()) 438 if (!request_ || !request_->has_delegate())
387 return; // The request was destroyed, so there is no more work to do. 439 return; // The request was destroyed, so there is no more work to do.
388 440
389 // TODO(darin): Bug 1004233. Re-enable this test once all of the chrome 441 // TODO(darin): Bug 1004233. Re-enable this test once all of the chrome
390 // unit_tests have been fixed to not trip this. 442 // unit_tests have been fixed to not trip this.
391 #if 0 443 #if 0
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 !redirect_info.new_url.SchemeIsSecure()) { 853 !redirect_info.new_url.SchemeIsSecure()) {
802 redirect_info.new_referrer.clear(); 854 redirect_info.new_referrer.clear();
803 } else { 855 } else {
804 redirect_info.new_referrer = request_->referrer(); 856 redirect_info.new_referrer = request_->referrer();
805 } 857 }
806 858
807 return redirect_info; 859 return redirect_info;
808 } 860 }
809 861
810 } // namespace net 862 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_http_job_unittest.cc ('k') | net/websockets/websocket_basic_handshake_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698