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_fetcher_core.h" | 5 #include "net/url_request/url_fetcher_core.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 g_ignore_certificate_requests = ignored; | 534 g_ignore_certificate_requests = ignored; |
535 } | 535 } |
536 | 536 |
537 URLFetcherCore::~URLFetcherCore() { | 537 URLFetcherCore::~URLFetcherCore() { |
538 // |request_| should be NULL. If not, it's unsafe to delete it here since we | 538 // |request_| should be NULL. If not, it's unsafe to delete it here since we |
539 // may not be on the IO thread. | 539 // may not be on the IO thread. |
540 DCHECK(!request_.get()); | 540 DCHECK(!request_.get()); |
541 } | 541 } |
542 | 542 |
543 void URLFetcherCore::StartOnIOThread() { | 543 void URLFetcherCore::StartOnIOThread() { |
| 544 // TODO(pkasting): Remove ScopedTracker below once crbug.com/456327 is fixed. |
| 545 tracked_objects::ScopedTracker tracking_profile( |
| 546 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 547 "456327 URLFetcherCore::StartOnIOThread")); |
544 DCHECK(network_task_runner_->BelongsToCurrentThread()); | 548 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
545 | 549 |
546 if (!response_writer_) | 550 if (!response_writer_) |
547 response_writer_.reset(new URLFetcherStringWriter); | 551 response_writer_.reset(new URLFetcherStringWriter); |
548 | 552 |
549 const int result = response_writer_->Initialize( | 553 const int result = response_writer_->Initialize( |
550 base::Bind(&URLFetcherCore::DidInitializeWriter, this)); | 554 base::Bind(&URLFetcherCore::DidInitializeWriter, this)); |
551 if (result != ERR_IO_PENDING) | 555 if (result != ERR_IO_PENDING) |
552 DidInitializeWriter(result); | 556 DidInitializeWriter(result); |
553 } | 557 } |
554 | 558 |
555 void URLFetcherCore::StartURLRequest() { | 559 void URLFetcherCore::StartURLRequest() { |
| 560 // TODO(pkasting): Remove ScopedTracker below once crbug.com/456327 is fixed. |
| 561 tracked_objects::ScopedTracker tracking_profile( |
| 562 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 563 "456327 URLFetcherCore::StartURLRequest")); |
556 DCHECK(network_task_runner_->BelongsToCurrentThread()); | 564 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
557 | 565 |
558 if (was_cancelled_) { | 566 if (was_cancelled_) { |
559 // Since StartURLRequest() is posted as a *delayed* task, it may | 567 // Since StartURLRequest() is posted as a *delayed* task, it may |
560 // run after the URLFetcher was already stopped. | 568 // run after the URLFetcher was already stopped. |
561 return; | 569 return; |
562 } | 570 } |
563 | 571 |
564 DCHECK(request_context_getter_.get()); | 572 DCHECK(request_context_getter_.get()); |
565 DCHECK(!request_.get()); | 573 DCHECK(!request_.get()); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 } | 670 } |
663 | 671 |
664 void URLFetcherCore::StartURLRequestWhenAppropriate() { | 672 void URLFetcherCore::StartURLRequestWhenAppropriate() { |
665 DCHECK(network_task_runner_->BelongsToCurrentThread()); | 673 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
666 | 674 |
667 if (was_cancelled_) | 675 if (was_cancelled_) |
668 return; | 676 return; |
669 | 677 |
670 DCHECK(request_context_getter_.get()); | 678 DCHECK(request_context_getter_.get()); |
671 | 679 |
672 int64 delay = INT64_C(0); | 680 int64 delay = 0; |
673 if (!original_url_throttler_entry_.get()) { | 681 if (!original_url_throttler_entry_.get()) { |
| 682 // TODO(pkasting): Remove ScopedTracker below once crbug.com/456327 is |
| 683 // fixed. |
| 684 tracked_objects::ScopedTracker tracking_profile1( |
| 685 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 686 "456327 URLFetcherCore::StartURLRequestWhenAppropriate1")); |
674 URLRequestThrottlerManager* manager = | 687 URLRequestThrottlerManager* manager = |
675 request_context_getter_->GetURLRequestContext()->throttler_manager(); | 688 request_context_getter_->GetURLRequestContext()->throttler_manager(); |
676 if (manager) { | 689 if (manager) { |
677 original_url_throttler_entry_ = | 690 original_url_throttler_entry_ = |
678 manager->RegisterRequestUrl(original_url_); | 691 manager->RegisterRequestUrl(original_url_); |
679 } | 692 } |
680 } | 693 } |
681 if (original_url_throttler_entry_.get()) { | 694 if (original_url_throttler_entry_.get()) { |
| 695 // TODO(pkasting): Remove ScopedTracker below once crbug.com/456327 is |
| 696 // fixed. |
| 697 tracked_objects::ScopedTracker tracking_profile2( |
| 698 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 699 "456327 URLFetcherCore::StartURLRequestWhenAppropriate2")); |
682 delay = original_url_throttler_entry_->ReserveSendingTimeForNextRequest( | 700 delay = original_url_throttler_entry_->ReserveSendingTimeForNextRequest( |
683 GetBackoffReleaseTime()); | 701 GetBackoffReleaseTime()); |
684 } | 702 } |
685 | 703 |
686 if (delay == INT64_C(0)) { | 704 if (delay == 0) { |
687 StartURLRequest(); | 705 StartURLRequest(); |
688 } else { | 706 } else { |
689 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 707 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
690 FROM_HERE, base::Bind(&URLFetcherCore::StartURLRequest, this), | 708 FROM_HERE, base::Bind(&URLFetcherCore::StartURLRequest, this), |
691 base::TimeDelta::FromMilliseconds(delay)); | 709 base::TimeDelta::FromMilliseconds(delay)); |
692 } | 710 } |
693 } | 711 } |
694 | 712 |
695 void URLFetcherCore::CancelURLRequest(int error) { | 713 void URLFetcherCore::CancelURLRequest(int error) { |
696 DCHECK(network_task_runner_->BelongsToCurrentThread()); | 714 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
971 } | 989 } |
972 | 990 |
973 void URLFetcherCore::AssertHasNoUploadData() const { | 991 void URLFetcherCore::AssertHasNoUploadData() const { |
974 DCHECK(!upload_content_set_); | 992 DCHECK(!upload_content_set_); |
975 DCHECK(upload_content_.empty()); | 993 DCHECK(upload_content_.empty()); |
976 DCHECK(upload_file_path_.empty()); | 994 DCHECK(upload_file_path_.empty()); |
977 DCHECK(upload_stream_factory_.is_null()); | 995 DCHECK(upload_stream_factory_.is_null()); |
978 } | 996 } |
979 | 997 |
980 } // namespace net | 998 } // namespace net |
OLD | NEW |