Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Side by Side Diff: remoting/host/server_log_entry.cc

Issue 10409017: [Chromoting] Add platform data to heartbeats. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Improve comments and formatting. Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/sys_info.h" 7 #include "base/sys_info.h"
8 #include "remoting/base/constants.h" 8 #include "remoting/base/constants.h"
9 #include "remoting/protocol/session.h" 9 #include "remoting/protocol/session.h"
10 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" 10 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h"
11 11
12 using base::SysInfo; 12 using base::SysInfo;
13 using buzz::QName; 13 using buzz::QName;
14 using buzz::XmlElement; 14 using buzz::XmlElement;
15 using remoting::protocol::Session; 15 using remoting::protocol::Session;
16 16
17 namespace remoting { 17 namespace remoting {
18 18
19 namespace { 19 namespace {
20 const char kLogCommand[] = "log";
21
20 const char kLogEntry[] = "entry"; 22 const char kLogEntry[] = "entry";
21 23
22 const char kKeyEventName[] = "event-name"; 24 const char kKeyEventName[] = "event-name";
23 const char kValueEventNameSessionState[] = "session-state"; 25 const char kValueEventNameSessionState[] = "session-state";
26 const char kValueEventNameHeartbeat[] = "heartbeat";
24 27
25 const char kKeyRole[] = "role"; 28 const char kKeyRole[] = "role";
26 const char kValueRoleHost[] = "host"; 29 const char kValueRoleHost[] = "host";
27 30
28 const char kKeyMode[] = "mode"; 31 const char kKeyMode[] = "mode";
29 const char kValueModeIt2Me[] = "it2me"; 32 const char kValueModeIt2Me[] = "it2me";
30 const char kValueModeMe2Me[] = "me2me"; 33 const char kValueModeMe2Me[] = "me2me";
31 34
32 const char kKeySessionState[] = "session-state"; 35 const char kKeySessionState[] = "session-state";
33 const char kValueSessionStateConnected[] = "connected"; 36 const char kValueSessionStateConnected[] = "connected";
(...skipping 12 matching lines...) Expand all
46 const char kKeyConnectionType[] = "connection-type"; 49 const char kKeyConnectionType[] = "connection-type";
47 50
48 } // namespace 51 } // namespace
49 52
50 ServerLogEntry::ServerLogEntry() { 53 ServerLogEntry::ServerLogEntry() {
51 } 54 }
52 55
53 ServerLogEntry::~ServerLogEntry() { 56 ServerLogEntry::~ServerLogEntry() {
54 } 57 }
55 58
59 // static
60 scoped_ptr<buzz::XmlElement> ServerLogEntry::MakeStanza() {
61 return scoped_ptr<buzz::XmlElement>(
62 new XmlElement(QName(kChromotingXmlNamespace, kLogCommand)));
63 }
64
65 // static
56 ServerLogEntry* ServerLogEntry::MakeSessionStateChange(bool connected) { 66 ServerLogEntry* ServerLogEntry::MakeSessionStateChange(bool connected) {
57 ServerLogEntry* entry = new ServerLogEntry(); 67 ServerLogEntry* entry = new ServerLogEntry();
58 entry->Set(kKeyRole, kValueRoleHost); 68 entry->Set(kKeyRole, kValueRoleHost);
59 entry->Set(kKeyEventName, kValueEventNameSessionState); 69 entry->Set(kKeyEventName, kValueEventNameSessionState);
60 entry->Set(kKeySessionState, GetValueSessionState(connected)); 70 entry->Set(kKeySessionState, GetValueSessionState(connected));
61 return entry; 71 return entry;
62 } 72 }
63 73
74 // static
75 ServerLogEntry* ServerLogEntry::MakeForHeartbeat() {
76 ServerLogEntry* entry = new ServerLogEntry();
77 entry->Set(kKeyRole, kValueRoleHost);
78 entry->Set(kKeyEventName, kValueEventNameHeartbeat);
79 return entry;
80 }
81
64 void ServerLogEntry::AddHostFields() { 82 void ServerLogEntry::AddHostFields() {
65 #if defined(OS_WIN) 83 #if defined(OS_WIN)
66 Set(kKeyOsName, kValueOsNameWindows); 84 Set(kKeyOsName, kValueOsNameWindows);
67 #elif defined(OS_MACOSX) 85 #elif defined(OS_MACOSX)
68 Set(kKeyOsName, kValueOsNameMac); 86 Set(kKeyOsName, kValueOsNameMac);
69 #elif defined(OS_CHROMEOS) 87 #elif defined(OS_CHROMEOS)
70 Set(kKeyOsName, kValueOsNameChromeOS); 88 Set(kKeyOsName, kValueOsNameChromeOS);
71 #elif defined(OS_LINUX) 89 #elif defined(OS_LINUX)
72 Set(kKeyOsName, kValueOsNameLinux); 90 Set(kKeyOsName, kValueOsNameLinux);
73 #endif 91 #endif
(...skipping 17 matching lines...) Expand all
91 109
92 void ServerLogEntry::AddModeField(ServerLogEntry::Mode mode) { 110 void ServerLogEntry::AddModeField(ServerLogEntry::Mode mode) {
93 Set(kKeyMode, GetValueMode(mode)); 111 Set(kKeyMode, GetValueMode(mode));
94 } 112 }
95 113
96 void ServerLogEntry::AddConnectionTypeField( 114 void ServerLogEntry::AddConnectionTypeField(
97 protocol::TransportRoute::RouteType type) { 115 protocol::TransportRoute::RouteType type) {
98 Set(kKeyConnectionType, protocol::TransportRoute::GetTypeString(type)); 116 Set(kKeyConnectionType, protocol::TransportRoute::GetTypeString(type));
99 } 117 }
100 118
119 // static
101 const char* ServerLogEntry::GetValueMode(ServerLogEntry::Mode mode) { 120 const char* ServerLogEntry::GetValueMode(ServerLogEntry::Mode mode) {
102 switch(mode) { 121 switch(mode) {
103 case IT2ME: 122 case IT2ME:
104 return kValueModeIt2Me; 123 return kValueModeIt2Me;
105 case ME2ME: 124 case ME2ME:
106 return kValueModeMe2Me; 125 return kValueModeMe2Me;
107 default: 126 default:
108 NOTREACHED(); 127 NOTREACHED();
109 return NULL; 128 return NULL;
110 } 129 }
111 } 130 }
112 131
113 scoped_ptr<XmlElement> ServerLogEntry::ToStanza() const { 132 scoped_ptr<XmlElement> ServerLogEntry::ToStanza() const {
114 scoped_ptr<XmlElement> stanza(new XmlElement(QName( 133 scoped_ptr<XmlElement> stanza(new XmlElement(QName(
115 kChromotingXmlNamespace, kLogEntry))); 134 kChromotingXmlNamespace, kLogEntry)));
116 ValuesMap::const_iterator iter; 135 ValuesMap::const_iterator iter;
117 for (iter = values_map_.begin(); iter != values_map_.end(); ++iter) { 136 for (iter = values_map_.begin(); iter != values_map_.end(); ++iter) {
118 stanza->AddAttr(QName("", iter->first), iter->second); 137 stanza->AddAttr(QName("", iter->first), iter->second);
119 } 138 }
120 return stanza.Pass(); 139 return stanza.Pass();
121 } 140 }
122 141
142 // static
123 const char* ServerLogEntry::GetValueSessionState(bool connected) { 143 const char* ServerLogEntry::GetValueSessionState(bool connected) {
124 return connected ? kValueSessionStateConnected : kValueSessionStateClosed; 144 return connected ? kValueSessionStateConnected : kValueSessionStateClosed;
125 } 145 }
126 146
127 void ServerLogEntry::Set(const std::string& key, const std::string& value) { 147 void ServerLogEntry::Set(const std::string& key, const std::string& value) {
128 values_map_[key] = value; 148 values_map_[key] = value;
129 } 149 }
130 150
131 } // namespace remoting 151 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698