security/sandbox/chromium/base/pending_task.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/sandbox/chromium/base/pending_task.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,60 @@
     1.4 +// Copyright (c) 2011 The Chromium Authors. All rights reserved.
     1.5 +// Use of this source code is governed by a BSD-style license that can be
     1.6 +// found in the LICENSE file.
     1.7 +
     1.8 +#ifndef PENDING_TASK_H_
     1.9 +#define PENDING_TASK_H_
    1.10 +
    1.11 +#include <queue>
    1.12 +
    1.13 +#include "base/base_export.h"
    1.14 +#include "base/callback.h"
    1.15 +#include "base/location.h"
    1.16 +#include "base/time/time.h"
    1.17 +#include "base/tracking_info.h"
    1.18 +
    1.19 +namespace base {
    1.20 +
    1.21 +// Contains data about a pending task. Stored in TaskQueue and DelayedTaskQueue
    1.22 +// for use by classes that queue and execute tasks.
    1.23 +struct BASE_EXPORT PendingTask : public TrackingInfo {
    1.24 +#if _MSC_VER >= 1700
    1.25 +  PendingTask();
    1.26 +#endif
    1.27 +  PendingTask(const tracked_objects::Location& posted_from,
    1.28 +              const Closure& task);
    1.29 +  PendingTask(const tracked_objects::Location& posted_from,
    1.30 +              const Closure& task,
    1.31 +              TimeTicks delayed_run_time,
    1.32 +              bool nestable);
    1.33 +  ~PendingTask();
    1.34 +
    1.35 +  // Used to support sorting.
    1.36 +  bool operator<(const PendingTask& other) const;
    1.37 +
    1.38 +  // The task to run.
    1.39 +  Closure task;
    1.40 +
    1.41 +  // The site this PendingTask was posted from.
    1.42 +  tracked_objects::Location posted_from;
    1.43 +
    1.44 +  // Secondary sort key for run time.
    1.45 +  int sequence_num;
    1.46 +
    1.47 +  // OK to dispatch from a nested loop.
    1.48 +  bool nestable;
    1.49 +};
    1.50 +
    1.51 +// Wrapper around std::queue specialized for PendingTask which adds a Swap
    1.52 +// helper method.
    1.53 +class BASE_EXPORT TaskQueue : public std::queue<PendingTask> {
    1.54 + public:
    1.55 +  void Swap(TaskQueue* queue);
    1.56 +};
    1.57 +
    1.58 +// PendingTasks are sorted by their |delayed_run_time| property.
    1.59 +typedef std::priority_queue<base::PendingTask> DelayedTaskQueue;
    1.60 +
    1.61 +}  // namespace base
    1.62 +
    1.63 +#endif  // PENDING_TASK_H_

mercurial