OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #ifndef BASE_EVENT_RECORDER_H_ | 5 #ifndef BASE_EVENT_RECORDER_H_ |
6 #define BASE_EVENT_RECORDER_H_ | 6 #define BASE_EVENT_RECORDER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <windows.h> | 9 #include <windows.h> |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 // We can only handle one recorder/player at a time. | 30 // We can only handle one recorder/player at a time. |
31 static EventRecorder* current() { | 31 static EventRecorder* current() { |
32 if (!current_) | 32 if (!current_) |
33 current_ = new EventRecorder(); | 33 current_ = new EventRecorder(); |
34 return current_; | 34 return current_; |
35 } | 35 } |
36 | 36 |
37 // Starts recording events. | 37 // Starts recording events. |
38 // Will clobber the file if it already exists. | 38 // Will clobber the file if it already exists. |
39 // Returns true on success, or false if an error occurred. | 39 // Returns true on success, or false if an error occurred. |
40 bool StartRecording(std::wstring &filename); | 40 bool StartRecording(const std::wstring& filename); |
41 | 41 |
42 // Stops recording. | 42 // Stops recording. |
43 void StopRecording(); | 43 void StopRecording(); |
44 | 44 |
45 // Is the EventRecorder currently recording. | 45 // Is the EventRecorder currently recording. |
46 bool is_recording() const { return is_recording_; } | 46 bool is_recording() const { return is_recording_; } |
47 | 47 |
48 // Plays events previously recorded. | 48 // Plays events previously recorded. |
49 // Returns true on success, or false if an error occurred. | 49 // Returns true on success, or false if an error occurred. |
50 bool StartPlayback(std::wstring &filename); | 50 bool StartPlayback(const std::wstring& filename); |
51 | 51 |
52 // Stops playback. | 52 // Stops playback. |
53 void StopPlayback(); | 53 void StopPlayback(); |
54 | 54 |
55 // Is the EventRecorder currently playing. | 55 // Is the EventRecorder currently playing. |
56 bool is_playing() const { return is_playing_; } | 56 bool is_playing() const { return is_playing_; } |
57 | 57 |
58 // C-style callbacks for the EventRecorder. | 58 // C-style callbacks for the EventRecorder. |
59 // Used for internal purposes only. | 59 // Used for internal purposes only. |
60 LRESULT RecordWndProc(int nCode, WPARAM wParam, LPARAM lParam); | 60 LRESULT RecordWndProc(int nCode, WPARAM wParam, LPARAM lParam); |
61 LRESULT PlaybackWndProc(int nCode, WPARAM wParam, LPARAM lParam); | 61 LRESULT PlaybackWndProc(int nCode, WPARAM wParam, LPARAM lParam); |
62 | 62 |
63 private: | 63 private: |
64 // Create a new EventRecorder. Events are saved to the file filename. | 64 // Create a new EventRecorder. Events are saved to the file filename. |
65 // If the file already exists, it will be deleted before recording | 65 // If the file already exists, it will be deleted before recording |
66 // starts. | 66 // starts. |
67 explicit EventRecorder() | 67 explicit EventRecorder() |
68 : is_recording_(false), | 68 : is_recording_(false), |
69 is_playing_(false), | 69 is_playing_(false), |
70 journal_hook_(NULL), | 70 journal_hook_(NULL), |
71 file_(NULL) { | 71 file_(NULL), |
| 72 playback_first_msg_time_(0), |
| 73 playback_start_time_(0) { |
72 } | 74 } |
73 ~EventRecorder(); | 75 ~EventRecorder(); |
74 | 76 |
75 static EventRecorder* current_; // Our singleton. | 77 static EventRecorder* current_; // Our singleton. |
76 | 78 |
77 bool is_recording_; | 79 bool is_recording_; |
78 bool is_playing_; | 80 bool is_playing_; |
79 HHOOK journal_hook_; | 81 HHOOK journal_hook_; |
80 FILE* file_; | 82 FILE* file_; |
81 EVENTMSG playback_msg_; | 83 EVENTMSG playback_msg_; |
82 int playback_first_msg_time_; | 84 int playback_first_msg_time_; |
83 int playback_start_time_; | 85 int playback_start_time_; |
84 | 86 |
85 DISALLOW_EVIL_CONSTRUCTORS(EventRecorder); | 87 DISALLOW_EVIL_CONSTRUCTORS(EventRecorder); |
86 }; | 88 }; |
87 | 89 |
88 } // namespace base | 90 } // namespace base |
89 | 91 |
90 #endif // BASE_EVENT_RECORDER_H_ | 92 #endif // BASE_EVENT_RECORDER_H_ |
91 | |
OLD | NEW |