Commit 8380ebee authored by dcheng@chromium.org's avatar dcheng@chromium.org

Remove Task inheritance from base::Timer.

BUG=none
TEST=trybots
TBR=brettw

Review URL: http://codereview.chromium.org/8898019

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114679 0039d316-1c4b-4281-b951-d872f2087c98
parent 99d3f1cc
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "base/timer.h" #include "base/timer.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/message_loop.h" #include "base/message_loop.h"
namespace base { namespace base {
...@@ -21,7 +23,8 @@ void BaseTimer_Helper::InitiateDelayedTask(TimerTask* timer_task) { ...@@ -21,7 +23,8 @@ void BaseTimer_Helper::InitiateDelayedTask(TimerTask* timer_task) {
delayed_task_ = timer_task; delayed_task_ = timer_task;
delayed_task_->timer_ = this; delayed_task_->timer_ = this;
MessageLoop::current()->PostDelayedTask( MessageLoop::current()->PostDelayedTask(
timer_task->posted_from_, timer_task, timer_task->posted_from_,
base::Bind(&TimerTask::Run, base::Owned(timer_task)),
static_cast<int>(timer_task->delay_.InMillisecondsRoundedUp())); static_cast<int>(timer_task->delay_.InMillisecondsRoundedUp()));
} }
......
...@@ -50,7 +50,6 @@ ...@@ -50,7 +50,6 @@
#include "base/base_export.h" #include "base/base_export.h"
#include "base/location.h" #include "base/location.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/task.h"
#include "base/time.h" #include "base/time.h"
class MessageLoop; class MessageLoop;
...@@ -86,7 +85,7 @@ class BASE_EXPORT BaseTimer_Helper { ...@@ -86,7 +85,7 @@ class BASE_EXPORT BaseTimer_Helper {
BaseTimer_Helper() : delayed_task_(NULL) {} BaseTimer_Helper() : delayed_task_(NULL) {}
// We have access to the timer_ member so we can orphan this task. // We have access to the timer_ member so we can orphan this task.
class TimerTask : public Task { class TimerTask {
public: public:
TimerTask(const tracked_objects::Location& posted_from, TimerTask(const tracked_objects::Location& posted_from,
TimeDelta delay) TimeDelta delay)
...@@ -95,6 +94,7 @@ class BASE_EXPORT BaseTimer_Helper { ...@@ -95,6 +94,7 @@ class BASE_EXPORT BaseTimer_Helper {
delay_(delay) { delay_(delay) {
} }
virtual ~TimerTask() {} virtual ~TimerTask() {}
virtual void Run() = 0;
tracked_objects::Location posted_from_; tracked_objects::Location posted_from_;
BaseTimer_Helper* timer_; BaseTimer_Helper* timer_;
TimeDelta delay_; TimeDelta delay_;
...@@ -170,7 +170,7 @@ class BaseTimer : public BaseTimer_Helper { ...@@ -170,7 +170,7 @@ class BaseTimer : public BaseTimer_Helper {
ResetBaseTimer(); ResetBaseTimer();
else else
ClearBaseTimer(); ClearBaseTimer();
DispatchToMethod(receiver_, method_, Tuple0()); (receiver_->*method_)();
} }
TimerTask* Clone() const { TimerTask* Clone() const {
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_CONTENTS_VIEW_H_ #define CHROME_BROWSER_UI_VIEWS_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_CONTENTS_VIEW_H_
#pragma once #pragma once
#include "base/memory/weak_ptr.h"
#include "chrome/browser/autocomplete/autocomplete.h" #include "chrome/browser/autocomplete/autocomplete.h"
#include "chrome/browser/autocomplete/autocomplete_popup_model.h" #include "chrome/browser/autocomplete/autocomplete_popup_model.h"
#include "chrome/browser/autocomplete/autocomplete_popup_view.h" #include "chrome/browser/autocomplete/autocomplete_popup_view.h"
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "base/callback.h" #include "base/callback.h"
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/process_util.h" #include "base/process_util.h"
#include "base/property_bag.h" #include "base/property_bag.h"
#include "base/string16.h" #include "base/string16.h"
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#endif #endif
#include "base/memory/scoped_handle.h" #include "base/memory/scoped_handle.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/shared_memory.h" #include "base/shared_memory.h"
#include "base/timer.h" #include "base/timer.h"
#include "googleurl/src/gurl.h" #include "googleurl/src/gurl.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment