server_log_entry_host.cc 1.9 KB

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