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

Side by Side Diff: mojo/services/html_viewer/webscheduler_impl.cc

Issue 959873003: Add WebScheduler implementation to HTMLViewer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 5 years, 10 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
(Empty)
1 // Copyright 2015 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 // An implementation of WebThread in terms of base::MessageLoop and
6 // base::Thread
7
8 #include "base/bind.h"
9 #include "base/message_loop/message_loop.h"
10 #include "base/tracked_objects.h"
11 #include "mojo/services/html_viewer/webscheduler_impl.h"
12
13 namespace html_viewer {
14
15 WebSchedulerImpl::WebSchedulerImpl(
16 scoped_refptr<base::SingleThreadTaskRunner> task_runner)
17 : task_runner_(task_runner) {
18 }
19
20 WebSchedulerImpl::~WebSchedulerImpl() {
21 }
22
23 void WebSchedulerImpl::postIdleTask(const blink::WebTraceLocation& web_location,
24 blink::WebScheduler::IdleTask* task) {
25 scoped_ptr<blink::WebScheduler::IdleTask> scoped_task(task);
26 tracked_objects::Location location(web_location.functionName(),
27 web_location.fileName(), -1, nullptr);
28 task_runner_->PostTask(location, base::Bind(&WebSchedulerImpl::runIdleTask,
29 base::Passed(&scoped_task)));
30 }
31
32 void WebSchedulerImpl::postLoadingTask(
33 const blink::WebTraceLocation& web_location,
34 blink::WebThread::Task* task) {
35 scoped_ptr<blink::WebThread::Task> scoped_task(task);
36 tracked_objects::Location location(web_location.functionName(),
37 web_location.fileName(), -1, nullptr);
38 task_runner_->PostTask(location, base::Bind(&WebSchedulerImpl::runTask,
39 base::Passed(&scoped_task)));
40 }
41
42 void WebSchedulerImpl::shutdown() {
43 task_runner_ = nullptr;
44 }
45
46 // static
47 void WebSchedulerImpl::runIdleTask(
48 scoped_ptr<blink::WebScheduler::IdleTask> task) {
49 // TODO(davemoore) Implement idle scheduling.
50 task->run(0);
51 }
52
53 // static
54 void WebSchedulerImpl::runTask(scoped_ptr<blink::WebThread::Task> task) {
55 task->run();
56 }
57
58 } // namespace html_viewer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698