1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_CHILD_SCHEDULER_TASK_QUEUE_SELECTOR_H_
6 #define CONTENT_CHILD_SCHEDULER_TASK_QUEUE_SELECTOR_H_
10 #include "base/basictypes.h"
11 #include "content/common/content_export.h"
15 namespace trace_event
{
17 } // namespace trace_event
22 class TaskQueueSelector
{
24 virtual ~TaskQueueSelector() {}
26 // Called once to register the work queues to be selected from. This function
27 // is called on the main thread.
28 virtual void RegisterWorkQueues(
29 const std::vector
<const base::TaskQueue
*>& work_queues
) = 0;
31 class CONTENT_EXPORT Observer
{
33 virtual ~Observer() {}
35 // Called when a task queue transitions from disabled to enabled.
36 virtual void OnTaskQueueEnabled() = 0;
39 // Called once to set the Observer. This function is called
40 // on the main thread. If |observer| is null, then no callbacks will occur.
41 virtual void SetTaskQueueSelectorObserver(Observer
* observer
) = 0;
43 // Called to choose the work queue from which the next task should be taken
44 // and run. Return true if |out_queue| indicates the queue to service or
45 // false to avoid running any task.
47 // This function is called on the main thread.
48 virtual bool SelectWorkQueueToService(size_t* out_queue_index
) = 0;
50 // Serialize the selector state for tracing.
51 virtual void AsValueInto(base::trace_event::TracedValue
* state
) const = 0;
54 } // namespace content
56 #endif // CONTENT_CHILD_SCHEDULER_TASK_QUEUE_SELECTOR_H_