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

Side by Side Diff: base/message_loop/message_loop_task_runner.cc

Issue 2637843002: Migrate base::TaskRunner from Closure to OnceClosure (Closed)
Patch Set: rebase Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/message_loop/message_loop_task_runner.h" 5 #include "base/message_loop/message_loop_task_runner.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/message_loop/incoming_task_queue.h" 11 #include "base/message_loop/incoming_task_queue.h"
12 12
13 namespace base { 13 namespace base {
14 namespace internal { 14 namespace internal {
15 15
16 MessageLoopTaskRunner::MessageLoopTaskRunner( 16 MessageLoopTaskRunner::MessageLoopTaskRunner(
17 scoped_refptr<IncomingTaskQueue> incoming_queue) 17 scoped_refptr<IncomingTaskQueue> incoming_queue)
18 : incoming_queue_(incoming_queue), valid_thread_id_(kInvalidThreadId) { 18 : incoming_queue_(incoming_queue), valid_thread_id_(kInvalidThreadId) {
19 } 19 }
20 20
21 void MessageLoopTaskRunner::BindToCurrentThread() { 21 void MessageLoopTaskRunner::BindToCurrentThread() {
22 AutoLock lock(valid_thread_id_lock_); 22 AutoLock lock(valid_thread_id_lock_);
23 DCHECK_EQ(kInvalidThreadId, valid_thread_id_); 23 DCHECK_EQ(kInvalidThreadId, valid_thread_id_);
24 valid_thread_id_ = PlatformThread::CurrentId(); 24 valid_thread_id_ = PlatformThread::CurrentId();
25 } 25 }
26 26
27 bool MessageLoopTaskRunner::PostDelayedTask( 27 bool MessageLoopTaskRunner::PostDelayedTask(
28 const tracked_objects::Location& from_here, 28 const tracked_objects::Location& from_here,
29 Closure task, 29 OnceClosure task,
30 base::TimeDelta delay) { 30 base::TimeDelta delay) {
31 DCHECK(!task.is_null()) << from_here.ToString(); 31 DCHECK(!task.is_null()) << from_here.ToString();
32 return incoming_queue_->AddToIncomingQueue(from_here, std::move(task), delay, 32 return incoming_queue_->AddToIncomingQueue(from_here, std::move(task), delay,
33 true); 33 true);
34 } 34 }
35 35
36 bool MessageLoopTaskRunner::PostNonNestableDelayedTask( 36 bool MessageLoopTaskRunner::PostNonNestableDelayedTask(
37 const tracked_objects::Location& from_here, 37 const tracked_objects::Location& from_here,
38 Closure task, 38 OnceClosure task,
39 base::TimeDelta delay) { 39 base::TimeDelta delay) {
40 DCHECK(!task.is_null()) << from_here.ToString(); 40 DCHECK(!task.is_null()) << from_here.ToString();
41 return incoming_queue_->AddToIncomingQueue(from_here, std::move(task), delay, 41 return incoming_queue_->AddToIncomingQueue(from_here, std::move(task), delay,
42 false); 42 false);
43 } 43 }
44 44
45 bool MessageLoopTaskRunner::RunsTasksOnCurrentThread() const { 45 bool MessageLoopTaskRunner::RunsTasksOnCurrentThread() const {
46 AutoLock lock(valid_thread_id_lock_); 46 AutoLock lock(valid_thread_id_lock_);
47 return valid_thread_id_ == PlatformThread::CurrentId(); 47 return valid_thread_id_ == PlatformThread::CurrentId();
48 } 48 }
49 49
50 MessageLoopTaskRunner::~MessageLoopTaskRunner() { 50 MessageLoopTaskRunner::~MessageLoopTaskRunner() {
51 } 51 }
52 52
53 } // namespace internal 53 } // namespace internal
54 54
55 } // namespace base 55 } // namespace base
OLDNEW
« no previous file with comments | « base/message_loop/message_loop_task_runner.h ('k') | base/post_task_and_reply_with_result_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698