| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/client/server_log_entry_client.h" | 5 #include "remoting/client/server_log_entry_client.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/stringize_macros.h" | 9 #include "base/strings/stringize_macros.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 ErrorCode error) { | 98 ErrorCode error) { |
| 99 scoped_ptr<ServerLogEntry> entry(new ServerLogEntry()); | 99 scoped_ptr<ServerLogEntry> entry(new ServerLogEntry()); |
| 100 entry->AddRoleField(kValueRoleClient); | 100 entry->AddRoleField(kValueRoleClient); |
| 101 entry->AddEventNameField(kValueEventNameSessionState); | 101 entry->AddEventNameField(kValueEventNameSessionState); |
| 102 | 102 |
| 103 entry->Set(kKeySessionState, GetValueSessionState(state)); | 103 entry->Set(kKeySessionState, GetValueSessionState(state)); |
| 104 if (error != protocol::OK) { | 104 if (error != protocol::OK) { |
| 105 entry->Set(kKeyConnectionError, GetValueError(error)); | 105 entry->Set(kKeyConnectionError, GetValueError(error)); |
| 106 } | 106 } |
| 107 | 107 |
| 108 return entry.Pass(); | 108 return entry; |
| 109 } | 109 } |
| 110 | 110 |
| 111 scoped_ptr<ServerLogEntry> MakeLogEntryForStatistics( | 111 scoped_ptr<ServerLogEntry> MakeLogEntryForStatistics( |
| 112 protocol::PerformanceTracker* perf_tracker) { | 112 protocol::PerformanceTracker* perf_tracker) { |
| 113 scoped_ptr<ServerLogEntry> entry(new ServerLogEntry()); | 113 scoped_ptr<ServerLogEntry> entry(new ServerLogEntry()); |
| 114 entry->AddRoleField(kValueRoleClient); | 114 entry->AddRoleField(kValueRoleClient); |
| 115 entry->AddEventNameField(kValueEventNameStatistics); | 115 entry->AddEventNameField(kValueEventNameStatistics); |
| 116 | 116 |
| 117 entry->Set("video-bandwidth", | 117 entry->Set("video-bandwidth", |
| 118 StringPrintf("%.2f", perf_tracker->video_bandwidth())); | 118 StringPrintf("%.2f", perf_tracker->video_bandwidth())); |
| 119 entry->Set("capture-latency", | 119 entry->Set("capture-latency", |
| 120 StringPrintf("%.2f", perf_tracker->video_capture_ms())); | 120 StringPrintf("%.2f", perf_tracker->video_capture_ms())); |
| 121 entry->Set("encode-latency", | 121 entry->Set("encode-latency", |
| 122 StringPrintf("%.2f", perf_tracker->video_encode_ms())); | 122 StringPrintf("%.2f", perf_tracker->video_encode_ms())); |
| 123 entry->Set("decode-latency", | 123 entry->Set("decode-latency", |
| 124 StringPrintf("%.2f", perf_tracker->video_decode_ms())); | 124 StringPrintf("%.2f", perf_tracker->video_decode_ms())); |
| 125 entry->Set("render-latency", | 125 entry->Set("render-latency", |
| 126 StringPrintf("%.2f", perf_tracker->video_frame_rate())); | 126 StringPrintf("%.2f", perf_tracker->video_frame_rate())); |
| 127 entry->Set("roundtrip-latency", | 127 entry->Set("roundtrip-latency", |
| 128 StringPrintf("%.2f", perf_tracker->round_trip_ms())); | 128 StringPrintf("%.2f", perf_tracker->round_trip_ms())); |
| 129 | 129 |
| 130 return entry.Pass(); | 130 return entry; |
| 131 } | 131 } |
| 132 | 132 |
| 133 scoped_ptr<ServerLogEntry> MakeLogEntryForSessionIdOld( | 133 scoped_ptr<ServerLogEntry> MakeLogEntryForSessionIdOld( |
| 134 const std::string& session_id) { | 134 const std::string& session_id) { |
| 135 scoped_ptr<ServerLogEntry> entry(new ServerLogEntry()); | 135 scoped_ptr<ServerLogEntry> entry(new ServerLogEntry()); |
| 136 entry->AddRoleField(kValueRoleClient); | 136 entry->AddRoleField(kValueRoleClient); |
| 137 entry->AddEventNameField(kValueEventNameSessionIdOld); | 137 entry->AddEventNameField(kValueEventNameSessionIdOld); |
| 138 AddSessionIdToLogEntry(entry.get(), session_id); | 138 AddSessionIdToLogEntry(entry.get(), session_id); |
| 139 return entry.Pass(); | 139 return entry; |
| 140 } | 140 } |
| 141 | 141 |
| 142 scoped_ptr<ServerLogEntry> MakeLogEntryForSessionIdNew( | 142 scoped_ptr<ServerLogEntry> MakeLogEntryForSessionIdNew( |
| 143 const std::string& session_id) { | 143 const std::string& session_id) { |
| 144 scoped_ptr<ServerLogEntry> entry(new ServerLogEntry()); | 144 scoped_ptr<ServerLogEntry> entry(new ServerLogEntry()); |
| 145 entry->AddRoleField(kValueRoleClient); | 145 entry->AddRoleField(kValueRoleClient); |
| 146 entry->AddEventNameField(kValueEventNameSessionIdNew); | 146 entry->AddEventNameField(kValueEventNameSessionIdNew); |
| 147 AddSessionIdToLogEntry(entry.get(), session_id); | 147 AddSessionIdToLogEntry(entry.get(), session_id); |
| 148 return entry.Pass(); | 148 return entry; |
| 149 } | 149 } |
| 150 | 150 |
| 151 void AddClientFieldsToLogEntry(ServerLogEntry* entry) { | 151 void AddClientFieldsToLogEntry(ServerLogEntry* entry) { |
| 152 entry->Set(kKeyOsName, SysInfo::OperatingSystemName()); | 152 entry->Set(kKeyOsName, SysInfo::OperatingSystemName()); |
| 153 entry->Set(kKeyOsVersion, SysInfo::OperatingSystemVersion()); | 153 entry->Set(kKeyOsVersion, SysInfo::OperatingSystemVersion()); |
| 154 entry->Set(kKeyAppVersion, STRINGIZE(VERSION)); | 154 entry->Set(kKeyAppVersion, STRINGIZE(VERSION)); |
| 155 entry->AddCpuField(); | 155 entry->AddCpuField(); |
| 156 } | 156 } |
| 157 | 157 |
| 158 void AddSessionIdToLogEntry(ServerLogEntry* entry, const std::string& id) { | 158 void AddSessionIdToLogEntry(ServerLogEntry* entry, const std::string& id) { |
| 159 entry->Set(kKeySessionId, id); | 159 entry->Set(kKeySessionId, id); |
| 160 } | 160 } |
| 161 | 161 |
| 162 void AddSessionDurationToLogEntry(ServerLogEntry* entry, | 162 void AddSessionDurationToLogEntry(ServerLogEntry* entry, |
| 163 base::TimeDelta duration) { | 163 base::TimeDelta duration) { |
| 164 entry->Set(kKeySessionDuration, base::Int64ToString(duration.InSeconds())); | 164 entry->Set(kKeySessionDuration, base::Int64ToString(duration.InSeconds())); |
| 165 } | 165 } |
| 166 | 166 |
| 167 } // namespace remoting | 167 } // namespace remoting |
| OLD | NEW |