| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "remoting/host/host_event_logger.h" | 5 #include "remoting/host/host_event_logger.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 DISALLOW_COPY_AND_ASSIGN(HostEventLoggerWin); | 54 DISALLOW_COPY_AND_ASSIGN(HostEventLoggerWin); |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 } //namespace | 57 } //namespace |
| 58 | 58 |
| 59 HostEventLoggerWin::HostEventLoggerWin(base::WeakPtr<HostStatusMonitor> monitor, | 59 HostEventLoggerWin::HostEventLoggerWin(base::WeakPtr<HostStatusMonitor> monitor, |
| 60 const std::string& application_name) | 60 const std::string& application_name) |
| 61 : monitor_(monitor), | 61 : monitor_(monitor), |
| 62 event_log_(NULL) { | 62 event_log_(NULL) { |
| 63 event_log_ = RegisterEventSourceW(NULL, | 63 event_log_ = RegisterEventSourceW( |
| 64 UTF8ToUTF16(application_name).c_str()); | 64 NULL, base::UTF8ToUTF16(application_name).c_str()); |
| 65 if (event_log_ != NULL) { | 65 if (event_log_ != NULL) { |
| 66 monitor_->AddStatusObserver(this); | 66 monitor_->AddStatusObserver(this); |
| 67 } else { | 67 } else { |
| 68 LOG_GETLASTERROR(ERROR) << "Failed to register the event source: " | 68 LOG_GETLASTERROR(ERROR) << "Failed to register the event source: " |
| 69 << application_name; | 69 << application_name; |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 HostEventLoggerWin::~HostEventLoggerWin() { | 73 HostEventLoggerWin::~HostEventLoggerWin() { |
| 74 if (event_log_ != NULL) { | 74 if (event_log_ != NULL) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 DWORD event_id, | 115 DWORD event_id, |
| 116 const std::vector<std::string>& strings) { | 116 const std::vector<std::string>& strings) { |
| 117 if (event_log_ == NULL) | 117 if (event_log_ == NULL) |
| 118 return; | 118 return; |
| 119 | 119 |
| 120 // ReportEventW() takes an array of raw string pointers. They should stay | 120 // ReportEventW() takes an array of raw string pointers. They should stay |
| 121 // valid for the duration of the call. | 121 // valid for the duration of the call. |
| 122 std::vector<const WCHAR*> raw_strings(strings.size()); | 122 std::vector<const WCHAR*> raw_strings(strings.size()); |
| 123 std::vector<base::string16> utf16_strings(strings.size()); | 123 std::vector<base::string16> utf16_strings(strings.size()); |
| 124 for (size_t i = 0; i < strings.size(); ++i) { | 124 for (size_t i = 0; i < strings.size(); ++i) { |
| 125 utf16_strings[i] = UTF8ToUTF16(strings[i]); | 125 utf16_strings[i] = base::UTF8ToUTF16(strings[i]); |
| 126 raw_strings[i] = utf16_strings[i].c_str(); | 126 raw_strings[i] = utf16_strings[i].c_str(); |
| 127 } | 127 } |
| 128 | 128 |
| 129 if (!ReportEventW(event_log_, | 129 if (!ReportEventW(event_log_, |
| 130 type, | 130 type, |
| 131 HOST_CATEGORY, | 131 HOST_CATEGORY, |
| 132 event_id, | 132 event_id, |
| 133 NULL, | 133 NULL, |
| 134 static_cast<WORD>(raw_strings.size()), | 134 static_cast<WORD>(raw_strings.size()), |
| 135 0, | 135 0, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 149 | 149 |
| 150 // static | 150 // static |
| 151 scoped_ptr<HostEventLogger> HostEventLogger::Create( | 151 scoped_ptr<HostEventLogger> HostEventLogger::Create( |
| 152 base::WeakPtr<HostStatusMonitor> monitor, | 152 base::WeakPtr<HostStatusMonitor> monitor, |
| 153 const std::string& application_name) { | 153 const std::string& application_name) { |
| 154 return scoped_ptr<HostEventLogger>( | 154 return scoped_ptr<HostEventLogger>( |
| 155 new HostEventLoggerWin(monitor, application_name)); | 155 new HostEventLoggerWin(monitor, application_name)); |
| 156 } | 156 } |
| 157 | 157 |
| 158 } // namespace remoting | 158 } // namespace remoting |
| OLD | NEW |