Fix UnlockEndpointIsDelayed again.
[chromium-blink-merge.git] / remoting / signaling / server_log_entry.cc
blobd91a32a970d3d9e8b0164f4dd809faefae9ce7c6
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"
12 using base::SysInfo;
13 using buzz::QName;
14 using buzz::XmlElement;
16 namespace remoting {
18 namespace {
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";
33 } // namespace
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;
51 switch (mode) {
52 case IT2ME:
53 mode_value = kValueModeIt2Me;
54 break;
55 case ME2ME:
56 mode_value = kValueModeMe2Me;
57 break;
58 default:
59 NOTREACHED();
61 Set(kKeyMode, mode_value);
64 void ServerLogEntry::AddRoleField(const char* role) {
65 Set(kKeyRole, role);
68 void ServerLogEntry::AddEventNameField(const char* name) {
69 Set(kKeyEventName, name);
72 // static
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);
85 return stanza.Pass();
88 } // namespace remoting