OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <stddef.h> | 5 #include <stddef.h> |
6 #include <windows.h> | 6 #include <windows.h> |
7 #include <mmsystem.h> | 7 #include <mmsystem.h> |
8 | 8 |
9 #include "base/event_recorder.h" | 9 #include "base/event_recorder.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 | 12 |
13 // A note about time. | 13 // A note about time. |
14 // For perfect playback of events, you'd like a very accurate timer | 14 // For perfect playback of events, you'd like a very accurate timer |
15 // so that events are played back at exactly the same time that | 15 // so that events are played back at exactly the same time that |
16 // they were recorded. However, windows has a clock which is only | 16 // they were recorded. However, windows has a clock which is only |
17 // granular to ~15ms. We see more consistent event playback when | 17 // granular to ~15ms. We see more consistent event playback when |
18 // using a higher resolution timer. To do this, we use the | 18 // using a higher resolution timer. To do this, we use the |
19 // timeGetTime API instead of the default GetTickCount() API. | 19 // timeGetTime API instead of the default GetTickCount() API. |
20 | 20 |
21 namespace base { | 21 namespace base { |
22 | 22 |
23 EventRecorder* EventRecorder::current_ = NULL; | 23 EventRecorder* EventRecorder::current_ = NULL; |
24 | 24 |
25 LRESULT CALLBACK StaticRecordWndProc(int nCode, WPARAM wParam, | 25 LRESULT CALLBACK StaticRecordWndProc(int nCode, WPARAM wParam, |
26 LPARAM lParam) { | 26 LPARAM lParam) { |
27 CHECK(EventRecorder::current()); | 27 DCHECK(EventRecorder::current()); |
28 return EventRecorder::current()->RecordWndProc(nCode, wParam, lParam); | 28 return EventRecorder::current()->RecordWndProc(nCode, wParam, lParam); |
29 } | 29 } |
30 | 30 |
31 LRESULT CALLBACK StaticPlaybackWndProc(int nCode, WPARAM wParam, | 31 LRESULT CALLBACK StaticPlaybackWndProc(int nCode, WPARAM wParam, |
32 LPARAM lParam) { | 32 LPARAM lParam) { |
33 CHECK(EventRecorder::current()); | 33 DCHECK(EventRecorder::current()); |
34 return EventRecorder::current()->PlaybackWndProc(nCode, wParam, lParam); | 34 return EventRecorder::current()->PlaybackWndProc(nCode, wParam, lParam); |
35 } | 35 } |
36 | 36 |
37 EventRecorder::~EventRecorder() { | 37 EventRecorder::~EventRecorder() { |
38 // Try to assert early if the caller deletes the recorder | 38 // Try to assert early if the caller deletes the recorder |
39 // while it is still in use. | 39 // while it is still in use. |
40 DCHECK(!journal_hook_); | 40 DCHECK(!journal_hook_); |
41 DCHECK(!is_recording_ && !is_playing_); | 41 DCHECK(!is_recording_ && !is_playing_); |
42 } | 42 } |
43 | 43 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 // indicating that the message is not removed from the message queue after | 249 // indicating that the message is not removed from the message queue after |
250 // PeekMessage processing. | 250 // PeekMessage processing. |
251 case HC_NOREMOVE: | 251 case HC_NOREMOVE: |
252 break; | 252 break; |
253 } | 253 } |
254 | 254 |
255 return CallNextHookEx(journal_hook_, nCode, wParam, lParam); | 255 return CallNextHookEx(journal_hook_, nCode, wParam, lParam); |
256 } | 256 } |
257 | 257 |
258 } // namespace base | 258 } // namespace base |
OLD | NEW |