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

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

Issue 9727005: Log connection type to syslogs and to the server. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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"
(...skipping 24 matching lines...) Expand all
35 35
36 const char kKeyOsName[] = "os-name"; 36 const char kKeyOsName[] = "os-name";
37 const char kValueOsNameWindows[] = "Windows"; 37 const char kValueOsNameWindows[] = "Windows";
38 const char kValueOsNameLinux[] = "Linux"; 38 const char kValueOsNameLinux[] = "Linux";
39 const char kValueOsNameMac[] = "Mac"; 39 const char kValueOsNameMac[] = "Mac";
40 const char kValueOsNameChromeOS[] = "ChromeOS"; 40 const char kValueOsNameChromeOS[] = "ChromeOS";
41 41
42 const char kKeyOsVersion[] = "os-version"; 42 const char kKeyOsVersion[] = "os-version";
43 43
44 const char kKeyCpu[] = "cpu"; 44 const char kKeyCpu[] = "cpu";
45
46 const char kKeyConnectionType[] = "connection-type";
47
45 } // namespace 48 } // namespace
46 49
47 ServerLogEntry::ServerLogEntry() { 50 ServerLogEntry::ServerLogEntry() {
48 } 51 }
49 52
50 ServerLogEntry::~ServerLogEntry() { 53 ServerLogEntry::~ServerLogEntry() {
51 } 54 }
52 55
53 ServerLogEntry* ServerLogEntry::MakeSessionStateChange(bool connected) { 56 ServerLogEntry* ServerLogEntry::MakeSessionStateChange(bool connected) {
54 ServerLogEntry* entry = new ServerLogEntry(); 57 ServerLogEntry* entry = new ServerLogEntry();
(...skipping 18 matching lines...) Expand all
73 // OSes: see base/sys_info_unittest.cc. 76 // OSes: see base/sys_info_unittest.cc.
74 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS) 77 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS)
75 std::stringstream os_version; 78 std::stringstream os_version;
76 int32 os_major_version = 0; 79 int32 os_major_version = 0;
77 int32 os_minor_version = 0; 80 int32 os_minor_version = 0;
78 int32 os_bugfix_version = 0; 81 int32 os_bugfix_version = 0;
79 SysInfo::OperatingSystemVersionNumbers(&os_major_version, &os_minor_version, 82 SysInfo::OperatingSystemVersionNumbers(&os_major_version, &os_minor_version,
80 &os_bugfix_version); 83 &os_bugfix_version);
81 os_version << os_major_version << "." << os_minor_version << "." 84 os_version << os_major_version << "." << os_minor_version << "."
82 << os_bugfix_version; 85 << os_bugfix_version;
83 Set(kKeyOsVersion, os_version.str().c_str()); 86 Set(kKeyOsVersion, os_version.str());
84 #endif 87 #endif
85 88
86 Set(kKeyCpu, SysInfo::CPUArchitecture().c_str()); 89 Set(kKeyCpu, SysInfo::CPUArchitecture());
87 }; 90 };
88 91
89 void ServerLogEntry::AddModeField(ServerLogEntry::Mode mode) { 92 void ServerLogEntry::AddModeField(ServerLogEntry::Mode mode) {
90 Set(kKeyMode, GetValueMode(mode)); 93 Set(kKeyMode, GetValueMode(mode));
91 } 94 }
92 95
96 void ServerLogEntry::AddConnectionTypeField(const std::string& type) {
97 Set(kKeyConnectionType, type);
98 }
99
93 const char* ServerLogEntry::GetValueMode(ServerLogEntry::Mode mode) { 100 const char* ServerLogEntry::GetValueMode(ServerLogEntry::Mode mode) {
94 switch(mode) { 101 switch(mode) {
95 case IT2ME: 102 case IT2ME:
96 return kValueModeIt2Me; 103 return kValueModeIt2Me;
97 case ME2ME: 104 case ME2ME:
98 return kValueModeMe2Me; 105 return kValueModeMe2Me;
99 default: 106 default:
100 NOTREACHED(); 107 NOTREACHED();
101 return NULL; 108 return NULL;
102 } 109 }
103 } 110 }
104 111
105 XmlElement* ServerLogEntry::ToStanza() const { 112 XmlElement* ServerLogEntry::ToStanza() const {
106 XmlElement* stanza = new XmlElement(QName( 113 XmlElement* stanza = new XmlElement(QName(
107 kChromotingXmlNamespace, kLogEntry)); 114 kChromotingXmlNamespace, kLogEntry));
108 ValuesMap::const_iterator iter; 115 ValuesMap::const_iterator iter;
109 for (iter = values_map_.begin(); iter != values_map_.end(); ++iter) { 116 for (iter = values_map_.begin(); iter != values_map_.end(); ++iter) {
110 stanza->AddAttr(QName("", iter->first), iter->second); 117 stanza->AddAttr(QName("", iter->first), iter->second);
111 } 118 }
112 return stanza; 119 return stanza;
113 } 120 }
114 121
115 const char* ServerLogEntry::GetValueSessionState(bool connected) { 122 const char* ServerLogEntry::GetValueSessionState(bool connected) {
116 return connected ? kValueSessionStateConnected : kValueSessionStateClosed; 123 return connected ? kValueSessionStateConnected : kValueSessionStateClosed;
117 } 124 }
118 125
119 void ServerLogEntry::Set(const char* key, const char* value) { 126 void ServerLogEntry::Set(const std::string& key, const std::string& value) {
120 values_map_[key] = value; 127 values_map_[key] = value;
121 } 128 }
122 129
123 } // namespace remoting 130 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698