| 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 #include "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <mmsystem.h> | 8 #include <mmsystem.h> |
| 9 | 9 |
| 10 #include "base/event_recorder.h" | 10 #include "base/event_recorder.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 DCHECK(!is_recording_ && !is_playing_); | 42 DCHECK(!is_recording_ && !is_playing_); |
| 43 } | 43 } |
| 44 | 44 |
| 45 bool EventRecorder::StartRecording(const FilePath& filename) { | 45 bool EventRecorder::StartRecording(const FilePath& filename) { |
| 46 if (journal_hook_ != NULL) | 46 if (journal_hook_ != NULL) |
| 47 return false; | 47 return false; |
| 48 if (is_recording_ || is_playing_) | 48 if (is_recording_ || is_playing_) |
| 49 return false; | 49 return false; |
| 50 | 50 |
| 51 // Open the recording file. | 51 // Open the recording file. |
| 52 DCHECK(file_ == NULL); | 52 DCHECK(!file_); |
| 53 file_ = file_util::OpenFile(filename, "wb+"); | 53 file_ = file_util::OpenFile(filename, "wb+"); |
| 54 if (!file_) { | 54 if (!file_) { |
| 55 DLOG(ERROR) << "EventRecorder could not open log file"; | 55 DLOG(ERROR) << "EventRecorder could not open log file"; |
| 56 return false; | 56 return false; |
| 57 } | 57 } |
| 58 | 58 |
| 59 // Set the faster clock, if possible. | 59 // Set the faster clock, if possible. |
| 60 ::timeBeginPeriod(1); | 60 ::timeBeginPeriod(1); |
| 61 | 61 |
| 62 // Set the recording hook. JOURNALRECORD can only be used as a global hook. | 62 // Set the recording hook. JOURNALRECORD can only be used as a global hook. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 | 95 |
| 96 bool EventRecorder::StartPlayback(const FilePath& filename) { | 96 bool EventRecorder::StartPlayback(const FilePath& filename) { |
| 97 if (journal_hook_ != NULL) | 97 if (journal_hook_ != NULL) |
| 98 return false; | 98 return false; |
| 99 if (is_recording_ || is_playing_) | 99 if (is_recording_ || is_playing_) |
| 100 return false; | 100 return false; |
| 101 | 101 |
| 102 // Open the recording file. | 102 // Open the recording file. |
| 103 DCHECK(file_ == NULL); | 103 DCHECK(!file_); |
| 104 file_ = file_util::OpenFile(filename, "rb"); | 104 file_ = file_util::OpenFile(filename, "rb"); |
| 105 if (!file_) { | 105 if (!file_) { |
| 106 DLOG(ERROR) << "EventRecorder Playback could not open log file"; | 106 DLOG(ERROR) << "EventRecorder Playback could not open log file"; |
| 107 return false; | 107 return false; |
| 108 } | 108 } |
| 109 // Read the first event from the record. | 109 // Read the first event from the record. |
| 110 if (fread(&playback_msg_, sizeof(EVENTMSG), 1, file_) != 1) { | 110 if (fread(&playback_msg_, sizeof(EVENTMSG), 1, file_) != 1) { |
| 111 DLOG(ERROR) << "EventRecorder Playback has no records!"; | 111 DLOG(ERROR) << "EventRecorder Playback has no records!"; |
| 112 file_util::CloseFile(file_); | 112 file_util::CloseFile(file_); |
| 113 return false; | 113 return false; |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 // indicating that the message is not removed from the message queue after | 250 // indicating that the message is not removed from the message queue after |
| 251 // PeekMessage processing. | 251 // PeekMessage processing. |
| 252 case HC_NOREMOVE: | 252 case HC_NOREMOVE: |
| 253 break; | 253 break; |
| 254 } | 254 } |
| 255 | 255 |
| 256 return CallNextHookEx(journal_hook_, nCode, wParam, lParam); | 256 return CallNextHookEx(journal_hook_, nCode, wParam, lParam); |
| 257 } | 257 } |
| 258 | 258 |
| 259 } // namespace base | 259 } // namespace base |
| OLD | NEW |