diff options
| author | darin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-03 18:18:14 +0000 |
|---|---|---|
| committer | darin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-03 18:18:14 +0000 |
| commit | 2d31666a58e746b7a1d415c99e5f68ad9256d236 (patch) | |
| tree | 144c99d4b80df0f0f9a3ded83f9d21a8b36f17cc /chrome/browser/safe_browsing | |
| parent | 90d6958fe2374a00d3c8583cf4d3b8a509ae8e90 (diff) | |
| download | chromium_src-2d31666a58e746b7a1d415c99e5f68ad9256d236.zip chromium_src-2d31666a58e746b7a1d415c99e5f68ad9256d236.tar.gz chromium_src-2d31666a58e746b7a1d415c99e5f68ad9256d236.tar.bz2 | |
Minor cleanup to OneShotTimer and RepeatingTimer: moves more of the member variables into the Task subclass.
Also included in this change: deprecate MessageLoop::timer_manager(), and change consumers over to use OneShotTimer or RepeatingTimer.
R=beng
BUG=1346553
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1684 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/safe_browsing')
| -rw-r--r-- | chrome/browser/safe_browsing/protocol_manager.cc | 31 | ||||
| -rw-r--r-- | chrome/browser/safe_browsing/protocol_manager.h | 3 |
2 files changed, 5 insertions, 29 deletions
diff --git a/chrome/browser/safe_browsing/protocol_manager.cc b/chrome/browser/safe_browsing/protocol_manager.cc index c1ed1b4..e66afc5 100644 --- a/chrome/browser/safe_browsing/protocol_manager.cc +++ b/chrome/browser/safe_browsing/protocol_manager.cc @@ -49,22 +49,6 @@ static const int kSbClientMinorVersion = 0; static const int kSbMaxBackOff = 8; -// Periodic update task -------------------------------------------------------- -class SafeBrowsingProtocolUpdateTask : public Task { - public: - explicit SafeBrowsingProtocolUpdateTask(SafeBrowsingProtocolManager* manager) - : manager_(manager) { - } - - void Run() { - manager_->GetNextUpdate(); - } - - private: - SafeBrowsingProtocolManager* manager_; -}; - - // SafeBrowsingProtocolManager implementation ---------------------------------- SafeBrowsingProtocolManager::SafeBrowsingProtocolManager( @@ -93,9 +77,6 @@ SafeBrowsingProtocolManager::SafeBrowsingProtocolManager( } SafeBrowsingProtocolManager::~SafeBrowsingProtocolManager() { - if (update_timer_.get()) - MessageLoop::current()->timer_manager()->StopTimer(update_timer_.get()); - // Delete in-progress SafeBrowsing requests. STLDeleteContainerPairFirstPointers(hash_requests_.begin(), hash_requests_.end()); @@ -399,17 +380,13 @@ void SafeBrowsingProtocolManager::Initialize() { void SafeBrowsingProtocolManager::ScheduleNextUpdate(bool back_off) { DCHECK(next_update_sec_ > 0); - if (!update_task_.get()) - update_task_.reset(new SafeBrowsingProtocolUpdateTask(this)); - - // Unschedule any current timer & task. - TimerManager* tm = MessageLoop::current()->timer_manager(); - if (update_timer_.get()) - tm->StopTimer(update_timer_.get()); + // Unschedule any current timer. + update_timer_.Stop(); // Reschedule with the new update. const int next_update = GetNextUpdateTime(back_off); - update_timer_.reset(tm->StartTimer(next_update, update_task_.get(), false)); + update_timer_.Start(TimeDelta::FromMilliseconds(next_update), this, + &SafeBrowsingProtocolManager::GetNextUpdate); } // According to section 5 of the SafeBrowsing protocol specification, we must diff --git a/chrome/browser/safe_browsing/protocol_manager.h b/chrome/browser/safe_browsing/protocol_manager.h index 1b12d5c6..c7276c6 100644 --- a/chrome/browser/safe_browsing/protocol_manager.h +++ b/chrome/browser/safe_browsing/protocol_manager.h @@ -159,8 +159,7 @@ class SafeBrowsingProtocolManager : public URLFetcher::Delegate { // For managing the next earliest time to query the SafeBrowsing servers for // updates. int next_update_sec_; - scoped_ptr<Task> update_task_; - scoped_ptr<Timer> update_timer_; + base::OneShotTimer<SafeBrowsingProtocolManager> update_timer_; // All chunk requests that need to be made, along with their MAC. std::deque<ChunkUrl> chunk_request_urls_; |
