Chromium Code Reviews| 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"; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 } | 78 } |
| 78 | 79 |
| 79 // static | 80 // static |
| 80 scoped_ptr<ServerLogEntry> ServerLogEntry::MakeForHeartbeat() { | 81 scoped_ptr<ServerLogEntry> ServerLogEntry::MakeForHeartbeat() { |
| 81 scoped_ptr<ServerLogEntry> entry(new ServerLogEntry()); | 82 scoped_ptr<ServerLogEntry> entry(new ServerLogEntry()); |
| 82 entry->Set(kKeyRole, kValueRoleHost); | 83 entry->Set(kKeyRole, kValueRoleHost); |
| 83 entry->Set(kKeyEventName, kValueEventNameHeartbeat); | 84 entry->Set(kKeyEventName, kValueEventNameHeartbeat); |
| 84 return entry.Pass(); | 85 return entry.Pass(); |
| 85 } | 86 } |
| 86 | 87 |
| 88 // static | |
| 89 scoped_ptr<ServerLogEntry> ServerLogEntry::MakeForHostStatus() { | |
| 90 scoped_ptr<ServerLogEntry> entry(new ServerLogEntry()); | |
| 91 entry->Set(kKeyRole, kValueRoleHost); | |
| 92 entry->Set(kKeyEventName, kValueEventNameHostStatus); | |
| 93 return entry.Pass(); | |
| 94 } | |
| 95 | |
| 87 void ServerLogEntry::AddHostFields() { | 96 void ServerLogEntry::AddHostFields() { |
| 88 #if defined(OS_WIN) | 97 #if defined(OS_WIN) |
| 89 Set(kKeyOsName, kValueOsNameWindows); | 98 Set(kKeyOsName, kValueOsNameWindows); |
| 90 #elif defined(OS_MACOSX) | 99 #elif defined(OS_MACOSX) |
| 91 Set(kKeyOsName, kValueOsNameMac); | 100 Set(kKeyOsName, kValueOsNameMac); |
| 92 #elif defined(OS_CHROMEOS) | 101 #elif defined(OS_CHROMEOS) |
| 93 Set(kKeyOsName, kValueOsNameChromeOS); | 102 Set(kKeyOsName, kValueOsNameChromeOS); |
| 94 #elif defined(OS_LINUX) | 103 #elif defined(OS_LINUX) |
| 95 Set(kKeyOsName, kValueOsNameLinux); | 104 Set(kKeyOsName, kValueOsNameLinux); |
| 96 #endif | 105 #endif |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 case IT2ME: | 137 case IT2ME: |
| 129 return kValueModeIt2Me; | 138 return kValueModeIt2Me; |
| 130 case ME2ME: | 139 case ME2ME: |
| 131 return kValueModeMe2Me; | 140 return kValueModeMe2Me; |
| 132 default: | 141 default: |
| 133 NOTREACHED(); | 142 NOTREACHED(); |
| 134 return NULL; | 143 return NULL; |
| 135 } | 144 } |
| 136 } | 145 } |
| 137 | 146 |
| 147 void ServerLogEntry::AddCustomField(const std::string& name, | |
|
rmsousa
2013/07/09 03:13:41
Could you pass the host_status and exit_code value
weitao
2013/07/09 19:02:17
I think the ServerLogEntry class should be general
| |
| 148 const std::string& value) { | |
| 149 Set(name, value); | |
| 150 } | |
| 151 | |
| 138 scoped_ptr<XmlElement> ServerLogEntry::ToStanza() const { | 152 scoped_ptr<XmlElement> ServerLogEntry::ToStanza() const { |
| 139 scoped_ptr<XmlElement> stanza(new XmlElement(QName( | 153 scoped_ptr<XmlElement> stanza(new XmlElement(QName( |
| 140 kChromotingXmlNamespace, kLogEntry))); | 154 kChromotingXmlNamespace, kLogEntry))); |
| 141 ValuesMap::const_iterator iter; | 155 ValuesMap::const_iterator iter; |
| 142 for (iter = values_map_.begin(); iter != values_map_.end(); ++iter) { | 156 for (iter = values_map_.begin(); iter != values_map_.end(); ++iter) { |
| 143 stanza->AddAttr(QName(std::string(), iter->first), iter->second); | 157 stanza->AddAttr(QName(std::string(), iter->first), iter->second); |
| 144 } | 158 } |
| 145 return stanza.Pass(); | 159 return stanza.Pass(); |
| 146 } | 160 } |
| 147 | 161 |
| 148 // static | 162 // static |
| 149 const char* ServerLogEntry::GetValueSessionState(bool connected) { | 163 const char* ServerLogEntry::GetValueSessionState(bool connected) { |
| 150 return connected ? kValueSessionStateConnected : kValueSessionStateClosed; | 164 return connected ? kValueSessionStateConnected : kValueSessionStateClosed; |
| 151 } | 165 } |
| 152 | 166 |
| 153 void ServerLogEntry::Set(const std::string& key, const std::string& value) { | 167 void ServerLogEntry::Set(const std::string& key, const std::string& value) { |
| 154 values_map_[key] = value; | 168 values_map_[key] = value; |
| 155 } | 169 } |
| 156 | 170 |
| 157 } // namespace remoting | 171 } // namespace remoting |
| OLD | NEW |