OLD | NEW |
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.h" | 5 #include "base/message_loop.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 } | 248 } |
249 | 249 |
250 void MessageLoop::RemoveDestructionObserver( | 250 void MessageLoop::RemoveDestructionObserver( |
251 DestructionObserver* destruction_observer) { | 251 DestructionObserver* destruction_observer) { |
252 DCHECK_EQ(this, current()); | 252 DCHECK_EQ(this, current()); |
253 destruction_observers_.RemoveObserver(destruction_observer); | 253 destruction_observers_.RemoveObserver(destruction_observer); |
254 } | 254 } |
255 | 255 |
256 void MessageLoop::PostTask( | 256 void MessageLoop::PostTask( |
257 const tracked_objects::Location& from_here, Task* task) { | 257 const tracked_objects::Location& from_here, Task* task) { |
| 258 CHECK(task); |
258 PendingTask pending_task( | 259 PendingTask pending_task( |
259 base::Bind(&TaskClosureAdapter::Run, | 260 base::Bind(&TaskClosureAdapter::Run, |
260 new TaskClosureAdapter(task, &should_leak_tasks_)), | 261 new TaskClosureAdapter(task, &should_leak_tasks_)), |
261 from_here, | 262 from_here, |
262 CalculateDelayedRuntime(0), true); | 263 CalculateDelayedRuntime(0), true); |
263 AddToIncomingQueue(&pending_task); | 264 AddToIncomingQueue(&pending_task); |
264 } | 265 } |
265 | 266 |
266 void MessageLoop::PostDelayedTask( | 267 void MessageLoop::PostDelayedTask( |
267 const tracked_objects::Location& from_here, Task* task, int64 delay_ms) { | 268 const tracked_objects::Location& from_here, Task* task, int64 delay_ms) { |
| 269 CHECK(task); |
268 PendingTask pending_task( | 270 PendingTask pending_task( |
269 base::Bind(&TaskClosureAdapter::Run, | 271 base::Bind(&TaskClosureAdapter::Run, |
270 new TaskClosureAdapter(task, &should_leak_tasks_)), | 272 new TaskClosureAdapter(task, &should_leak_tasks_)), |
271 from_here, | 273 from_here, |
272 CalculateDelayedRuntime(delay_ms), true); | 274 CalculateDelayedRuntime(delay_ms), true); |
273 AddToIncomingQueue(&pending_task); | 275 AddToIncomingQueue(&pending_task); |
274 } | 276 } |
275 | 277 |
276 void MessageLoop::PostNonNestableTask( | 278 void MessageLoop::PostNonNestableTask( |
277 const tracked_objects::Location& from_here, Task* task) { | 279 const tracked_objects::Location& from_here, Task* task) { |
| 280 CHECK(task); |
278 PendingTask pending_task( | 281 PendingTask pending_task( |
279 base::Bind(&TaskClosureAdapter::Run, | 282 base::Bind(&TaskClosureAdapter::Run, |
280 new TaskClosureAdapter(task, &should_leak_tasks_)), | 283 new TaskClosureAdapter(task, &should_leak_tasks_)), |
281 from_here, | 284 from_here, |
282 CalculateDelayedRuntime(0), false); | 285 CalculateDelayedRuntime(0), false); |
283 AddToIncomingQueue(&pending_task); | 286 AddToIncomingQueue(&pending_task); |
284 } | 287 } |
285 | 288 |
286 void MessageLoop::PostNonNestableDelayedTask( | 289 void MessageLoop::PostNonNestableDelayedTask( |
287 const tracked_objects::Location& from_here, Task* task, int64 delay_ms) { | 290 const tracked_objects::Location& from_here, Task* task, int64 delay_ms) { |
| 291 CHECK(task); |
288 PendingTask pending_task( | 292 PendingTask pending_task( |
289 base::Bind(&TaskClosureAdapter::Run, | 293 base::Bind(&TaskClosureAdapter::Run, |
290 new TaskClosureAdapter(task, &should_leak_tasks_)), | 294 new TaskClosureAdapter(task, &should_leak_tasks_)), |
291 from_here, | 295 from_here, |
292 CalculateDelayedRuntime(delay_ms), false); | 296 CalculateDelayedRuntime(delay_ms), false); |
293 AddToIncomingQueue(&pending_task); | 297 AddToIncomingQueue(&pending_task); |
294 } | 298 } |
295 | 299 |
296 void MessageLoop::PostTask( | 300 void MessageLoop::PostTask( |
297 const tracked_objects::Location& from_here, const base::Closure& task) { | 301 const tracked_objects::Location& from_here, const base::Closure& task) { |
298 DCHECK(!task.is_null()); | 302 CHECK(!task.is_null()); |
299 PendingTask pending_task(task, from_here, CalculateDelayedRuntime(0), true); | 303 PendingTask pending_task(task, from_here, CalculateDelayedRuntime(0), true); |
300 AddToIncomingQueue(&pending_task); | 304 AddToIncomingQueue(&pending_task); |
301 } | 305 } |
302 | 306 |
303 void MessageLoop::PostDelayedTask( | 307 void MessageLoop::PostDelayedTask( |
304 const tracked_objects::Location& from_here, const base::Closure& task, | 308 const tracked_objects::Location& from_here, const base::Closure& task, |
305 int64 delay_ms) { | 309 int64 delay_ms) { |
306 DCHECK(!task.is_null()); | 310 CHECK(!task.is_null()); |
307 PendingTask pending_task(task, from_here, | 311 PendingTask pending_task(task, from_here, |
308 CalculateDelayedRuntime(delay_ms), true); | 312 CalculateDelayedRuntime(delay_ms), true); |
309 AddToIncomingQueue(&pending_task); | 313 AddToIncomingQueue(&pending_task); |
310 } | 314 } |
311 | 315 |
312 void MessageLoop::PostNonNestableTask( | 316 void MessageLoop::PostNonNestableTask( |
313 const tracked_objects::Location& from_here, const base::Closure& task) { | 317 const tracked_objects::Location& from_here, const base::Closure& task) { |
314 DCHECK(!task.is_null()); | 318 CHECK(!task.is_null()); |
315 PendingTask pending_task(task, from_here, CalculateDelayedRuntime(0), false); | 319 PendingTask pending_task(task, from_here, CalculateDelayedRuntime(0), false); |
316 AddToIncomingQueue(&pending_task); | 320 AddToIncomingQueue(&pending_task); |
317 } | 321 } |
318 | 322 |
319 void MessageLoop::PostNonNestableDelayedTask( | 323 void MessageLoop::PostNonNestableDelayedTask( |
320 const tracked_objects::Location& from_here, const base::Closure& task, | 324 const tracked_objects::Location& from_here, const base::Closure& task, |
321 int64 delay_ms) { | 325 int64 delay_ms) { |
322 DCHECK(!task.is_null()); | 326 CHECK(!task.is_null()); |
323 PendingTask pending_task(task, from_here, | 327 PendingTask pending_task(task, from_here, |
324 CalculateDelayedRuntime(delay_ms), false); | 328 CalculateDelayedRuntime(delay_ms), false); |
325 AddToIncomingQueue(&pending_task); | 329 AddToIncomingQueue(&pending_task); |
326 } | 330 } |
327 | 331 |
328 void MessageLoop::Run() { | 332 void MessageLoop::Run() { |
329 AutoRunState save_state(this); | 333 AutoRunState save_state(this); |
330 RunHandler(); | 334 RunHandler(); |
331 } | 335 } |
332 | 336 |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 Watcher *delegate) { | 841 Watcher *delegate) { |
838 return pump_libevent()->WatchFileDescriptor( | 842 return pump_libevent()->WatchFileDescriptor( |
839 fd, | 843 fd, |
840 persistent, | 844 persistent, |
841 static_cast<base::MessagePumpLibevent::Mode>(mode), | 845 static_cast<base::MessagePumpLibevent::Mode>(mode), |
842 controller, | 846 controller, |
843 delegate); | 847 delegate); |
844 } | 848 } |
845 | 849 |
846 #endif | 850 #endif |
OLD | NEW |