| 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/client/client_telemetry_logger.h" | 5 #include "remoting/client/client_telemetry_logger.h" |
| 6 | 6 |
| 7 #include "base/format_macros.h" |
| 7 #include "base/logging.h" | 8 #include "base/logging.h" |
| 8 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
| 10 #include "base/strings/stringprintf.h" |
| 9 #include "remoting/base/telemetry_log_writer.h" | 11 #include "remoting/base/telemetry_log_writer.h" |
| 10 | 12 |
| 13 #if defined(OS_ANDROID) |
| 14 #include <android/log.h> |
| 15 #endif // OS_ANDROID |
| 16 |
| 11 namespace { | 17 namespace { |
| 12 | 18 |
| 13 const char kSessionIdAlphabet[] = | 19 const char kSessionIdAlphabet[] = |
| 14 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; | 20 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; |
| 15 const int kSessionIdLength = 20; | 21 const int kSessionIdLength = 20; |
| 16 const int kMaxSessionIdAgeDays = 1; | 22 const int kMaxSessionIdAgeDays = 1; |
| 17 | 23 |
| 18 } // namespace | 24 } // namespace |
| 19 | 25 |
| 20 namespace remoting { | 26 namespace remoting { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 session_id_.clear(); | 61 session_id_.clear(); |
| 56 session_start_time_ = base::TimeTicks(); | 62 session_start_time_ = base::TimeTicks(); |
| 57 } | 63 } |
| 58 } | 64 } |
| 59 | 65 |
| 60 void ClientTelemetryLogger::LogStatistics( | 66 void ClientTelemetryLogger::LogStatistics( |
| 61 protocol::PerformanceTracker* perf_tracker) { | 67 protocol::PerformanceTracker* perf_tracker) { |
| 62 DCHECK(thread_checker_.CalledOnValidThread()); | 68 DCHECK(thread_checker_.CalledOnValidThread()); |
| 63 RefreshSessionIdIfOutdated(); | 69 RefreshSessionIdIfOutdated(); |
| 64 | 70 |
| 71 PrintLogStatistics(perf_tracker); |
| 72 |
| 65 ChromotingEvent event = MakeStatsEvent(perf_tracker); | 73 ChromotingEvent event = MakeStatsEvent(perf_tracker); |
| 66 log_writer_->Log(event); | 74 log_writer_->Log(event); |
| 67 } | 75 } |
| 68 | 76 |
| 77 void ClientTelemetryLogger::PrintLogStatistics( |
| 78 protocol::PerformanceTracker* perf_tracker) { |
| 79 #if defined(OS_ANDROID) |
| 80 __android_log_print( |
| 81 ANDROID_LOG_INFO, "stats", |
| 82 #else |
| 83 VLOG(1) << base::StringPrintf( |
| 84 #endif // OS_ANDROID |
| 85 "Bandwidth:%.0f FrameRate:%.1f;" |
| 86 " (Avg, Max) Capture:%.1f, %" PRId64 " Encode:%.1f, %" PRId64 |
| 87 " Decode:%.1f, %" PRId64 " Render:%.1f, %" PRId64 " RTL:%.0f, %" PRId64, |
| 88 perf_tracker->video_bandwidth(), perf_tracker->video_frame_rate(), |
| 89 perf_tracker->video_capture_ms().Average(), |
| 90 perf_tracker->video_capture_ms().Max(), |
| 91 perf_tracker->video_encode_ms().Average(), |
| 92 perf_tracker->video_encode_ms().Max(), |
| 93 perf_tracker->video_decode_ms().Average(), |
| 94 perf_tracker->video_decode_ms().Max(), |
| 95 perf_tracker->video_paint_ms().Average(), |
| 96 perf_tracker->video_paint_ms().Max(), |
| 97 perf_tracker->round_trip_ms().Average(), |
| 98 perf_tracker->round_trip_ms().Max()); |
| 99 } |
| 100 |
| 69 void ClientTelemetryLogger::SetSessionIdGenerationTimeForTest( | 101 void ClientTelemetryLogger::SetSessionIdGenerationTimeForTest( |
| 70 base::TimeTicks gen_time) { | 102 base::TimeTicks gen_time) { |
| 71 session_id_generation_time_ = gen_time; | 103 session_id_generation_time_ = gen_time; |
| 72 } | 104 } |
| 73 | 105 |
| 74 // static | 106 // static |
| 75 ChromotingEvent::SessionState ClientTelemetryLogger::TranslateState( | 107 ChromotingEvent::SessionState ClientTelemetryLogger::TranslateState( |
| 76 protocol::ConnectionToHost::State state) { | 108 protocol::ConnectionToHost::State state) { |
| 77 switch (state) { | 109 switch (state) { |
| 78 case protocol::ConnectionToHost::State::INITIALIZING: | 110 case protocol::ConnectionToHost::State::INITIALIZING: |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 return event; | 259 return event; |
| 228 } | 260 } |
| 229 | 261 |
| 230 ChromotingEvent ClientTelemetryLogger::MakeSessionIdNewEvent() { | 262 ChromotingEvent ClientTelemetryLogger::MakeSessionIdNewEvent() { |
| 231 ChromotingEvent event(ChromotingEvent::Type::SESSION_ID_NEW); | 263 ChromotingEvent event(ChromotingEvent::Type::SESSION_ID_NEW); |
| 232 FillEventContext(&event); | 264 FillEventContext(&event); |
| 233 return event; | 265 return event; |
| 234 } | 266 } |
| 235 | 267 |
| 236 } // namespace remoting | 268 } // namespace remoting |
| OLD | NEW |