OLD | NEW |
| (Empty) |
1 // Copyright 2007-2009 Google Inc. | |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 // you may not use this file except in compliance with the License. | |
5 // You may obtain a copy of the License at | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 // ======================================================================== | |
15 | |
16 // TODO(omaha): consider using a waitable timer registered with the reactor. It | |
17 // seems a lot less code than using the QueueTimer class. | |
18 | |
19 #ifndef OMAHA_CORE_SCHEDULER_H__ | |
20 #define OMAHA_CORE_SCHEDULER_H__ | |
21 | |
22 #include <windows.h> | |
23 #include <atlstr.h> | |
24 #include "base/basictypes.h" | |
25 #include "base/scoped_ptr.h" | |
26 | |
27 namespace omaha { | |
28 | |
29 class Core; | |
30 class HighresTimer; | |
31 class QueueTimer; | |
32 | |
33 class Scheduler { | |
34 public: | |
35 explicit Scheduler(const Core& core); | |
36 ~Scheduler(); | |
37 | |
38 // Starts the scheduler. | |
39 HRESULT Initialize(); | |
40 | |
41 private: | |
42 static void TimerCallback(QueueTimer* timer); | |
43 void HandleCallback(QueueTimer* timer); | |
44 HRESULT ScheduleUpdateTimer(int interval_ms); | |
45 HRESULT ScheduleCodeRedTimer(int interval_ms); | |
46 | |
47 const Core& core_; | |
48 HANDLE timer_queue_; | |
49 scoped_ptr<QueueTimer> update_timer_; | |
50 scoped_ptr<QueueTimer> code_red_timer_; | |
51 | |
52 // Measures the actual time interval between code red events for debugging | |
53 // purposes. The timer is started when a code red alarm is set and then, | |
54 // the value of the timer is read when the alarm goes off. | |
55 scoped_ptr<HighresTimer> cr_debug_timer_; | |
56 | |
57 DISALLOW_EVIL_CONSTRUCTORS(Scheduler); | |
58 }; | |
59 | |
60 } // namespace omaha | |
61 | |
62 #endif // OMAHA_CORE_SCHEDULER_H__ | |
63 | |
OLD | NEW |