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

Side by Side Diff: components/scheduler/child/web_task_runner_impl.cc

Issue 1675633002: WebTaskRunnerImpl to take a TaskQueue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/scheduler/child/web_task_runner_impl.h" 5 #include "components/scheduler/child/web_task_runner_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h" 9 #include "components/scheduler/base/task_queue.h"
10 #include "third_party/WebKit/public/platform/WebTraceLocation.h" 10 #include "third_party/WebKit/public/platform/WebTraceLocation.h"
11 11
12 namespace scheduler { 12 namespace scheduler {
13 13
14 WebTaskRunnerImpl::WebTaskRunnerImpl( 14 WebTaskRunnerImpl::WebTaskRunnerImpl(scoped_refptr<TaskQueue> task_queue)
15 scoped_refptr<base::SingleThreadTaskRunner> task_runner) 15 : task_queue_(task_queue) {}
16 : task_runner_(task_runner) {}
17 16
18 WebTaskRunnerImpl::~WebTaskRunnerImpl() {} 17 WebTaskRunnerImpl::~WebTaskRunnerImpl() {}
19 18
20 void WebTaskRunnerImpl::postTask(const blink::WebTraceLocation& web_location, 19 void WebTaskRunnerImpl::postTask(const blink::WebTraceLocation& web_location,
21 blink::WebTaskRunner::Task* task) { 20 blink::WebTaskRunner::Task* task) {
22 tracked_objects::Location location(web_location.functionName(), 21 tracked_objects::Location location(web_location.functionName(),
23 web_location.fileName(), -1, nullptr); 22 web_location.fileName(), -1, nullptr);
24 task_runner_->PostTask( 23 task_queue_->PostTask(
25 location, 24 location,
26 base::Bind(&WebTaskRunnerImpl::runTask, 25 base::Bind(&WebTaskRunnerImpl::runTask,
27 base::Passed(scoped_ptr<blink::WebTaskRunner::Task>(task)))); 26 base::Passed(scoped_ptr<blink::WebTaskRunner::Task>(task))));
28 } 27 }
29 28
30 void WebTaskRunnerImpl::postDelayedTask( 29 void WebTaskRunnerImpl::postDelayedTask(
31 const blink::WebTraceLocation& web_location, 30 const blink::WebTraceLocation& web_location,
32 blink::WebTaskRunner::Task* task, 31 blink::WebTaskRunner::Task* task,
33 double delayMs) { 32 double delayMs) {
34 DCHECK_GE(delayMs, 0.0); 33 DCHECK_GE(delayMs, 0.0);
35 tracked_objects::Location location(web_location.functionName(), 34 tracked_objects::Location location(web_location.functionName(),
36 web_location.fileName(), -1, nullptr); 35 web_location.fileName(), -1, nullptr);
37 task_runner_->PostDelayedTask( 36 task_queue_->PostDelayedTask(
38 location, 37 location,
39 base::Bind(&WebTaskRunnerImpl::runTask, 38 base::Bind(&WebTaskRunnerImpl::runTask,
40 base::Passed(scoped_ptr<blink::WebTaskRunner::Task>(task))), 39 base::Passed(scoped_ptr<blink::WebTaskRunner::Task>(task))),
41 base::TimeDelta::FromMillisecondsD(delayMs)); 40 base::TimeDelta::FromMillisecondsD(delayMs));
42 } 41 }
43 42
44 blink::WebTaskRunner* WebTaskRunnerImpl::clone() { 43 blink::WebTaskRunner* WebTaskRunnerImpl::clone() {
45 return new WebTaskRunnerImpl(task_runner_); 44 return new WebTaskRunnerImpl(task_queue_);
46 } 45 }
47 46
48 void WebTaskRunnerImpl::runTask(scoped_ptr<blink::WebTaskRunner::Task> task) 47 void WebTaskRunnerImpl::runTask(scoped_ptr<blink::WebTaskRunner::Task> task)
49 { 48 {
50 task->run(); 49 task->run();
51 } 50 }
52 51
53 } // namespace scheduler 52 } // namespace scheduler
OLDNEW
« no previous file with comments | « components/scheduler/child/web_task_runner_impl.h ('k') | components/scheduler/child/webthread_impl_for_worker_scheduler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698