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