OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/sync/notifier/base/task_pump.h" |
| 6 |
| 7 #include "chrome/browser/sync/notifier/base/time.h" |
| 8 #include "talk/base/common.h" |
| 9 #include "talk/base/thread.h" |
| 10 |
| 11 namespace notifier { |
| 12 |
| 13 // Don't add any messages because there are cleared and thrown away. |
| 14 enum { MSG_WAKE_UP = 1, MSG_TIMED_WAKE_UP }; |
| 15 |
| 16 TaskPump::TaskPump() : timeout_change_count_(0), posted_(false) { |
| 17 } |
| 18 |
| 19 void TaskPump::OnMessage(talk_base::Message* msg) { |
| 20 posted_ = false; |
| 21 int initial_count = timeout_change_count_; |
| 22 |
| 23 // If a task timed out, ensure that it is not blocked, so it will be deleted. |
| 24 // This may result in a WakeTasks if a task is timed out. |
| 25 PollTasks(); |
| 26 |
| 27 // Run tasks and handle timeouts. |
| 28 RunTasks(); |
| 29 } |
| 30 |
| 31 void TaskPump::WakeTasks() { |
| 32 if (!posted_) { |
| 33 // Do the requested wake up |
| 34 talk_base::Thread::Current()->Post(this, MSG_WAKE_UP); |
| 35 posted_ = true; |
| 36 } |
| 37 } |
| 38 |
| 39 int64 TaskPump::CurrentTime() { |
| 40 return GetCurrent100NSTime(); |
| 41 } |
| 42 } // namespace notifier |
OLD | NEW |