| 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 #ifndef BASE_EVENT_RECORDER_H_ | 5 #ifndef BASE_EVENT_RECORDER_H_ |
| 6 #define BASE_EVENT_RECORDER_H_ | 6 #define BASE_EVENT_RECORDER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include <windows.h> | 10 #include <windows.h> |
| 11 #include <stdio.h> | 11 #include <stdio.h> |
| 12 #endif | 12 #endif |
| 13 |
| 14 #include "base/base_api.h" |
| 13 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
| 14 | 16 |
| 15 class FilePath; | 17 class FilePath; |
| 16 | 18 |
| 17 namespace base { | 19 namespace base { |
| 18 | 20 |
| 19 // A class for recording and playing back keyboard and mouse input events. | 21 // A class for recording and playing back keyboard and mouse input events. |
| 20 // | 22 // |
| 21 // Note - if you record events, and the playback with the windows in | 23 // Note - if you record events, and the playback with the windows in |
| 22 // different sizes or positions, the playback will fail. When | 24 // different sizes or positions, the playback will fail. When |
| 23 // recording and playing, you should move the relevant windows | 25 // recording and playing, you should move the relevant windows |
| 24 // to constant sizes and locations. | 26 // to constant sizes and locations. |
| 25 // TODO(mbelshe) For now this is a singleton. I believe that this class | 27 // TODO(mbelshe) For now this is a singleton. I believe that this class |
| 26 // could be easily modified to: | 28 // could be easily modified to: |
| 27 // support two simultaneous recorders | 29 // support two simultaneous recorders |
| 28 // be playing back events while already recording events. | 30 // be playing back events while already recording events. |
| 29 // Why? Imagine if the product had a "record a macro" feature. | 31 // Why? Imagine if the product had a "record a macro" feature. |
| 30 // You might be recording globally, while recording or playing back | 32 // You might be recording globally, while recording or playing back |
| 31 // a macro. I don't think two playbacks make sense. | 33 // a macro. I don't think two playbacks make sense. |
| 32 class EventRecorder { | 34 class BASE_API EventRecorder { |
| 33 public: | 35 public: |
| 34 // Get the singleton EventRecorder. | 36 // Get the singleton EventRecorder. |
| 35 // We can only handle one recorder/player at a time. | 37 // We can only handle one recorder/player at a time. |
| 36 static EventRecorder* current() { | 38 static EventRecorder* current() { |
| 37 if (!current_) | 39 if (!current_) |
| 38 current_ = new EventRecorder(); | 40 current_ = new EventRecorder(); |
| 39 return current_; | 41 return current_; |
| 40 } | 42 } |
| 41 | 43 |
| 42 // Starts recording events. | 44 // Starts recording events. |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 #endif | 99 #endif |
| 98 int playback_first_msg_time_; | 100 int playback_first_msg_time_; |
| 99 int playback_start_time_; | 101 int playback_start_time_; |
| 100 | 102 |
| 101 DISALLOW_COPY_AND_ASSIGN(EventRecorder); | 103 DISALLOW_COPY_AND_ASSIGN(EventRecorder); |
| 102 }; | 104 }; |
| 103 | 105 |
| 104 } // namespace base | 106 } // namespace base |
| 105 | 107 |
| 106 #endif // BASE_EVENT_RECORDER_H_ | 108 #endif // BASE_EVENT_RECORDER_H_ |
| OLD | NEW |