summaryrefslogtreecommitdiffstats
path: root/content/renderer/scheduler/task_queue_selector.h
blob: efe9bcf91819e731a2e1fbe3f5a794d7746a8808 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright 2014 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 CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_SELECTOR_H_
#define CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_SELECTOR_H_

#include <vector>

#include "base/basictypes.h"

namespace base {
class TaskQueue;
namespace trace_event {
class TracedValue;
}  // namespace trace_event

// TODO(ssid): remove these aliases after the tracing clients are moved to the
// new trace_event namespace. See crbug.com/451032. ETA: March 2015
namespace debug {
using ::base::trace_event::TracedValue;
}  // namespace debug
}  // namespace base

namespace content {

class TaskQueueSelector {
 public:
  virtual ~TaskQueueSelector() {}

  // Called once to register the work queues to be selected from. This function
  // is called on the main thread.
  virtual void RegisterWorkQueues(
      const std::vector<const base::TaskQueue*>& work_queues) = 0;

  // Called to choose the work queue from which the next task should be taken
  // and run. Return true if |out_queue| indicates the queue to service or
  // false to avoid running any task.
  //
  // This function is called on the main thread.
  virtual bool SelectWorkQueueToService(size_t* out_queue_index) = 0;

  // Serialize the selector state for tracing.
  virtual void AsValueInto(base::debug::TracedValue* state) const = 0;
};

}  // namespace content

#endif  // CONTENT_RENDERER_SCHEDULER_TASK_QUEUE_SELECTOR_H_