Fix mouse warp with 2x displays
[chromium-blink-merge.git] / remoting / host / server_log_entry_host.cc
blob7c258652fd4797f17657e4a88674fbb76de36692
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.
5 #include "remoting/host/server_log_entry_host.h"
7 #include "base/strings/stringize_macros.h"
8 #include "base/sys_info.h"
9 #include "remoting/signaling/server_log_entry.h"
11 using base::SysInfo;
13 namespace remoting {
15 namespace {
16 const char kValueEventNameSessionState[] = "session-state";
17 const char kValueEventNameHeartbeat[] = "heartbeat";
19 const char kValueRoleHost[] = "host";
21 const char kKeySessionState[] = "session-state";
22 const char kValueSessionStateConnected[] = "connected";
23 const char kValueSessionStateClosed[] = "closed";
25 const char kKeyOsName[] = "os-name";
27 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS)
28 const char kKeyOsVersion[] = "os-version";
29 #endif
31 const char kKeyHostVersion[] = "host-version";
33 const char kKeyConnectionType[] = "connection-type";
35 const char* GetValueSessionState(bool connected) {
36 return connected ? kValueSessionStateConnected : kValueSessionStateClosed;
39 } // namespace
41 scoped_ptr<ServerLogEntry> MakeLogEntryForSessionStateChange(
42 bool connected) {
43 scoped_ptr<ServerLogEntry> entry(new ServerLogEntry());
44 entry->AddRoleField(kValueRoleHost);
45 entry->AddEventNameField(kValueEventNameSessionState);
46 entry->Set(kKeySessionState, GetValueSessionState(connected));
47 return entry.Pass();
50 scoped_ptr<ServerLogEntry> MakeLogEntryForHeartbeat() {
51 scoped_ptr<ServerLogEntry> entry(new ServerLogEntry());
52 entry->AddRoleField(kValueRoleHost);
53 entry->AddEventNameField(kValueEventNameHeartbeat);
54 return entry.Pass();
57 void AddHostFieldsToLogEntry(ServerLogEntry* entry) {
58 #if defined(OS_WIN)
59 entry->Set(kKeyOsName, "Windows");
60 #elif defined(OS_MACOSX)
61 entry->Set(kKeyOsName, "Mac");
62 #elif defined(OS_CHROMEOS)
63 entry->Set(kKeyOsName, "ChromeOS");
64 #elif defined(OS_LINUX)
65 entry->Set(kKeyOsName, "Linux");
66 #endif
68 // SysInfo::OperatingSystemVersionNumbers is only defined for the following
69 // OSes: see base/sys_info_unittest.cc.
70 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS)
71 std::stringstream os_version;
72 int32 os_major_version = 0;
73 int32 os_minor_version = 0;
74 int32 os_bugfix_version = 0;
75 SysInfo::OperatingSystemVersionNumbers(&os_major_version, &os_minor_version,
76 &os_bugfix_version);
77 os_version << os_major_version << "." << os_minor_version << "."
78 << os_bugfix_version;
79 entry->Set(kKeyOsVersion, os_version.str());
80 #endif
82 entry->Set(kKeyHostVersion, STRINGIZE(VERSION));
83 entry->AddCpuField();
86 void AddConnectionTypeToLogEntry(ServerLogEntry* entry,
87 protocol::TransportRoute::RouteType type) {
88 entry->Set(kKeyConnectionType, protocol::TransportRoute::GetTypeString(type));
91 } // namespace remoting