michael@0: // Copyright (c) 2011 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: #ifndef PENDING_TASK_H_ michael@0: #define PENDING_TASK_H_ michael@0: michael@0: #include michael@0: michael@0: #include "base/base_export.h" michael@0: #include "base/callback.h" michael@0: #include "base/location.h" michael@0: #include "base/time/time.h" michael@0: #include "base/tracking_info.h" michael@0: michael@0: namespace base { michael@0: michael@0: // Contains data about a pending task. Stored in TaskQueue and DelayedTaskQueue michael@0: // for use by classes that queue and execute tasks. michael@0: struct BASE_EXPORT PendingTask : public TrackingInfo { michael@0: #if _MSC_VER >= 1700 michael@0: PendingTask(); michael@0: #endif michael@0: PendingTask(const tracked_objects::Location& posted_from, michael@0: const Closure& task); michael@0: PendingTask(const tracked_objects::Location& posted_from, michael@0: const Closure& task, michael@0: TimeTicks delayed_run_time, michael@0: bool nestable); michael@0: ~PendingTask(); michael@0: michael@0: // Used to support sorting. michael@0: bool operator<(const PendingTask& other) const; michael@0: michael@0: // The task to run. michael@0: Closure task; michael@0: michael@0: // The site this PendingTask was posted from. michael@0: tracked_objects::Location posted_from; michael@0: michael@0: // Secondary sort key for run time. michael@0: int sequence_num; michael@0: michael@0: // OK to dispatch from a nested loop. michael@0: bool nestable; michael@0: }; michael@0: michael@0: // Wrapper around std::queue specialized for PendingTask which adds a Swap michael@0: // helper method. michael@0: class BASE_EXPORT TaskQueue : public std::queue { michael@0: public: michael@0: void Swap(TaskQueue* queue); michael@0: }; michael@0: michael@0: // PendingTasks are sorted by their |delayed_run_time| property. michael@0: typedef std::priority_queue DelayedTaskQueue; michael@0: michael@0: } // namespace base michael@0: michael@0: #endif // PENDING_TASK_H_