| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "remoting/signaling/chromoting_event.h" | |
| 6 | |
| 7 #include "base/sys_info.h" | |
| 8 | |
| 9 namespace remoting { | |
| 10 | |
| 11 const char ChromotingEvent::kCaptureLatencyKey[] = "capture_latency"; | |
| 12 const char ChromotingEvent::kConnectionErrorKey[] = "connection_error"; | |
| 13 const char ChromotingEvent::kCpuKey[] = "cpu"; | |
| 14 const char ChromotingEvent::kDecodeLatencyKey[] = "decode_latency"; | |
| 15 const char ChromotingEvent::kEncodeLatencyKey[] = "encode_latency"; | |
| 16 const char ChromotingEvent::kMaxCaptureLatencyKey[] = "max_capture_latency"; | |
| 17 const char ChromotingEvent::kMaxDecodeLatencyKey[] = "max_decode_latency"; | |
| 18 const char ChromotingEvent::kMaxEncodeLatencyKey[] = "max_encode_latency"; | |
| 19 const char ChromotingEvent::kMaxRenderLatencyKey[] = "max_render_latency"; | |
| 20 const char ChromotingEvent::kMaxRoundtripLatencyKey[] = "max_roundtrip_latency"; | |
| 21 const char ChromotingEvent::kModeKey[] = "mode"; | |
| 22 const char ChromotingEvent::kOsKey[] = "os"; | |
| 23 const char ChromotingEvent::kOsVersionKey[] = "os_version"; | |
| 24 const char ChromotingEvent::kRenderLatencyKey[] = "render_latency"; | |
| 25 const char ChromotingEvent::kRoleKey[] = "role"; | |
| 26 const char ChromotingEvent::kRoundtripLatencyKey[] = "roundtrip_latency"; | |
| 27 const char ChromotingEvent::kSessionDurationKey[] = "session_duration"; | |
| 28 const char ChromotingEvent::kSessionIdKey[] = "session_id"; | |
| 29 const char ChromotingEvent::kSessionStateKey[] = "session_state"; | |
| 30 const char ChromotingEvent::kTypeKey[] = "type"; | |
| 31 const char ChromotingEvent::kVideoBandwidthKey[] = "video_bandwidth"; | |
| 32 | |
| 33 ChromotingEvent::ChromotingEvent() : values_map_(new base::DictionaryValue()) {} | |
| 34 | |
| 35 ChromotingEvent::ChromotingEvent(Type type) : ChromotingEvent() { | |
| 36 SetEnum(kTypeKey, type); | |
| 37 } | |
| 38 | |
| 39 ChromotingEvent::ChromotingEvent(const ChromotingEvent& other) { | |
| 40 try_count_ = other.try_count_; | |
| 41 values_map_ = other.values_map_->CreateDeepCopy(); | |
| 42 } | |
| 43 | |
| 44 ChromotingEvent::ChromotingEvent(ChromotingEvent&& other) { | |
| 45 try_count_ = other.try_count_; | |
| 46 values_map_ = std::move(other.values_map_); | |
| 47 } | |
| 48 | |
| 49 ChromotingEvent::~ChromotingEvent() {} | |
| 50 | |
| 51 ChromotingEvent& ChromotingEvent::operator=(const ChromotingEvent& other) { | |
| 52 if (this != &other) { | |
| 53 try_count_ = other.try_count_; | |
| 54 values_map_ = other.values_map_->CreateDeepCopy(); | |
| 55 } | |
| 56 return *this; | |
| 57 } | |
| 58 | |
| 59 ChromotingEvent& ChromotingEvent::operator=(ChromotingEvent&& other) { | |
| 60 try_count_ = other.try_count_; | |
| 61 values_map_ = std::move(other.values_map_); | |
| 62 return *this; | |
| 63 } | |
| 64 | |
| 65 void ChromotingEvent::SetString(const std::string& key, | |
| 66 const std::string& value) { | |
| 67 values_map_->SetString(key, value); | |
| 68 } | |
| 69 | |
| 70 void ChromotingEvent::SetInteger(const std::string& key, int value) { | |
| 71 values_map_->SetInteger(key, value); | |
| 72 } | |
| 73 | |
| 74 void ChromotingEvent::SetBoolean(const std::string& key, bool value) { | |
| 75 values_map_->SetBoolean(key, value); | |
| 76 } | |
| 77 | |
| 78 void ChromotingEvent::SetDouble(const std::string& key, double value) { | |
| 79 values_map_->SetDouble(key, value); | |
| 80 } | |
| 81 | |
| 82 void ChromotingEvent::AddSystemInfo() { | |
| 83 SetString(kCpuKey, base::SysInfo::OperatingSystemArchitecture()); | |
| 84 SetString(kOsVersionKey, base::SysInfo::OperatingSystemVersion()); | |
| 85 std::string osName = base::SysInfo::OperatingSystemName(); | |
| 86 #if defined(OS_LINUX) | |
| 87 Os os = Os::CHROMOTING_LINUX; | |
| 88 #elif defined(OS_CHROMEOS) | |
| 89 Os os = Os::CHROMOTING_CHROMEOS; | |
| 90 #elif defined(OS_MACOSX) | |
| 91 Os os = Os::CHROMOTING_MAC; | |
| 92 #elif defined(OS_WIN) | |
| 93 Os os = Os::CHROMOTING_WINDOWS; | |
| 94 #elif defined(OS_ANDROID) | |
| 95 Os os = Os::CHROMOTING_ANDROID; | |
| 96 #elif defined(OS_IOS) | |
| 97 Os os = Os::CHROMOTING_IOS; | |
| 98 #else | |
| 99 Os os = Os::OTHER; | |
| 100 #endif | |
| 101 SetEnum(kOsKey, os); | |
| 102 } | |
| 103 | |
| 104 void ChromotingEvent::IncrementTryCount() { | |
| 105 try_count_++; | |
| 106 } | |
| 107 | |
| 108 std::unique_ptr<base::DictionaryValue> ChromotingEvent::CopyDictionaryValue() | |
| 109 const { | |
| 110 return values_map_->CreateDeepCopy(); | |
| 111 } | |
| 112 | |
| 113 // static | |
| 114 bool ChromotingEvent::IsEndOfSession(SessionState state) { | |
| 115 return state == SessionState::CLOSED || | |
| 116 state == SessionState::CONNECTION_DROPPED || | |
| 117 state == SessionState::CONNECTION_FAILED || | |
| 118 state == SessionState::CONNECTION_CANCELED; | |
| 119 } | |
| 120 | |
| 121 } // namespace remoting | |
| OLD | NEW |