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

Side by Side Diff: content/renderer/renderer_message_loop.cc

Issue 281073002: NOT FOR REVIEW: Adding prioritized incoming task queue to renderers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Prioritize input events Created 6 years, 7 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
« no previous file with comments | « content/renderer/renderer_message_loop.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "content/renderer/renderer_message_loop.h"
6
7 #include "base/message_loop/high_priority_task_runner.h"
8 #include "content/renderer/render_thread_impl.h"
9
10 namespace content {
11
12 RendererMessageLoop::RendererMessageLoop()
13 : normal_work_queue_deficit_(0) {
14 high_priority_task_runner_ = new base::HighPriorityTaskRunner(this);
15 }
16
17 RendererMessageLoop::RendererMessageLoop(scoped_ptr<base::MessagePump> pump)
18 : MessageLoop(pump.Pass()),
19 normal_work_queue_deficit_(0) {
20 high_priority_task_runner_ = new base::HighPriorityTaskRunner(this);
21 }
22
23 RendererMessageLoop::~RendererMessageLoop() {
24 }
25
26 void RendererMessageLoop::EnableHighPriorityIncomingTaskQueue() {
27 DCHECK(RenderThreadImpl::current());
28 DCHECK(!is_running());
29
30 RenderThreadImpl::current()->UseHighPriorityTaskRunner(
31 high_priority_task_runner_);
32 }
33
34 void RendererMessageLoop::ReloadWorkQueue() {
35 MessageLoop::ReloadWorkQueue();
36 if (high_priority_work_queue_.empty())
37 high_priority_task_runner_->ReloadWorkQueue(&high_priority_work_queue_);
38 }
39
40 base::TaskQueue& RendererMessageLoop::SelectNextWorkQueue() {
41 // TODO(bashi): Need to be tuned.
42 static const int kMaxDeficit = 1000;
43 if (!high_priority_work_queue_.empty() &&
44 normal_work_queue_deficit_ <= kMaxDeficit) {
45 ++normal_work_queue_deficit_;
46 return high_priority_work_queue_;
47 }
48
49 normal_work_queue_deficit_ = 0;
50 return MessageLoop::SelectNextWorkQueue();
51 }
52
53 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/renderer_message_loop.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698