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/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 Loading... |
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 scoped_ptr<buzz::XmlElement> ServerLogEntry::MakeLogStanza() { |
| 60 return scoped_ptr<buzz::XmlElement>( |
| 61 new XmlElement(QName(kChromotingXmlNamespace, kLogCommand))); |
| 62 } |
| 63 |
56 ServerLogEntry* ServerLogEntry::MakeSessionStateChange(bool connected) { | 64 ServerLogEntry* ServerLogEntry::MakeSessionStateChange(bool connected) { |
57 ServerLogEntry* entry = new ServerLogEntry(); | 65 ServerLogEntry* entry = new ServerLogEntry(); |
58 entry->Set(kKeyRole, kValueRoleHost); | 66 entry->Set(kKeyRole, kValueRoleHost); |
59 entry->Set(kKeyEventName, kValueEventNameSessionState); | 67 entry->Set(kKeyEventName, kValueEventNameSessionState); |
60 entry->Set(kKeySessionState, GetValueSessionState(connected)); | 68 entry->Set(kKeySessionState, GetValueSessionState(connected)); |
61 return entry; | 69 return entry; |
62 } | 70 } |
63 | 71 |
| 72 ServerLogEntry* ServerLogEntry::MakeHeartbeat() { |
| 73 ServerLogEntry* entry = new ServerLogEntry(); |
| 74 entry->Set(kKeyRole, kValueRoleHost); |
| 75 entry->Set(kKeyEventName, kValueEventNameHeartbeat); |
| 76 return entry; |
| 77 } |
| 78 |
64 void ServerLogEntry::AddHostFields() { | 79 void ServerLogEntry::AddHostFields() { |
65 #if defined(OS_WIN) | 80 #if defined(OS_WIN) |
66 Set(kKeyOsName, kValueOsNameWindows); | 81 Set(kKeyOsName, kValueOsNameWindows); |
67 #elif defined(OS_MACOSX) | 82 #elif defined(OS_MACOSX) |
68 Set(kKeyOsName, kValueOsNameMac); | 83 Set(kKeyOsName, kValueOsNameMac); |
69 #elif defined(OS_CHROMEOS) | 84 #elif defined(OS_CHROMEOS) |
70 Set(kKeyOsName, kValueOsNameChromeOS); | 85 Set(kKeyOsName, kValueOsNameChromeOS); |
71 #elif defined(OS_LINUX) | 86 #elif defined(OS_LINUX) |
72 Set(kKeyOsName, kValueOsNameLinux); | 87 Set(kKeyOsName, kValueOsNameLinux); |
73 #endif | 88 #endif |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 | 137 |
123 const char* ServerLogEntry::GetValueSessionState(bool connected) { | 138 const char* ServerLogEntry::GetValueSessionState(bool connected) { |
124 return connected ? kValueSessionStateConnected : kValueSessionStateClosed; | 139 return connected ? kValueSessionStateConnected : kValueSessionStateClosed; |
125 } | 140 } |
126 | 141 |
127 void ServerLogEntry::Set(const std::string& key, const std::string& value) { | 142 void ServerLogEntry::Set(const std::string& key, const std::string& value) { |
128 values_map_[key] = value; | 143 values_map_[key] = value; |
129 } | 144 } |
130 | 145 |
131 } // namespace remoting | 146 } // namespace remoting |
OLD | NEW |