| 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/server_log_entry.h" | 5 #include "remoting/host/server_log_entry.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/stringize_macros.h" | 8 #include "base/strings/stringize_macros.h" |
| 9 #include "base/sys_info.h" | 9 #include "base/sys_info.h" |
| 10 #include "remoting/base/constants.h" | 10 #include "remoting/base/constants.h" |
| 11 #include "remoting/protocol/session.h" | 11 #include "remoting/protocol/session.h" |
| 12 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" | 12 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" |
| 13 | 13 |
| 14 using base::SysInfo; | 14 using base::SysInfo; |
| 15 using buzz::QName; | 15 using buzz::QName; |
| 16 using buzz::XmlElement; | 16 using buzz::XmlElement; |
| 17 using remoting::protocol::Session; | 17 using remoting::protocol::Session; |
| 18 | 18 |
| 19 namespace remoting { | 19 namespace remoting { |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 const char kLogCommand[] = "log"; | 22 const char kLogCommand[] = "log"; |
| 23 | 23 |
| 24 const char kLogEntry[] = "entry"; | 24 const char kLogEntry[] = "entry"; |
| 25 | 25 |
| 26 const char kKeyEventName[] = "event-name"; | 26 const char kKeyEventName[] = "event-name"; |
| 27 const char kValueEventNameSessionState[] = "session-state"; | 27 const char kValueEventNameSessionState[] = "session-state"; |
| 28 const char kValueEventNameHeartbeat[] = "heartbeat"; | 28 const char kValueEventNameHeartbeat[] = "heartbeat"; |
| 29 const char kValueEventNameHostStatus[] = "host-status"; |
| 29 | 30 |
| 30 const char kKeyRole[] = "role"; | 31 const char kKeyRole[] = "role"; |
| 31 const char kValueRoleHost[] = "host"; | 32 const char kValueRoleHost[] = "host"; |
| 32 | 33 |
| 33 const char kKeyMode[] = "mode"; | 34 const char kKeyMode[] = "mode"; |
| 34 const char kValueModeIt2Me[] = "it2me"; | 35 const char kValueModeIt2Me[] = "it2me"; |
| 35 const char kValueModeMe2Me[] = "me2me"; | 36 const char kValueModeMe2Me[] = "me2me"; |
| 36 | 37 |
| 37 const char kKeySessionState[] = "session-state"; | 38 const char kKeySessionState[] = "session-state"; |
| 38 const char kValueSessionStateConnected[] = "connected"; | 39 const char kValueSessionStateConnected[] = "connected"; |
| 39 const char kValueSessionStateClosed[] = "closed"; | 40 const char kValueSessionStateClosed[] = "closed"; |
| 40 | 41 |
| 42 const char kStatusName[] = "status"; |
| 43 const char kExitCodeName[] = "exit-code"; |
| 44 |
| 41 const char kKeyOsName[] = "os-name"; | 45 const char kKeyOsName[] = "os-name"; |
| 42 const char kValueOsNameWindows[] = "Windows"; | 46 const char kValueOsNameWindows[] = "Windows"; |
| 43 const char kValueOsNameLinux[] = "Linux"; | 47 const char kValueOsNameLinux[] = "Linux"; |
| 44 const char kValueOsNameMac[] = "Mac"; | 48 const char kValueOsNameMac[] = "Mac"; |
| 45 const char kValueOsNameChromeOS[] = "ChromeOS"; | 49 const char kValueOsNameChromeOS[] = "ChromeOS"; |
| 46 | 50 |
| 47 const char kKeyOsVersion[] = "os-version"; | 51 const char kKeyOsVersion[] = "os-version"; |
| 48 | 52 |
| 49 const char kKeyHostVersion[] = "host-version"; | 53 const char kKeyHostVersion[] = "host-version"; |
| 50 | 54 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 77 } | 81 } |
| 78 | 82 |
| 79 // static | 83 // static |
| 80 scoped_ptr<ServerLogEntry> ServerLogEntry::MakeForHeartbeat() { | 84 scoped_ptr<ServerLogEntry> ServerLogEntry::MakeForHeartbeat() { |
| 81 scoped_ptr<ServerLogEntry> entry(new ServerLogEntry()); | 85 scoped_ptr<ServerLogEntry> entry(new ServerLogEntry()); |
| 82 entry->Set(kKeyRole, kValueRoleHost); | 86 entry->Set(kKeyRole, kValueRoleHost); |
| 83 entry->Set(kKeyEventName, kValueEventNameHeartbeat); | 87 entry->Set(kKeyEventName, kValueEventNameHeartbeat); |
| 84 return entry.Pass(); | 88 return entry.Pass(); |
| 85 } | 89 } |
| 86 | 90 |
| 91 // static |
| 92 scoped_ptr<ServerLogEntry> ServerLogEntry::MakeForHostStatus( |
| 93 HostStatusSender::HostStatus host_status, HostExitCodes exit_code) { |
| 94 scoped_ptr<ServerLogEntry> entry(new ServerLogEntry()); |
| 95 entry->Set(kKeyRole, kValueRoleHost); |
| 96 entry->Set(kKeyEventName, kValueEventNameHostStatus); |
| 97 entry->Set(kStatusName, HostStatusSender::HostStatusToString(host_status)); |
| 98 if (host_status == HostStatusSender::OFFLINE) |
| 99 entry->Set(kExitCodeName, ExitCodeToString(exit_code)); |
| 100 return entry.Pass(); |
| 101 } |
| 102 |
| 87 void ServerLogEntry::AddHostFields() { | 103 void ServerLogEntry::AddHostFields() { |
| 88 #if defined(OS_WIN) | 104 #if defined(OS_WIN) |
| 89 Set(kKeyOsName, kValueOsNameWindows); | 105 Set(kKeyOsName, kValueOsNameWindows); |
| 90 #elif defined(OS_MACOSX) | 106 #elif defined(OS_MACOSX) |
| 91 Set(kKeyOsName, kValueOsNameMac); | 107 Set(kKeyOsName, kValueOsNameMac); |
| 92 #elif defined(OS_CHROMEOS) | 108 #elif defined(OS_CHROMEOS) |
| 93 Set(kKeyOsName, kValueOsNameChromeOS); | 109 Set(kKeyOsName, kValueOsNameChromeOS); |
| 94 #elif defined(OS_LINUX) | 110 #elif defined(OS_LINUX) |
| 95 Set(kKeyOsName, kValueOsNameLinux); | 111 Set(kKeyOsName, kValueOsNameLinux); |
| 96 #endif | 112 #endif |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 // static | 164 // static |
| 149 const char* ServerLogEntry::GetValueSessionState(bool connected) { | 165 const char* ServerLogEntry::GetValueSessionState(bool connected) { |
| 150 return connected ? kValueSessionStateConnected : kValueSessionStateClosed; | 166 return connected ? kValueSessionStateConnected : kValueSessionStateClosed; |
| 151 } | 167 } |
| 152 | 168 |
| 153 void ServerLogEntry::Set(const std::string& key, const std::string& value) { | 169 void ServerLogEntry::Set(const std::string& key, const std::string& value) { |
| 154 values_map_[key] = value; | 170 values_map_[key] = value; |
| 155 } | 171 } |
| 156 | 172 |
| 157 } // namespace remoting | 173 } // namespace remoting |
| OLD | NEW |