| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "remoting/base/chromoting_event.h" | 5 #include "remoting/base/chromoting_event.h" |
| 6 | 6 |
| 7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "base/strings/stringize_macros.h" | 8 #include "base/strings/stringize_macros.h" |
| 9 #include "base/sys_info.h" | 9 #include "base/sys_info.h" |
| 10 #include "remoting/base/name_value_map.h" |
| 10 | 11 |
| 11 namespace remoting { | 12 namespace remoting { |
| 12 | 13 |
| 14 namespace { |
| 15 |
| 16 const NameMapElement<ChromotingEvent::Os> kOsNames[] = { |
| 17 {ChromotingEvent::Os::CHROMOTING_LINUX, "linux"}, |
| 18 {ChromotingEvent::Os::CHROMOTING_CHROMEOS, "chromeos"}, |
| 19 {ChromotingEvent::Os::CHROMOTING_MAC, "mac"}, |
| 20 {ChromotingEvent::Os::CHROMOTING_WINDOWS, "windows"}, |
| 21 {ChromotingEvent::Os::CHROMOTING_ANDROID, "android"}, |
| 22 {ChromotingEvent::Os::CHROMOTING_IOS, "ios"}, |
| 23 }; |
| 24 |
| 25 } // namespace |
| 26 |
| 13 const char ChromotingEvent::kCaptureLatencyKey[] = "capture_latency"; | 27 const char ChromotingEvent::kCaptureLatencyKey[] = "capture_latency"; |
| 14 const char ChromotingEvent::kConnectionErrorKey[] = "connection_error"; | 28 const char ChromotingEvent::kConnectionErrorKey[] = "connection_error"; |
| 15 const char ChromotingEvent::kCpuKey[] = "cpu"; | 29 const char ChromotingEvent::kCpuKey[] = "cpu"; |
| 16 const char ChromotingEvent::kDecodeLatencyKey[] = "decode_latency"; | 30 const char ChromotingEvent::kDecodeLatencyKey[] = "decode_latency"; |
| 17 const char ChromotingEvent::kEncodeLatencyKey[] = "encode_latency"; | 31 const char ChromotingEvent::kEncodeLatencyKey[] = "encode_latency"; |
| 18 const char ChromotingEvent::kHostOsKey[] = "host_os"; | 32 const char ChromotingEvent::kHostOsKey[] = "host_os"; |
| 19 const char ChromotingEvent::kHostOsVersionKey[] = "host_os_version"; | 33 const char ChromotingEvent::kHostOsVersionKey[] = "host_os_version"; |
| 20 const char ChromotingEvent::kHostVersionKey[] = "host_version"; | 34 const char ChromotingEvent::kHostVersionKey[] = "host_version"; |
| 21 const char ChromotingEvent::kMaxCaptureLatencyKey[] = "max_capture_latency"; | 35 const char ChromotingEvent::kMaxCaptureLatencyKey[] = "max_capture_latency"; |
| 22 const char ChromotingEvent::kMaxDecodeLatencyKey[] = "max_decode_latency"; | 36 const char ChromotingEvent::kMaxDecodeLatencyKey[] = "max_decode_latency"; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 // static | 133 // static |
| 120 bool ChromotingEvent::IsEndOfSession(SessionState state) { | 134 bool ChromotingEvent::IsEndOfSession(SessionState state) { |
| 121 return state == SessionState::CLOSED || | 135 return state == SessionState::CLOSED || |
| 122 state == SessionState::CONNECTION_DROPPED || | 136 state == SessionState::CONNECTION_DROPPED || |
| 123 state == SessionState::CONNECTION_FAILED || | 137 state == SessionState::CONNECTION_FAILED || |
| 124 state == SessionState::CONNECTION_CANCELED; | 138 state == SessionState::CONNECTION_CANCELED; |
| 125 } | 139 } |
| 126 | 140 |
| 127 // static | 141 // static |
| 128 ChromotingEvent::Os ChromotingEvent::ParseOsFromString(const std::string& os) { | 142 ChromotingEvent::Os ChromotingEvent::ParseOsFromString(const std::string& os) { |
| 129 std::string lower_os = base::ToLowerASCII(os); | 143 ChromotingEvent::Os result; |
| 130 // TODO(yuweih): Refactor remoting/protocol/name_value_map.h and use it to | 144 if (!NameToValue(kOsNames, base::ToLowerASCII(os), &result)) { |
| 131 // map the value. | 145 return Os::OTHER; |
| 132 if (lower_os == "linux") { | |
| 133 return Os::CHROMOTING_LINUX; | |
| 134 } else if (lower_os == "chromeos") { | |
| 135 return Os::CHROMOTING_CHROMEOS; | |
| 136 } else if (lower_os == "mac") { | |
| 137 return Os::CHROMOTING_MAC; | |
| 138 } else if (lower_os == "windows") { | |
| 139 return Os::CHROMOTING_WINDOWS; | |
| 140 } else if (lower_os == "android") { | |
| 141 return Os::CHROMOTING_ANDROID; | |
| 142 } else if (lower_os == "ios") { | |
| 143 return Os::CHROMOTING_IOS; | |
| 144 } | 146 } |
| 145 return Os::OTHER; | 147 |
| 148 return result; |
| 146 } | 149 } |
| 147 | 150 |
| 148 } // namespace remoting | 151 } // namespace remoting |
| OLD | NEW |