| 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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 } | 251 } |
| 252 | 252 |
| 253 void MessageLoop::RemoveDestructionObserver( | 253 void MessageLoop::RemoveDestructionObserver( |
| 254 DestructionObserver* destruction_observer) { | 254 DestructionObserver* destruction_observer) { |
| 255 DCHECK_EQ(this, current()); | 255 DCHECK_EQ(this, current()); |
| 256 destruction_observers_.RemoveObserver(destruction_observer); | 256 destruction_observers_.RemoveObserver(destruction_observer); |
| 257 } | 257 } |
| 258 | 258 |
| 259 void MessageLoop::PostTask( | 259 void MessageLoop::PostTask( |
| 260 const tracked_objects::Location& from_here, Task* task) { | 260 const tracked_objects::Location& from_here, Task* task) { |
| 261 CHECK(task); | 261 DCHECK(task); |
| 262 PendingTask pending_task( | 262 PendingTask pending_task( |
| 263 base::Bind( | 263 base::Bind( |
| 264 &base::subtle::TaskClosureAdapter::Run, | 264 &base::subtle::TaskClosureAdapter::Run, |
| 265 new base::subtle::TaskClosureAdapter(task, &should_leak_tasks_)), | 265 new base::subtle::TaskClosureAdapter(task, &should_leak_tasks_)), |
| 266 from_here, | 266 from_here, |
| 267 CalculateDelayedRuntime(0), true); | 267 CalculateDelayedRuntime(0), true); |
| 268 AddToIncomingQueue(&pending_task); | 268 AddToIncomingQueue(&pending_task); |
| 269 } | 269 } |
| 270 | 270 |
| 271 void MessageLoop::PostDelayedTask( | 271 void MessageLoop::PostDelayedTask( |
| 272 const tracked_objects::Location& from_here, Task* task, int64 delay_ms) { | 272 const tracked_objects::Location& from_here, Task* task, int64 delay_ms) { |
| 273 CHECK(task); | 273 DCHECK(task); |
| 274 PendingTask pending_task( | 274 PendingTask pending_task( |
| 275 base::Bind( | 275 base::Bind( |
| 276 &base::subtle::TaskClosureAdapter::Run, | 276 &base::subtle::TaskClosureAdapter::Run, |
| 277 new base::subtle::TaskClosureAdapter(task, &should_leak_tasks_)), | 277 new base::subtle::TaskClosureAdapter(task, &should_leak_tasks_)), |
| 278 from_here, | 278 from_here, |
| 279 CalculateDelayedRuntime(delay_ms), true); | 279 CalculateDelayedRuntime(delay_ms), true); |
| 280 AddToIncomingQueue(&pending_task); | 280 AddToIncomingQueue(&pending_task); |
| 281 } | 281 } |
| 282 | 282 |
| 283 void MessageLoop::PostNonNestableTask( | 283 void MessageLoop::PostNonNestableTask( |
| 284 const tracked_objects::Location& from_here, Task* task) { | 284 const tracked_objects::Location& from_here, Task* task) { |
| 285 CHECK(task); | 285 DCHECK(task); |
| 286 PendingTask pending_task( | 286 PendingTask pending_task( |
| 287 base::Bind( | 287 base::Bind( |
| 288 &base::subtle::TaskClosureAdapter::Run, | 288 &base::subtle::TaskClosureAdapter::Run, |
| 289 new base::subtle::TaskClosureAdapter(task, &should_leak_tasks_)), | 289 new base::subtle::TaskClosureAdapter(task, &should_leak_tasks_)), |
| 290 from_here, | 290 from_here, |
| 291 CalculateDelayedRuntime(0), false); | 291 CalculateDelayedRuntime(0), false); |
| 292 AddToIncomingQueue(&pending_task); | 292 AddToIncomingQueue(&pending_task); |
| 293 } | 293 } |
| 294 | 294 |
| 295 void MessageLoop::PostNonNestableDelayedTask( | 295 void MessageLoop::PostNonNestableDelayedTask( |
| 296 const tracked_objects::Location& from_here, Task* task, int64 delay_ms) { | 296 const tracked_objects::Location& from_here, Task* task, int64 delay_ms) { |
| 297 CHECK(task); | 297 DCHECK(task); |
| 298 PendingTask pending_task( | 298 PendingTask pending_task( |
| 299 base::Bind( | 299 base::Bind( |
| 300 &base::subtle::TaskClosureAdapter::Run, | 300 &base::subtle::TaskClosureAdapter::Run, |
| 301 new base::subtle::TaskClosureAdapter(task, &should_leak_tasks_)), | 301 new base::subtle::TaskClosureAdapter(task, &should_leak_tasks_)), |
| 302 from_here, | 302 from_here, |
| 303 CalculateDelayedRuntime(delay_ms), false); | 303 CalculateDelayedRuntime(delay_ms), false); |
| 304 AddToIncomingQueue(&pending_task); | 304 AddToIncomingQueue(&pending_task); |
| 305 } | 305 } |
| 306 | 306 |
| 307 void MessageLoop::PostTask( | 307 void MessageLoop::PostTask( |
| 308 const tracked_objects::Location& from_here, const base::Closure& task) { | 308 const tracked_objects::Location& from_here, const base::Closure& task) { |
| 309 CHECK(!task.is_null()) << from_here.ToString(); | 309 DCHECK(!task.is_null()) << from_here.ToString(); |
| 310 PendingTask pending_task(task, from_here, CalculateDelayedRuntime(0), true); | 310 PendingTask pending_task(task, from_here, CalculateDelayedRuntime(0), true); |
| 311 AddToIncomingQueue(&pending_task); | 311 AddToIncomingQueue(&pending_task); |
| 312 } | 312 } |
| 313 | 313 |
| 314 void MessageLoop::PostDelayedTask( | 314 void MessageLoop::PostDelayedTask( |
| 315 const tracked_objects::Location& from_here, const base::Closure& task, | 315 const tracked_objects::Location& from_here, const base::Closure& task, |
| 316 int64 delay_ms) { | 316 int64 delay_ms) { |
| 317 CHECK(!task.is_null()) << from_here.ToString(); | 317 DCHECK(!task.is_null()) << from_here.ToString(); |
| 318 PendingTask pending_task(task, from_here, | 318 PendingTask pending_task(task, from_here, |
| 319 CalculateDelayedRuntime(delay_ms), true); | 319 CalculateDelayedRuntime(delay_ms), true); |
| 320 AddToIncomingQueue(&pending_task); | 320 AddToIncomingQueue(&pending_task); |
| 321 } | 321 } |
| 322 | 322 |
| 323 void MessageLoop::PostNonNestableTask( | 323 void MessageLoop::PostNonNestableTask( |
| 324 const tracked_objects::Location& from_here, const base::Closure& task) { | 324 const tracked_objects::Location& from_here, const base::Closure& task) { |
| 325 CHECK(!task.is_null()) << from_here.ToString(); | 325 DCHECK(!task.is_null()) << from_here.ToString(); |
| 326 PendingTask pending_task(task, from_here, CalculateDelayedRuntime(0), false); | 326 PendingTask pending_task(task, from_here, CalculateDelayedRuntime(0), false); |
| 327 AddToIncomingQueue(&pending_task); | 327 AddToIncomingQueue(&pending_task); |
| 328 } | 328 } |
| 329 | 329 |
| 330 void MessageLoop::PostNonNestableDelayedTask( | 330 void MessageLoop::PostNonNestableDelayedTask( |
| 331 const tracked_objects::Location& from_here, const base::Closure& task, | 331 const tracked_objects::Location& from_here, const base::Closure& task, |
| 332 int64 delay_ms) { | 332 int64 delay_ms) { |
| 333 CHECK(!task.is_null()) << from_here.ToString(); | 333 DCHECK(!task.is_null()) << from_here.ToString(); |
| 334 PendingTask pending_task(task, from_here, | 334 PendingTask pending_task(task, from_here, |
| 335 CalculateDelayedRuntime(delay_ms), false); | 335 CalculateDelayedRuntime(delay_ms), false); |
| 336 AddToIncomingQueue(&pending_task); | 336 AddToIncomingQueue(&pending_task); |
| 337 } | 337 } |
| 338 | 338 |
| 339 void MessageLoop::Run() { | 339 void MessageLoop::Run() { |
| 340 AutoRunState save_state(this); | 340 AutoRunState save_state(this); |
| 341 RunHandler(); | 341 RunHandler(); |
| 342 } | 342 } |
| 343 | 343 |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 Watcher *delegate) { | 870 Watcher *delegate) { |
| 871 return pump_libevent()->WatchFileDescriptor( | 871 return pump_libevent()->WatchFileDescriptor( |
| 872 fd, | 872 fd, |
| 873 persistent, | 873 persistent, |
| 874 static_cast<base::MessagePumpLibevent::Mode>(mode), | 874 static_cast<base::MessagePumpLibevent::Mode>(mode), |
| 875 controller, | 875 controller, |
| 876 delegate); | 876 delegate); |
| 877 } | 877 } |
| 878 | 878 |
| 879 #endif | 879 #endif |
| OLD | NEW |