OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "remoting/protocol/server_log_entry.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "base/sys_info.h" |
| 9 #include "remoting/base/constants.h" |
| 10 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" |
| 11 |
| 12 using base::SysInfo; |
| 13 using buzz::QName; |
| 14 using buzz::XmlElement; |
| 15 |
| 16 namespace remoting { |
| 17 namespace protocol { |
| 18 |
| 19 namespace { |
| 20 |
| 21 const char kLogCommand[] = "log"; |
| 22 const char kLogEntry[] = "entry"; |
| 23 |
| 24 const char kKeyEventName[] = "event-name"; |
| 25 |
| 26 const char kKeyRole[] = "role"; |
| 27 |
| 28 const char kKeyMode[] = "mode"; |
| 29 const char kValueModeIt2Me[] = "it2me"; |
| 30 const char kValueModeMe2Me[] = "me2me"; |
| 31 |
| 32 const char kKeyCpu[] = "cpu"; |
| 33 |
| 34 } // namespace |
| 35 |
| 36 ServerLogEntry::ServerLogEntry() { |
| 37 } |
| 38 |
| 39 ServerLogEntry::~ServerLogEntry() { |
| 40 } |
| 41 |
| 42 void ServerLogEntry::Set(const std::string& key, const std::string& value) { |
| 43 values_map_[key] = value; |
| 44 } |
| 45 |
| 46 void ServerLogEntry::AddCpuField() { |
| 47 Set(kKeyCpu, SysInfo::OperatingSystemArchitecture()); |
| 48 } |
| 49 |
| 50 void ServerLogEntry::AddModeField(ServerLogEntry::Mode mode) { |
| 51 const char* mode_value = NULL; |
| 52 switch (mode) { |
| 53 case IT2ME: |
| 54 mode_value = kValueModeIt2Me; |
| 55 break; |
| 56 case ME2ME: |
| 57 mode_value = kValueModeMe2Me; |
| 58 break; |
| 59 default: |
| 60 NOTREACHED(); |
| 61 } |
| 62 Set(kKeyMode, mode_value); |
| 63 } |
| 64 |
| 65 void ServerLogEntry::AddRoleField(const char* role) { |
| 66 Set(kKeyRole, role); |
| 67 } |
| 68 |
| 69 void ServerLogEntry::AddEventNameField(const char* name) { |
| 70 Set(kKeyEventName, name); |
| 71 } |
| 72 |
| 73 // static |
| 74 scoped_ptr<XmlElement> ServerLogEntry::MakeStanza() { |
| 75 return scoped_ptr<XmlElement>( |
| 76 new XmlElement(QName(kChromotingXmlNamespace, kLogCommand))); |
| 77 } |
| 78 |
| 79 scoped_ptr<XmlElement> ServerLogEntry::ToStanza() const { |
| 80 scoped_ptr<XmlElement> stanza(new XmlElement(QName( |
| 81 kChromotingXmlNamespace, kLogEntry))); |
| 82 ValuesMap::const_iterator iter; |
| 83 for (iter = values_map_.begin(); iter != values_map_.end(); ++iter) { |
| 84 stanza->AddAttr(QName(std::string(), iter->first), iter->second); |
| 85 } |
| 86 return stanza.Pass(); |
| 87 } |
| 88 |
| 89 } // namespace protocol |
| 90 } // namespace remoting |
OLD | NEW |