diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-15 23:36:30 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-15 23:36:30 +0000 |
commit | dd1f9fe143f20d4be760c44c974351e8c9aaca6d (patch) | |
tree | 2cc832d55557cb59e5e8c759033e246681019dee /base/pending_task.h | |
parent | f371ee77f051996ea398b0076afc8852d4243d04 (diff) | |
download | chromium_src-dd1f9fe143f20d4be760c44c974351e8c9aaca6d.zip chromium_src-dd1f9fe143f20d4be760c44c974351e8c9aaca6d.tar.gz chromium_src-dd1f9fe143f20d4be760c44c974351e8c9aaca6d.tar.bz2 |
base: Refactor PendingTask out of MessageLoop.
Also removes copy/pasted instances of this class.
BUG=none
TEST=none
R=willchan@chromium.org
Review URL: http://codereview.chromium.org/8565024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110206 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/pending_task.h')
-rw-r--r-- | base/pending_task.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/base/pending_task.h b/base/pending_task.h new file mode 100644 index 0000000..dcaea4c --- /dev/null +++ b/base/pending_task.h @@ -0,0 +1,54 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PENDING_TASK_H_ +#define PENDING_TASK_H_ +#pragma once + +#include <queue> + +#include "base/callback.h" +#include "base/location.h" +#include "base/time.h" +#include "base/tracking_info.h" + +namespace base { + +// Contains data about a pending task. Stored in TaskQueue and DelayedTaskQueue +// for use by classes that queue and execute tasks. +struct PendingTask : public TrackingInfo { + PendingTask(const tracked_objects::Location& posted_from, + const Closure& task); + PendingTask(const tracked_objects::Location& posted_from, + const Closure& task, + TimeTicks delayed_run_time, + bool nestable); + ~PendingTask(); + + // Used to support sorting. + bool operator<(const PendingTask& other) const; + + // The task to run. + Closure task; + + // The site this PendingTask was posted from. + tracked_objects::Location posted_from; + + // Secondary sort key for run time. + int sequence_num; + + // OK to dispatch from a nested loop. + bool nestable; +}; + +// Wrapper around std::queue specialized for PendingTask which adds a Swap +// helper method. +class TaskQueue : public std::queue<PendingTask> { + public: + void Swap(TaskQueue* queue); +}; + +} // namespace base + +#endif // PENDING_TASK_H_ |