| 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
|
|
|