| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 for (;;) { | 377 for (;;) { |
| 378 ReloadWorkQueue(); | 378 ReloadWorkQueue(); |
| 379 if (work_queue_.empty()) | 379 if (work_queue_.empty()) |
| 380 break; | 380 break; |
| 381 | 381 |
| 382 // Execute oldest task. | 382 // Execute oldest task. |
| 383 do { | 383 do { |
| 384 PendingTask pending_task = work_queue_.front(); | 384 PendingTask pending_task = work_queue_.front(); |
| 385 work_queue_.pop(); | 385 work_queue_.pop(); |
| 386 if (!pending_task.delayed_run_time.is_null()) { | 386 if (!pending_task.delayed_run_time.is_null()) { |
| 387 bool was_empty = delayed_work_queue_.empty(); | |
| 388 AddToDelayedWorkQueue(pending_task); | 387 AddToDelayedWorkQueue(pending_task); |
| 389 if (was_empty) // We only schedule the next delayed work item. | 388 // If we changed the topmost task, then it is time to re-schedule. |
| 389 if (delayed_work_queue_.top().task == pending_task.task) |
| 390 pump_->ScheduleDelayedWork(pending_task.delayed_run_time); | 390 pump_->ScheduleDelayedWork(pending_task.delayed_run_time); |
| 391 } else { | 391 } else { |
| 392 if (DeferOrRunPendingTask(pending_task)) | 392 if (DeferOrRunPendingTask(pending_task)) |
| 393 return true; | 393 return true; |
| 394 } | 394 } |
| 395 } while (!work_queue_.empty()); | 395 } while (!work_queue_.empty()); |
| 396 } | 396 } |
| 397 | 397 |
| 398 // Nothing happened. | 398 // Nothing happened. |
| 399 return false; | 399 return false; |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 | 575 |
| 576 void MessageLoopForIO::WatchSocket(int socket, short interest_mask, | 576 void MessageLoopForIO::WatchSocket(int socket, short interest_mask, |
| 577 struct event* e, Watcher* watcher) { | 577 struct event* e, Watcher* watcher) { |
| 578 pump_libevent()->WatchSocket(socket, interest_mask, e, watcher); | 578 pump_libevent()->WatchSocket(socket, interest_mask, e, watcher); |
| 579 } | 579 } |
| 580 | 580 |
| 581 void MessageLoopForIO::UnwatchSocket(struct event* e) { | 581 void MessageLoopForIO::UnwatchSocket(struct event* e) { |
| 582 pump_libevent()->UnwatchSocket(e); | 582 pump_libevent()->UnwatchSocket(e); |
| 583 } | 583 } |
| 584 #endif | 584 #endif |
| OLD | NEW |