Index: mojo/services/html_viewer/webscheduler_impl.cc |
diff --git a/mojo/services/html_viewer/webscheduler_impl.cc b/mojo/services/html_viewer/webscheduler_impl.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..dac434ea5968ecb2f8bf56a151b60096d8051207 |
--- /dev/null |
+++ b/mojo/services/html_viewer/webscheduler_impl.cc |
@@ -0,0 +1,58 @@ |
+// Copyright 2015 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. |
+ |
+// An implementation of WebThread in terms of base::MessageLoop and |
+// base::Thread |
+ |
+#include "base/bind.h" |
+#include "base/message_loop/message_loop.h" |
+#include "base/tracked_objects.h" |
+#include "mojo/services/html_viewer/webscheduler_impl.h" |
+ |
+namespace html_viewer { |
+ |
+WebSchedulerImpl::WebSchedulerImpl( |
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner) |
+ : task_runner_(task_runner) { |
+} |
+ |
+WebSchedulerImpl::~WebSchedulerImpl() { |
+} |
+ |
+void WebSchedulerImpl::postIdleTask(const blink::WebTraceLocation& web_location, |
+ blink::WebScheduler::IdleTask* task) { |
+ scoped_ptr<blink::WebScheduler::IdleTask> scoped_task(task); |
+ tracked_objects::Location location(web_location.functionName(), |
+ web_location.fileName(), -1, nullptr); |
+ task_runner_->PostTask(location, base::Bind(&WebSchedulerImpl::runIdleTask, |
+ base::Passed(&scoped_task))); |
+} |
+ |
+void WebSchedulerImpl::postLoadingTask( |
+ const blink::WebTraceLocation& web_location, |
+ blink::WebThread::Task* task) { |
+ scoped_ptr<blink::WebThread::Task> scoped_task(task); |
+ tracked_objects::Location location(web_location.functionName(), |
+ web_location.fileName(), -1, nullptr); |
+ task_runner_->PostTask(location, base::Bind(&WebSchedulerImpl::runTask, |
+ base::Passed(&scoped_task))); |
+} |
+ |
+void WebSchedulerImpl::shutdown() { |
+ task_runner_ = nullptr; |
+} |
+ |
+// static |
+void WebSchedulerImpl::runIdleTask( |
+ scoped_ptr<blink::WebScheduler::IdleTask> task) { |
+ // TODO(davemoore) Implement idle scheduling. |
+ task->run(0); |
+} |
+ |
+// static |
+void WebSchedulerImpl::runTask(scoped_ptr<blink::WebThread::Task> task) { |
+ task->run(); |
+} |
+ |
+} // namespace html_viewer |