Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1677)

Side by Side Diff: content/renderer/scheduler/renderer_task_queue_selector.h

Issue 985813002: Experimental: Remove chromium shared timers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More tests Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_RENDERER_SCHEDULER_RENDERER_TASK_QUEUE_SELECTOR_H_ 5 #ifndef CONTENT_RENDERER_SCHEDULER_RENDERER_TASK_QUEUE_SELECTOR_H_
6 #define CONTENT_RENDERER_SCHEDULER_RENDERER_TASK_QUEUE_SELECTOR_H_ 6 #define CONTENT_RENDERER_SCHEDULER_RENDERER_TASK_QUEUE_SELECTOR_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 30 matching lines...) Expand all
41 RendererTaskQueueSelector(); 41 RendererTaskQueueSelector();
42 ~RendererTaskQueueSelector() override; 42 ~RendererTaskQueueSelector() override;
43 43
44 // Set the priority of |queue_index| to |priority|. 44 // Set the priority of |queue_index| to |priority|.
45 void SetQueuePriority(size_t queue_index, QueuePriority priority); 45 void SetQueuePriority(size_t queue_index, QueuePriority priority);
46 46
47 // Enable the |queue_index| with a priority of |priority|. By default all 47 // Enable the |queue_index| with a priority of |priority|. By default all
48 // queues are enabled with normal priority. 48 // queues are enabled with normal priority.
49 void EnableQueue(size_t queue_index, QueuePriority priority); 49 void EnableQueue(size_t queue_index, QueuePriority priority);
50 50
51 // Disable the |queue_index|. 51 // Disable the |queue_index|. Returns true if the queue was previously enabled
52 void DisableQueue(size_t queue_index); 52 // otherwise returns false.
53 bool DisableQueue(size_t queue_index);
53 54
54 // Whether |queue_index| is enabled. 55 // Whether |queue_index| is enabled.
55 bool IsQueueEnabled(size_t queue_index) const; 56 bool IsQueueEnabled(size_t queue_index) const;
56 57
57 // TaskQueueSelector implementation: 58 // TaskQueueSelector implementation:
58 void RegisterWorkQueues( 59 void RegisterWorkQueues(
59 const std::vector<const base::TaskQueue*>& work_queues) override; 60 const std::vector<const base::TaskQueue*>& work_queues) override;
60 bool SelectWorkQueueToService(size_t* out_queue_index) override; 61 bool SelectWorkQueueToService(size_t* out_queue_index) override;
61 void AsValueInto(base::trace_event::TracedValue* state) const override; 62 void AsValueInto(base::trace_event::TracedValue* state) const override;
63 void RegisterTaskQueueObserver(TaskQueueSelectorObserver* observer) override;
62 64
63 private: 65 private:
64 // Returns true if queueA contains an older task than queueB. 66 // Returns true if queueA contains an older task than queueB.
65 static bool IsOlder(const base::TaskQueue* queueA, 67 static bool IsOlder(const base::TaskQueue* queueA,
66 const base::TaskQueue* queueB); 68 const base::TaskQueue* queueB);
67 69
68 // Returns the priority which is next after |priority|. 70 // Returns the priority which is next after |priority|.
69 static QueuePriority NextPriority(QueuePriority priority); 71 static QueuePriority NextPriority(QueuePriority priority);
70 72
71 static const char* PriorityToString(QueuePriority priority); 73 static const char* PriorityToString(QueuePriority priority);
(...skipping 14 matching lines...) Expand all
86 88
87 // Number of high priority tasks which can be run before a normal priority 89 // Number of high priority tasks which can be run before a normal priority
88 // task should be selected to prevent starvation. 90 // task should be selected to prevent starvation.
89 // TODO(rmcilroy): Check if this is a good value. 91 // TODO(rmcilroy): Check if this is a good value.
90 static const size_t kMaxStarvationTasks = 5; 92 static const size_t kMaxStarvationTasks = 5;
91 93
92 base::ThreadChecker main_thread_checker_; 94 base::ThreadChecker main_thread_checker_;
93 std::vector<const base::TaskQueue*> work_queues_; 95 std::vector<const base::TaskQueue*> work_queues_;
94 std::set<size_t> queue_priorities_[QUEUE_PRIORITY_COUNT]; 96 std::set<size_t> queue_priorities_[QUEUE_PRIORITY_COUNT];
95 size_t starvation_count_; 97 size_t starvation_count_;
98 TaskQueueSelectorObserver* task_queue_selector_observer_; // NOT OWNED
96 DISALLOW_COPY_AND_ASSIGN(RendererTaskQueueSelector); 99 DISALLOW_COPY_AND_ASSIGN(RendererTaskQueueSelector);
97 }; 100 };
98 101
99 } // namespace content 102 } // namespace content
100 103
101 #endif // CONTENT_RENDERER_SCHEDULER_RENDERER_TASK_QUEUE_SELECTOR_H_ 104 #endif // CONTENT_RENDERER_SCHEDULER_RENDERER_TASK_QUEUE_SELECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698