summaryrefslogtreecommitdiffstats
path: root/base/task.h
diff options
context:
space:
mode:
authordarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-30 00:22:48 +0000
committerdarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-30 00:22:48 +0000
commit9bcbf478c173d91958cdabc8a8902619392b7f1f (patch)
treebad2b3022719370e6eb01a66f94924a1f848a968 /base/task.h
parent3f9f500b82c82402d9eef92606ebd149762e9f0c (diff)
downloadchromium_src-9bcbf478c173d91958cdabc8a8902619392b7f1f.zip
chromium_src-9bcbf478c173d91958cdabc8a8902619392b7f1f.tar.gz
chromium_src-9bcbf478c173d91958cdabc8a8902619392b7f1f.tar.bz2
Switch SharedTimerWin over to using PostDelayedTask. I made some tweaks to the
PostDelayedTask implementation to ensure that perf is still good. This involved recording the intended fire time of PostDelayedTask on the Task object so that it can be used to properly determine the delay passed to the StartTimer call. With this change, I am able to service timers (call DoDelayedWork) more often from within the MessagePump implementations. R=mbelshe BUG=1346553 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1578 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/task.h')
-rw-r--r--base/task.h21
1 files changed, 11 insertions, 10 deletions
diff --git a/base/task.h b/base/task.h
index 42277d4..99bec4e 100644
--- a/base/task.h
+++ b/base/task.h
@@ -11,6 +11,7 @@
#include "base/logging.h"
#include "base/non_thread_safe.h"
#include "base/revocable_store.h"
+#include "base/time.h"
#include "base/tracked.h"
#include "base/tuple.h"
@@ -24,6 +25,8 @@ class TimerManager;
class Task;
+// TODO(darin): Eliminate TaskBase. This data is ML specific and is not
+// applicable to other uses of Task.
class TaskBase : public tracked_objects::Tracked {
public:
TaskBase() { Reset(); }
@@ -53,28 +56,23 @@ class TaskBase : public tracked_objects::Tracked {
// derived classes should attempt this feat, as a replacement for creating a
// new instance.
void Reset() {
- posted_task_delay_ = -1;
priority_ = 0;
+ delayed_run_time_ = Time();
next_task_ = NULL;
nestable_ = true;
+ owned_by_message_loop_ = false;
}
private:
friend class base::TimerManager; // To check is_owned_by_message_loop().
- friend class MessageLoop; // To maintain posted_task_delay().
-
- // Access methods used ONLY by friends in MessageLoop and TimerManager
- int posted_task_delay() const { return posted_task_delay_; }
- bool is_owned_by_message_loop() const { return 0 <= posted_task_delay_; }
- void set_posted_task_delay(int delay) { posted_task_delay_ = delay; }
+ friend class MessageLoop; // To maintain posted_task_delay().
// Priority for execution by MessageLoop. 0 is default. Higher means run
// sooner, and lower (including negative) means run less soon.
int priority_;
- // Slot to hold delay if the task was passed to PostTask(). If it was not
- // passed to PostTask, then the delay is negative (the default).
- int posted_task_delay_;
+ // The time when a delayed task should be run.
+ Time delayed_run_time_;
// When tasks are collected into a queue by MessageLoop, this member is used
// to form a null terminated list.
@@ -84,6 +82,9 @@ class TaskBase : public tracked_objects::Tracked {
// only in the top level message loop.
bool nestable_;
+ // True if this Task is owned by the message loop.
+ bool owned_by_message_loop_;
+
DISALLOW_COPY_AND_ASSIGN(TaskBase);
};