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

Side by Side Diff: base/message_loop_proxy_impl.cc

Issue 9086002: base::Bind: Remove Task. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Style fix. Created 8 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « base/message_loop_proxy_impl.h ('k') | base/message_loop_proxy_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_proxy_impl.h" 5 #include "base/message_loop_proxy_impl.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/threading/thread_restrictions.h" 8 #include "base/threading/thread_restrictions.h"
9 9
10 namespace base { 10 namespace base {
11 11
12 MessageLoopProxyImpl::~MessageLoopProxyImpl() { 12 MessageLoopProxyImpl::~MessageLoopProxyImpl() {
13 } 13 }
14 14
15 // MessageLoopProxy implementation
16 bool MessageLoopProxyImpl::PostTask(const tracked_objects::Location& from_here,
17 Task* task) {
18 return PostTaskHelper(from_here, task, 0, true);
19 }
20
21 bool MessageLoopProxyImpl::PostDelayedTask(
22 const tracked_objects::Location& from_here, Task* task, int64 delay_ms) {
23 return PostTaskHelper(from_here, task, delay_ms, true);
24 }
25
26 bool MessageLoopProxyImpl::PostNonNestableTask(
27 const tracked_objects::Location& from_here, Task* task) {
28 return PostTaskHelper(from_here, task, 0, false);
29 }
30
31 bool MessageLoopProxyImpl::PostNonNestableDelayedTask(
32 const tracked_objects::Location& from_here,
33 Task* task,
34 int64 delay_ms) {
35 return PostTaskHelper(from_here, task, delay_ms, false);
36 }
37
38 bool MessageLoopProxyImpl::PostTask(const tracked_objects::Location& from_here, 15 bool MessageLoopProxyImpl::PostTask(const tracked_objects::Location& from_here,
39 const base::Closure& task) { 16 const base::Closure& task) {
40 return PostTaskHelper(from_here, task, 0, true); 17 return PostTaskHelper(from_here, task, 0, true);
41 } 18 }
42 19
43 bool MessageLoopProxyImpl::PostDelayedTask( 20 bool MessageLoopProxyImpl::PostDelayedTask(
44 const tracked_objects::Location& from_here, 21 const tracked_objects::Location& from_here,
45 const base::Closure& task, 22 const base::Closure& task,
46 int64 delay_ms) { 23 int64 delay_ms) {
47 return PostTaskHelper(from_here, task, delay_ms, true); 24 return PostTaskHelper(from_here, task, delay_ms, true);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } 70 }
94 if (!delete_later) 71 if (!delete_later)
95 delete this; 72 delete this;
96 } 73 }
97 74
98 MessageLoopProxyImpl::MessageLoopProxyImpl() 75 MessageLoopProxyImpl::MessageLoopProxyImpl()
99 : target_message_loop_(MessageLoop::current()) { 76 : target_message_loop_(MessageLoop::current()) {
100 } 77 }
101 78
102 bool MessageLoopProxyImpl::PostTaskHelper( 79 bool MessageLoopProxyImpl::PostTaskHelper(
103 const tracked_objects::Location& from_here, Task* task, int64 delay_ms,
104 bool nestable) {
105 bool ret = false;
106 {
107 AutoLock lock(message_loop_lock_);
108 if (target_message_loop_) {
109 if (nestable) {
110 target_message_loop_->PostDelayedTask(from_here, task, delay_ms);
111 } else {
112 target_message_loop_->PostNonNestableDelayedTask(from_here, task,
113 delay_ms);
114 }
115 ret = true;
116 }
117 }
118 if (!ret)
119 delete task;
120 return ret;
121 }
122
123 bool MessageLoopProxyImpl::PostTaskHelper(
124 const tracked_objects::Location& from_here, const base::Closure& task, 80 const tracked_objects::Location& from_here, const base::Closure& task,
125 int64 delay_ms, bool nestable) { 81 int64 delay_ms, bool nestable) {
126 AutoLock lock(message_loop_lock_); 82 AutoLock lock(message_loop_lock_);
127 if (target_message_loop_) { 83 if (target_message_loop_) {
128 if (nestable) { 84 if (nestable) {
129 target_message_loop_->PostDelayedTask(from_here, task, delay_ms); 85 target_message_loop_->PostDelayedTask(from_here, task, delay_ms);
130 } else { 86 } else {
131 target_message_loop_->PostNonNestableDelayedTask(from_here, task, 87 target_message_loop_->PostNonNestableDelayedTask(from_here, task,
132 delay_ms); 88 delay_ms);
133 } 89 }
134 return true; 90 return true;
135 } 91 }
136 return false; 92 return false;
137 } 93 }
138 94
139 scoped_refptr<MessageLoopProxy> 95 scoped_refptr<MessageLoopProxy>
140 MessageLoopProxy::current() { 96 MessageLoopProxy::current() {
141 MessageLoop* cur_loop = MessageLoop::current(); 97 MessageLoop* cur_loop = MessageLoop::current();
142 if (!cur_loop) 98 if (!cur_loop)
143 return NULL; 99 return NULL;
144 return cur_loop->message_loop_proxy(); 100 return cur_loop->message_loop_proxy();
145 } 101 }
146 102
147 } // namespace base 103 } // namespace base
OLDNEW
« no previous file with comments | « base/message_loop_proxy_impl.h ('k') | base/message_loop_proxy_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698