| 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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 destruction_observers_.AddObserver(destruction_observer); | 242 destruction_observers_.AddObserver(destruction_observer); |
| 243 } | 243 } |
| 244 | 244 |
| 245 void MessageLoop::RemoveDestructionObserver( | 245 void MessageLoop::RemoveDestructionObserver( |
| 246 DestructionObserver* destruction_observer) { | 246 DestructionObserver* destruction_observer) { |
| 247 DCHECK_EQ(this, current()); | 247 DCHECK_EQ(this, current()); |
| 248 destruction_observers_.RemoveObserver(destruction_observer); | 248 destruction_observers_.RemoveObserver(destruction_observer); |
| 249 } | 249 } |
| 250 | 250 |
| 251 void MessageLoop::PostTask( | 251 void MessageLoop::PostTask( |
| 252 const tracked_objects::Location& from_here, Task* task) { | |
| 253 DCHECK(task); | |
| 254 PendingTask pending_task( | |
| 255 from_here, | |
| 256 base::Bind( | |
| 257 &base::subtle::TaskClosureAdapter::Run, | |
| 258 new base::subtle::TaskClosureAdapter(task, &should_leak_tasks_)), | |
| 259 CalculateDelayedRuntime(0), true); | |
| 260 AddToIncomingQueue(&pending_task); | |
| 261 } | |
| 262 | |
| 263 void MessageLoop::PostDelayedTask( | |
| 264 const tracked_objects::Location& from_here, Task* task, int64 delay_ms) { | |
| 265 DCHECK(task); | |
| 266 PendingTask pending_task( | |
| 267 from_here, | |
| 268 base::Bind( | |
| 269 &base::subtle::TaskClosureAdapter::Run, | |
| 270 new base::subtle::TaskClosureAdapter(task, &should_leak_tasks_)), | |
| 271 CalculateDelayedRuntime(delay_ms), true); | |
| 272 AddToIncomingQueue(&pending_task); | |
| 273 } | |
| 274 | |
| 275 void MessageLoop::PostDelayedTask( | |
| 276 const tracked_objects::Location& from_here, | |
| 277 Task* task, | |
| 278 base::TimeDelta delay) { | |
| 279 PostDelayedTask(from_here, task, delay.InMillisecondsRoundedUp()); | |
| 280 } | |
| 281 | |
| 282 void MessageLoop::PostNonNestableTask( | |
| 283 const tracked_objects::Location& from_here, Task* task) { | |
| 284 DCHECK(task); | |
| 285 PendingTask pending_task( | |
| 286 from_here, | |
| 287 base::Bind( | |
| 288 &base::subtle::TaskClosureAdapter::Run, | |
| 289 new base::subtle::TaskClosureAdapter(task, &should_leak_tasks_)), | |
| 290 CalculateDelayedRuntime(0), false); | |
| 291 AddToIncomingQueue(&pending_task); | |
| 292 } | |
| 293 | |
| 294 void MessageLoop::PostNonNestableDelayedTask( | |
| 295 const tracked_objects::Location& from_here, Task* task, int64 delay_ms) { | |
| 296 DCHECK(task); | |
| 297 PendingTask pending_task( | |
| 298 from_here, | |
| 299 base::Bind( | |
| 300 &base::subtle::TaskClosureAdapter::Run, | |
| 301 new base::subtle::TaskClosureAdapter(task, &should_leak_tasks_)), | |
| 302 CalculateDelayedRuntime(delay_ms), false); | |
| 303 AddToIncomingQueue(&pending_task); | |
| 304 } | |
| 305 | |
| 306 void MessageLoop::PostNonNestableDelayedTask( | |
| 307 const tracked_objects::Location& from_here, | |
| 308 Task* task, | |
| 309 base::TimeDelta delay) { | |
| 310 PostNonNestableDelayedTask(from_here, task, delay.InMillisecondsRoundedUp()); | |
| 311 } | |
| 312 | |
| 313 void MessageLoop::PostTask( | |
| 314 const tracked_objects::Location& from_here, const base::Closure& task) { | 252 const tracked_objects::Location& from_here, const base::Closure& task) { |
| 315 DCHECK(!task.is_null()) << from_here.ToString(); | 253 DCHECK(!task.is_null()) << from_here.ToString(); |
| 316 PendingTask pending_task(from_here, task, CalculateDelayedRuntime(0), true); | 254 PendingTask pending_task(from_here, task, CalculateDelayedRuntime(0), true); |
| 317 AddToIncomingQueue(&pending_task); | 255 AddToIncomingQueue(&pending_task); |
| 318 } | 256 } |
| 319 | 257 |
| 320 void MessageLoop::PostDelayedTask( | 258 void MessageLoop::PostDelayedTask( |
| 321 const tracked_objects::Location& from_here, | 259 const tracked_objects::Location& from_here, |
| 322 const base::Closure& task, | 260 const base::Closure& task, |
| 323 int64 delay_ms) { | 261 int64 delay_ms) { |
| (...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 869 Watcher *delegate) { | 807 Watcher *delegate) { |
| 870 return pump_libevent()->WatchFileDescriptor( | 808 return pump_libevent()->WatchFileDescriptor( |
| 871 fd, | 809 fd, |
| 872 persistent, | 810 persistent, |
| 873 static_cast<base::MessagePumpLibevent::Mode>(mode), | 811 static_cast<base::MessagePumpLibevent::Mode>(mode), |
| 874 controller, | 812 controller, |
| 875 delegate); | 813 delegate); |
| 876 } | 814 } |
| 877 | 815 |
| 878 #endif | 816 #endif |
| OLD | NEW |