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

Unified Diff: content/renderer/renderer_high_priority_task_queue.cc

Issue 242103007: NOT FOR REVIEW - prioritize fonts Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/renderer_high_priority_task_queue.h ('k') | content/renderer/renderer_main.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/renderer_high_priority_task_queue.cc
diff --git a/content/renderer/renderer_high_priority_task_queue.cc b/content/renderer/renderer_high_priority_task_queue.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d011dff8933acc4d8571dbfbc5a97a3d43cc513c
--- /dev/null
+++ b/content/renderer/renderer_high_priority_task_queue.cc
@@ -0,0 +1,87 @@
+// Copyright (c) 2012 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.
+
+#include "base/lazy_instance.h"
+#include "base/message_loop/message_loop_proxy_impl.h"
+#include "base/time/time.h"
+#include "base/threading/thread_restrictions.h"
+#include "content/renderer/renderer_high_priority_task_queue.h"
+
+#include <stdio.h>
+
+namespace content {
+class RendererHighPriorityTaskQueueImpl {
+public:
+ RendererHighPriorityTaskQueueImpl();
+ ~RendererHighPriorityTaskQueueImpl();
+
+ void Init(scoped_refptr<base::MessageLoopProxy> proxy);
+ bool PostTask(const tracked_objects::Location& from_here,
+ const base::Closure& task);
+
+private:
+ scoped_refptr<base::MessageLoopProxy> high_priority_message_loop_proxy_;
+};
+
+namespace {
+base::LazyInstance<RendererHighPriorityTaskQueueImpl>::Leaky g_lazy_instance;
+} // namespace
+
+
+MessageLoopRendererMainThread::MessageLoopRendererMainThread() {
+ high_priority_incoming_task_queue_ =
+ new base::internal::IncomingTaskQueue(this);
+ high_priority_message_loop_proxy_ =
+ new base::internal::MessageLoopProxyImpl(
+ high_priority_incoming_task_queue_);
+ g_lazy_instance.Get().Init(high_priority_message_loop_proxy_);
+}
+
+void MessageLoopRendererMainThread::ReloadHighPriorityWorkQueue() {
+ if (high_priority_work_queue_.empty())
+ high_priority_incoming_task_queue_->ReloadWorkQueue(
+ &high_priority_work_queue_);
+}
+
+void MessageLoopRendererMainThread::ReloadAllWorkQueues() {
+ MessageLoop::ReloadAllWorkQueues();
+ ReloadHighPriorityWorkQueue();
+}
+
+base::TaskQueue& MessageLoopRendererMainThread::GetNextWorkQueue() {
+ base::TaskQueue& current_task_queue = !high_priority_work_queue_.empty() ?
+ high_priority_work_queue_ : MessageLoop::GetNextWorkQueue();
+ return current_task_queue;
+}
+
+bool MessageLoopRendererMainThread::HasWorkAvailable() const {
+ return !high_priority_work_queue_.empty() || MessageLoop::HasWorkAvailable();
+}
+
+
+RendererHighPriorityTaskQueueImpl::RendererHighPriorityTaskQueueImpl() {
+}
+
+RendererHighPriorityTaskQueueImpl::~RendererHighPriorityTaskQueueImpl() {
+}
+
+void RendererHighPriorityTaskQueueImpl::Init(
+ scoped_refptr<base::MessageLoopProxy> proxy) {
+ high_priority_message_loop_proxy_ = proxy;
+}
+
+bool RendererHighPriorityTaskQueueImpl::PostTask(
+ const tracked_objects::Location& from_here,
+ const base::Closure& task) {
+ return high_priority_message_loop_proxy_->PostTask(from_here, task);
+}
+
+// static
+bool RendererHighPriorityTaskQueue::PostTask(
+ const tracked_objects::Location& from_here,
+ const base::Closure& task) {
+ return g_lazy_instance.Get().PostTask(from_here, task);
+}
+
+} // namespace content
« no previous file with comments | « content/renderer/renderer_high_priority_task_queue.h ('k') | content/renderer/renderer_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698