Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: remoting/client/client_telemetry_logger.cc

Issue 2753963002: Refactoring and rewriting the chromoting jni instance to be chromoting session. (Closed)
Patch Set: Fixed feedback. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #if defined(OS_ANDROID)
Lambros 2017/04/05 01:31:19 Move below the other #includes.
nicholss 2017/04/05 17:24:26 Acknowledged.
8 #include <android/log.h>
9 #endif // OS_ANDROID
10
11 #include "base/format_macros.h"
7 #include "base/logging.h" 12 #include "base/logging.h"
8 #include "base/rand_util.h" 13 #include "base/rand_util.h"
14 #include "base/strings/stringprintf.h"
9 #include "remoting/base/telemetry_log_writer.h" 15 #include "remoting/base/telemetry_log_writer.h"
10 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
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 #if defined(OS_ANDROID)
78 void ClientTelemetryLogger::PrintLogStatistics(
79 protocol::PerformanceTracker* perf_tracker) {
80 __android_log_print(
81 ANDROID_LOG_INFO, "stats",
82 "Bandwidth:%.0f FrameRate:%.1f;"
83 " (Avg, Max) Capture:%.1f, %" PRId64 " Encode:%.1f, %" PRId64
84 " Decode:%.1f, %" PRId64 " Render:%.1f, %" PRId64 " RTL:%.0f, %" PRId64,
85 perf_tracker->video_bandwidth(), perf_tracker->video_frame_rate(),
86 perf_tracker->video_capture_ms().Average(),
87 perf_tracker->video_capture_ms().Max(),
88 perf_tracker->video_encode_ms().Average(),
89 perf_tracker->video_encode_ms().Max(),
90 perf_tracker->video_decode_ms().Average(),
91 perf_tracker->video_decode_ms().Max(),
92 perf_tracker->video_paint_ms().Average(),
93 perf_tracker->video_paint_ms().Max(),
94 perf_tracker->round_trip_ms().Average(),
95 perf_tracker->round_trip_ms().Max());
96 }
97 #else
98 void ClientTelemetryLogger::PrintLogStatistics(
99 protocol::PerformanceTracker* perf_tracker) {
100 VLOG(1) << base::StringPrintf(
Yuwei 2017/04/03 21:40:46 What about putting the #ifdefs inside the function
nicholss 2017/04/03 21:56:00 I don't think that makes this more readable.
101 "Bandwidth:%.0f FrameRate:%.1f;"
Lambros 2017/04/05 01:31:19 Duplicating this code makes me sad. Could you writ
nicholss 2017/04/05 17:24:25 That type of feature is pretty easy now with the a
102 " (Avg, Max) Capture:%.1f, %" PRId64 " Encode:%.1f, %" PRId64
103 " Decode:%.1f, %" PRId64 " Render:%.1f, %" PRId64 " RTL:%.0f, %" PRId64,
104 perf_tracker->video_bandwidth(), perf_tracker->video_frame_rate(),
105 perf_tracker->video_capture_ms().Average(),
106 perf_tracker->video_capture_ms().Max(),
107 perf_tracker->video_encode_ms().Average(),
108 perf_tracker->video_encode_ms().Max(),
109 perf_tracker->video_decode_ms().Average(),
110 perf_tracker->video_decode_ms().Max(),
111 perf_tracker->video_paint_ms().Average(),
112 perf_tracker->video_paint_ms().Max(),
113 perf_tracker->round_trip_ms().Average(),
114 perf_tracker->round_trip_ms().Max());
115 }
116 #endif // OS_ANDROID
117
69 void ClientTelemetryLogger::SetSessionIdGenerationTimeForTest( 118 void ClientTelemetryLogger::SetSessionIdGenerationTimeForTest(
70 base::TimeTicks gen_time) { 119 base::TimeTicks gen_time) {
71 session_id_generation_time_ = gen_time; 120 session_id_generation_time_ = gen_time;
72 } 121 }
73 122
74 // static 123 // static
75 ChromotingEvent::SessionState ClientTelemetryLogger::TranslateState( 124 ChromotingEvent::SessionState ClientTelemetryLogger::TranslateState(
76 protocol::ConnectionToHost::State state) { 125 protocol::ConnectionToHost::State state) {
77 switch (state) { 126 switch (state) {
78 case protocol::ConnectionToHost::State::INITIALIZING: 127 case protocol::ConnectionToHost::State::INITIALIZING:
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 return event; 276 return event;
228 } 277 }
229 278
230 ChromotingEvent ClientTelemetryLogger::MakeSessionIdNewEvent() { 279 ChromotingEvent ClientTelemetryLogger::MakeSessionIdNewEvent() {
231 ChromotingEvent event(ChromotingEvent::Type::SESSION_ID_NEW); 280 ChromotingEvent event(ChromotingEvent::Type::SESSION_ID_NEW);
232 FillEventContext(&event); 281 FillEventContext(&event);
233 return event; 282 return event;
234 } 283 }
235 284
236 } // namespace remoting 285 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698