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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "remoting/host/server_log_entry_host.h"
6
7 #include "base/strings/stringize_macros.h"
8 #include "base/sys_info.h"
9 #include "remoting/jingle_glue/server_log_entry.h"
10
11 using base::SysInfo;
12
13 namespace remoting {
14
15 namespace {
16 const char kValueEventNameSessionState[] = "session-state";
17 const char kValueEventNameHeartbeat[] = "heartbeat";
18 const char kValueEventNameHostStatus[] = "host-status";
19
20 const char kValueRoleHost[] = "host";
21
22 const char kKeySessionState[] = "session-state";
23 const char kValueSessionStateConnected[] = "connected";
24 const char kValueSessionStateClosed[] = "closed";
25
26 const char kStatusName[] = "status";
27 const char kExitCodeName[] = "exit-code";
28
29 const char kKeyOsName[] = "os-name";
30
31 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS)
32 const char kKeyOsVersion[] = "os-version";
33 #endif
34
35 const char kKeyHostVersion[] = "host-version";
36
37 const char kKeyConnectionType[] = "connection-type";
38
39 const char* GetValueSessionState(bool connected) {
40 return connected ? kValueSessionStateConnected : kValueSessionStateClosed;
41 }
42
43 } // namespace
44
45 scoped_ptr<ServerLogEntry> MakeLogEntryForSessionStateChange(
46 bool connected) {
47 scoped_ptr<ServerLogEntry> entry(new ServerLogEntry());
48 entry->AddRoleField(kValueRoleHost);
49 entry->AddEventNameField(kValueEventNameSessionState);
50 entry->Set(kKeySessionState, GetValueSessionState(connected));
51 return entry.Pass();
52 }
53
54 scoped_ptr<ServerLogEntry> MakeLogEntryForHeartbeat() {
55 scoped_ptr<ServerLogEntry> entry(new ServerLogEntry());
56 entry->AddRoleField(kValueRoleHost);
57 entry->AddEventNameField(kValueEventNameHeartbeat);
58 return entry.Pass();
59 }
60
61 // static
62 scoped_ptr<ServerLogEntry> MakeLogEntryForHostStatus(
63 HostStatusSender::HostStatus host_status, HostExitCodes exit_code) {
64 scoped_ptr<ServerLogEntry> entry(new ServerLogEntry());
65 entry->AddRoleField(kValueRoleHost);
66 entry->AddEventNameField(kValueEventNameHostStatus);
67 entry->Set(kStatusName, HostStatusSender::HostStatusToString(host_status));
68 if (host_status == HostStatusSender::OFFLINE)
69 entry->Set(kExitCodeName, ExitCodeToString(exit_code));
70 return entry.Pass();
71 }
72
73 void AddHostFieldsToLogEntry(ServerLogEntry* entry) {
74 #if defined(OS_WIN)
75 entry->Set(kKeyOsName, "Windows");
76 #elif defined(OS_MACOSX)
77 entry->Set(kKeyOsName, "Mac");
78 #elif defined(OS_CHROMEOS)
79 entry->Set(kKeyOsName, "ChromeOS");
80 #elif defined(OS_LINUX)
81 entry->Set(kKeyOsName, "Linux");
82 #endif
83
84 // SysInfo::OperatingSystemVersionNumbers is only defined for the following
85 // OSes: see base/sys_info_unittest.cc.
86 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS)
87 std::stringstream os_version;
88 int32 os_major_version = 0;
89 int32 os_minor_version = 0;
90 int32 os_bugfix_version = 0;
91 SysInfo::OperatingSystemVersionNumbers(&os_major_version, &os_minor_version,
92 &os_bugfix_version);
93 os_version << os_major_version << "." << os_minor_version << "."
94 << os_bugfix_version;
95 entry->Set(kKeyOsVersion, os_version.str());
96 #endif
97
98 entry->Set(kKeyHostVersion, STRINGIZE(VERSION));
99 entry->AddCpuField();
100 };
101
102 void AddConnectionTypeToLogEntry(ServerLogEntry* entry,
103 protocol::TransportRoute::RouteType type) {
104 entry->Set(kKeyConnectionType, protocol::TransportRoute::GetTypeString(type));
105 }
106
107 } // namespace remoting
OLDNEW
« 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