From df9076ace1150780d9f696942f1aa377f3ffad9a Mon Sep 17 00:00:00 2001 From: "jbates@chromium.org" Date: Tue, 27 Mar 2012 00:18:57 +0000 Subject: Revert 129018 - Revert 128993 - Refactor BaseTimer to avoid spamming the MessageLoop with orphaned tasks. This change maintains the same API promises*, but instead of orphaning tasks when they are stopped, the BaseTimer_Helper class holds on to the task until either (1) it expires or (2) the user requests a delay that would arrive earlier than the pending task. If the user requests a longer delay than the pending task, a followup task will be posted when the pending task fires to span the remaining time. * The one change of usage is related to threading. The threading requirements are now more strict. It is not allowed to destruct a timer on a different thread than the one used to post tasks. A thread ID DCHECK is now in place that will help catch misuse. Some existing instances are changed as part of this CL. A side effect of this change is that the BaseTimer and DelayTimer are simplified to use features of BaseTimer_Helper (which is now called Timer). As suggested in timer.h, I ran the disabled TimerTest tests from linux, and they pass consistently. I also added some new tests to verify correct run states. BUG=117451,103667,119714,119750 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=128412 Reverted: http://src.chromium.org/viewvc/chrome?view=rev&revision=128506 Review URL: https://chromiumcodereview.appspot.com/9655006 TBR=jbates@chromium.org Review URL: https://chromiumcodereview.appspot.com/9791009 TBR=aa@chromium.org Review URL: https://chromiumcodereview.appspot.com/9860014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129062 0039d316-1c4b-4281-b951-d872f2087c98 --- content/common/net/url_fetcher_impl.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'content/common/net') diff --git a/content/common/net/url_fetcher_impl.cc b/content/common/net/url_fetcher_impl.cc index 9dd3cd3..0e87c51 100644 --- a/content/common/net/url_fetcher_impl.cc +++ b/content/common/net/url_fetcher_impl.cc @@ -316,7 +316,8 @@ class URLFetcherImpl::Core base::TimeDelta backoff_delay_; // Timer to poll the progress of uploading for POST and PUT requests. - base::RepeatingTimer upload_progress_checker_timer_; + // When crbug.com/119629 is fixed, scoped_ptr is not necessary here. + scoped_ptr > upload_progress_checker_timer_; // Number of bytes sent so far. int64 current_upload_bytes_; // Number of bytes received so far. @@ -903,7 +904,8 @@ void URLFetcherImpl::Core::StartURLRequest() { current_upload_bytes_ = -1; // TODO(kinaba): http://crbug.com/118103. Implement upload callback in the // net:: layer and avoid using timer here. - upload_progress_checker_timer_.Start( + upload_progress_checker_timer_.reset(new base::RepeatingTimer()); + upload_progress_checker_timer_->Start( FROM_HERE, base::TimeDelta::FromMilliseconds(kUploadProgressTimerInterval), this, @@ -1050,7 +1052,7 @@ void URLFetcherImpl::Core::NotifyMalformedContent() { } void URLFetcherImpl::Core::ReleaseRequest() { - upload_progress_checker_timer_.Stop(); + upload_progress_checker_timer_.reset(); request_.reset(); g_registry.Get().RemoveURLFetcherCore(this); } -- cgit v1.1