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

Unified Diff: remoting/host/server_log_entry_host.cc

Issue 282063005: Pull out common code from client and host versions of ServerLogEntry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move ServerLogEntry to jingle_glue Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/server_log_entry_host.h ('k') | remoting/host/server_log_entry_host_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/server_log_entry_host.cc
diff --git a/remoting/host/server_log_entry_host.cc b/remoting/host/server_log_entry_host.cc
new file mode 100644
index 0000000000000000000000000000000000000000..069dc2d3843505c1aeba0bf8ced9b2a9fb76c2b1
--- /dev/null
+++ b/remoting/host/server_log_entry_host.cc
@@ -0,0 +1,107 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/host/server_log_entry_host.h"
+
+#include "base/strings/stringize_macros.h"
+#include "base/sys_info.h"
+#include "remoting/jingle_glue/server_log_entry.h"
+
+using base::SysInfo;
+
+namespace remoting {
+
+namespace {
+const char kValueEventNameSessionState[] = "session-state";
+const char kValueEventNameHeartbeat[] = "heartbeat";
+const char kValueEventNameHostStatus[] = "host-status";
+
+const char kValueRoleHost[] = "host";
+
+const char kKeySessionState[] = "session-state";
+const char kValueSessionStateConnected[] = "connected";
+const char kValueSessionStateClosed[] = "closed";
+
+const char kStatusName[] = "status";
+const char kExitCodeName[] = "exit-code";
+
+const char kKeyOsName[] = "os-name";
+
+#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS)
+const char kKeyOsVersion[] = "os-version";
+#endif
+
+const char kKeyHostVersion[] = "host-version";
+
+const char kKeyConnectionType[] = "connection-type";
+
+const char* GetValueSessionState(bool connected) {
+ return connected ? kValueSessionStateConnected : kValueSessionStateClosed;
+}
+
+} // namespace
+
+scoped_ptr<ServerLogEntry> MakeLogEntryForSessionStateChange(
+ bool connected) {
+ scoped_ptr<ServerLogEntry> entry(new ServerLogEntry());
+ entry->AddRoleField(kValueRoleHost);
+ entry->AddEventNameField(kValueEventNameSessionState);
+ entry->Set(kKeySessionState, GetValueSessionState(connected));
+ return entry.Pass();
+}
+
+scoped_ptr<ServerLogEntry> MakeLogEntryForHeartbeat() {
+ scoped_ptr<ServerLogEntry> entry(new ServerLogEntry());
+ entry->AddRoleField(kValueRoleHost);
+ entry->AddEventNameField(kValueEventNameHeartbeat);
+ return entry.Pass();
+}
+
+// static
+scoped_ptr<ServerLogEntry> MakeLogEntryForHostStatus(
+ HostStatusSender::HostStatus host_status, HostExitCodes exit_code) {
+ scoped_ptr<ServerLogEntry> entry(new ServerLogEntry());
+ entry->AddRoleField(kValueRoleHost);
+ entry->AddEventNameField(kValueEventNameHostStatus);
+ entry->Set(kStatusName, HostStatusSender::HostStatusToString(host_status));
+ if (host_status == HostStatusSender::OFFLINE)
+ entry->Set(kExitCodeName, ExitCodeToString(exit_code));
+ return entry.Pass();
+}
+
+void AddHostFieldsToLogEntry(ServerLogEntry* entry) {
+#if defined(OS_WIN)
+ entry->Set(kKeyOsName, "Windows");
+#elif defined(OS_MACOSX)
+ entry->Set(kKeyOsName, "Mac");
+#elif defined(OS_CHROMEOS)
+ entry->Set(kKeyOsName, "ChromeOS");
+#elif defined(OS_LINUX)
+ entry->Set(kKeyOsName, "Linux");
+#endif
+
+ // SysInfo::OperatingSystemVersionNumbers is only defined for the following
+ // OSes: see base/sys_info_unittest.cc.
+#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS)
+ std::stringstream os_version;
+ int32 os_major_version = 0;
+ int32 os_minor_version = 0;
+ int32 os_bugfix_version = 0;
+ SysInfo::OperatingSystemVersionNumbers(&os_major_version, &os_minor_version,
+ &os_bugfix_version);
+ os_version << os_major_version << "." << os_minor_version << "."
+ << os_bugfix_version;
+ entry->Set(kKeyOsVersion, os_version.str());
+#endif
+
+ entry->Set(kKeyHostVersion, STRINGIZE(VERSION));
+ entry->AddCpuField();
+};
+
+void AddConnectionTypeToLogEntry(ServerLogEntry* entry,
+ protocol::TransportRoute::RouteType type) {
+ entry->Set(kKeyConnectionType, protocol::TransportRoute::GetTypeString(type));
+}
+
+} // namespace remoting
« no previous file with comments | « remoting/host/server_log_entry_host.h ('k') | remoting/host/server_log_entry_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698