| 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 #include "chrome/browser/sync/notifier/base/time.h" | |
| 7 #include "talk/base/common.h" | |
| 8 #include "talk/base/thread.h" | |
| 9 | |
| 10 namespace notifier { | |
| 11 | |
| 12 // Don't add any messages because there are cleared and thrown away. | |
| 13 enum { MSG_WAKE_UP = 1, MSG_TIMED_WAKE_UP }; | |
| 14 | |
| 15 TaskPump::TaskPump() : timeout_change_count_(0), posted_(false) { | |
| 16 } | |
| 17 | |
| 18 void TaskPump::OnMessage(talk_base::Message* msg) { | |
| 19 posted_ = false; | |
| 20 | |
| 21 // If a task timed out, ensure that it is not blocked, so it will be deleted. | |
| 22 // This may result in a WakeTasks if a task is timed out. | |
| 23 PollTasks(); | |
| 24 | |
| 25 // Run tasks and handle timeouts. | |
| 26 RunTasks(); | |
| 27 } | |
| 28 | |
| 29 void TaskPump::WakeTasks() { | |
| 30 if (!posted_) { | |
| 31 // Do the requested wake up. | |
| 32 talk_base::Thread::Current()->Post(this, MSG_WAKE_UP); | |
| 33 posted_ = true; | |
| 34 } | |
| 35 } | |
| 36 | |
| 37 int64 TaskPump::CurrentTime() { | |
| 38 return GetCurrent100NSTime(); | |
| 39 } | |
| 40 | |
| 41 } // namespace notifier | |
| OLD | NEW |