OLD | NEW |
---|---|
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 Loading... | |
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. | |
mmenke
2014/11/03 16:19:15
Do you really mean to keep this in that long? I'm
vadimt
2014/11/04 01:04:23
Yes, it's perfectly OK not not wait till the issue
mmenke
2014/11/04 19:50:13
I mean your TODO about when you're going to remove
| |
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 |
371 has_handled_response_ = true; | 413 has_handled_response_ = true; |
372 if (request_->status().is_success()) | 414 if (request_->status().is_success()) |
373 filter_.reset(SetupFilter()); | 415 filter_.reset(SetupFilter()); |
374 | 416 |
375 if (!filter_.get()) { | 417 if (!filter_.get()) { |
418 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed. | |
419 tracked_objects::ScopedTracker tracking_profile9( | |
420 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
421 "423948 URLRequestJob::NotifyHeadersComplete 9")); | |
mmenke
2014/11/03 16:19:15
I'd argue one just above "has_handled_response_ =
vadimt
2014/11/04 01:04:23
Moved the instrumentation up.
| |
422 | |
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 Loading... | |
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 |
OLD | NEW |