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.
5 #include "remoting/signaling/server_log_entry.h"
7 #include "base/logging.h"
8 #include "base/sys_info.h"
9 #include "remoting/base/constants.h"
10 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h"
14 using buzz::XmlElement
;
20 const char kLogCommand
[] = "log";
21 const char kLogEntry
[] = "entry";
23 const char kKeyEventName
[] = "event-name";
25 const char kKeyRole
[] = "role";
27 const char kKeyMode
[] = "mode";
28 const char kValueModeIt2Me
[] = "it2me";
29 const char kValueModeMe2Me
[] = "me2me";
31 const char kKeyCpu
[] = "cpu";
35 ServerLogEntry::ServerLogEntry() {
38 ServerLogEntry::~ServerLogEntry() {
41 void ServerLogEntry::Set(const std::string
& key
, const std::string
& value
) {
42 values_map_
[key
] = value
;
45 void ServerLogEntry::AddCpuField() {
46 Set(kKeyCpu
, SysInfo::OperatingSystemArchitecture());
49 void ServerLogEntry::AddModeField(ServerLogEntry::Mode mode
) {
50 const char* mode_value
= nullptr;
53 mode_value
= kValueModeIt2Me
;
56 mode_value
= kValueModeMe2Me
;
61 Set(kKeyMode
, mode_value
);
64 void ServerLogEntry::AddRoleField(const char* role
) {
68 void ServerLogEntry::AddEventNameField(const char* name
) {
69 Set(kKeyEventName
, name
);
73 scoped_ptr
<XmlElement
> ServerLogEntry::MakeStanza() {
74 return make_scoped_ptr(
75 new XmlElement(QName(kChromotingXmlNamespace
, kLogCommand
)));
78 scoped_ptr
<XmlElement
> ServerLogEntry::ToStanza() const {
79 scoped_ptr
<XmlElement
> stanza(new XmlElement(QName(
80 kChromotingXmlNamespace
, kLogEntry
)));
81 ValuesMap::const_iterator iter
;
82 for (iter
= values_map_
.begin(); iter
!= values_map_
.end(); ++iter
) {
83 stanza
->AddAttr(QName(std::string(), iter
->first
), iter
->second
);
88 } // namespace remoting