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 "remoting/host/host_details.h"
9 #include "remoting/signaling/server_log_entry.h"
10
11 namespace remoting {
12
13 namespace {
14 const char kValueEventNameSessionState[] = "session-state";
15
16 const char kValueRoleHost[] = "host";
17
18 const char kKeySessionState[] = "session-state";
19 const char kValueSessionStateConnected[] = "connected";
20 const char kValueSessionStateClosed[] = "closed";
21
22 const char kKeyOsName[] = "os-name";
23 const char kKeyOsVersion[] = "os-version";
24
25 const char kKeyHostVersion[] = "host-version";
26
27 const char kKeyConnectionType[] = "connection-type";
28
GetValueSessionState(bool connected)29 const char* GetValueSessionState(bool connected) {
30 return connected ? kValueSessionStateConnected : kValueSessionStateClosed;
31 }
32
33 } // namespace
34
MakeLogEntryForSessionStateChange(bool connected)35 std::unique_ptr<ServerLogEntry> MakeLogEntryForSessionStateChange(
36 bool connected) {
37 std::unique_ptr<ServerLogEntry> entry(new ServerLogEntry());
38 entry->AddRoleField(kValueRoleHost);
39 entry->AddEventNameField(kValueEventNameSessionState);
40 entry->Set(kKeySessionState, GetValueSessionState(connected));
41 return entry;
42 }
43
AddHostFieldsToLogEntry(ServerLogEntry * entry)44 void AddHostFieldsToLogEntry(ServerLogEntry* entry) {
45 // TODO os name, os version, and version will be in the main message body,
46 // remove these fields at a later date to remove redundancy.
47 entry->Set(kKeyOsName, GetHostOperatingSystemName());
48 entry->Set(kKeyOsVersion, GetHostOperatingSystemVersion());
49 entry->Set(kKeyHostVersion, STRINGIZE(VERSION));
50 entry->AddCpuField();
51 }
52
AddConnectionTypeToLogEntry(ServerLogEntry * entry,protocol::TransportRoute::RouteType type)53 void AddConnectionTypeToLogEntry(ServerLogEntry* entry,
54 protocol::TransportRoute::RouteType type) {
55 entry->Set(kKeyConnectionType, protocol::TransportRoute::GetTypeString(type));
56 }
57
58 } // namespace remoting
59