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

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

Issue 2629593003: [Chromoting.com] Make Android telemetry report host version/os/os version (Closed)
Patch Set: PTAL Point Created 3 years, 11 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 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/rand_util.h" 8 #include "base/rand_util.h"
9 #include "remoting/base/telemetry_log_writer.h" 9 #include "remoting/base/telemetry_log_writer.h"
10 10
11 namespace { 11 namespace {
12 12
13 const char kSessionIdAlphabet[] = 13 const char kSessionIdAlphabet[] =
14 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; 14 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
15 const int kSessionIdLength = 20; 15 const int kSessionIdLength = 20;
16 16
17 const int kMaxSessionIdAgeDays = 1; 17 const int kMaxSessionIdAgeDays = 1;
18 18
19 } // namespace 19 } // namespace
20 20
21 namespace remoting { 21 namespace remoting {
22 22
23 struct ClientTelemetryLogger::HostInfo {
24 const std::string host_version;
25 const ChromotingEvent::Os host_os;
26 const std::string host_os_version;
27 };
28
23 ClientTelemetryLogger::ClientTelemetryLogger(ChromotingEvent::Mode mode) 29 ClientTelemetryLogger::ClientTelemetryLogger(ChromotingEvent::Mode mode)
24 : mode_(mode) {} 30 : mode_(mode) {}
25 31
26 ClientTelemetryLogger::~ClientTelemetryLogger() {} 32 ClientTelemetryLogger::~ClientTelemetryLogger() {}
27 33
34 void ClientTelemetryLogger::SetHostInfo(const std::string& host_version,
35 ChromotingEvent::Os host_os,
36 const std::string& host_os_version) {
37 host_info_.reset(new HostInfo{host_version, host_os, host_os_version});
38 }
39
28 void ClientTelemetryLogger::Start( 40 void ClientTelemetryLogger::Start(
29 std::unique_ptr<UrlRequestFactory> request_factory, 41 std::unique_ptr<UrlRequestFactory> request_factory,
30 const std::string& telemetry_base_url) { 42 const std::string& telemetry_base_url) {
31 DCHECK(!log_writer_); 43 DCHECK(!log_writer_);
32 DCHECK(thread_checker_.CalledOnValidThread()); 44 DCHECK(thread_checker_.CalledOnValidThread());
33 log_writer_.reset( 45 log_writer_.reset(
34 new TelemetryLogWriter(telemetry_base_url, std::move(request_factory))); 46 new TelemetryLogWriter(telemetry_base_url, std::move(request_factory)));
35 } 47 }
36 48
37 void ClientTelemetryLogger::LogSessionStateChange( 49 void ClientTelemetryLogger::LogSessionStateChange(
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 return ChromotingEvent::ConnectionError::UNKNOWN_ERROR; 157 return ChromotingEvent::ConnectionError::UNKNOWN_ERROR;
146 default: 158 default:
147 NOTREACHED(); 159 NOTREACHED();
148 return ChromotingEvent::ConnectionError::UNEXPECTED; 160 return ChromotingEvent::ConnectionError::UNEXPECTED;
149 } 161 }
150 } 162 }
151 163
152 void ClientTelemetryLogger::FillEventContext(ChromotingEvent* event) const { 164 void ClientTelemetryLogger::FillEventContext(ChromotingEvent* event) const {
153 event->SetEnum(ChromotingEvent::kModeKey, mode_); 165 event->SetEnum(ChromotingEvent::kModeKey, mode_);
154 event->SetEnum(ChromotingEvent::kRoleKey, ChromotingEvent::Role::CLIENT); 166 event->SetEnum(ChromotingEvent::kRoleKey, ChromotingEvent::Role::CLIENT);
167 if (host_info_) {
168 event->SetString(ChromotingEvent::kHostVersionKey,
169 host_info_->host_version);
170 event->SetEnum(ChromotingEvent::kHostOsKey, host_info_->host_os);
171 event->SetString(ChromotingEvent::kHostOsVersionKey,
172 host_info_->host_os_version);
173 }
155 event->AddSystemInfo(); 174 event->AddSystemInfo();
156 if (!session_id_.empty()) { 175 if (!session_id_.empty()) {
157 event->SetString(ChromotingEvent::kSessionIdKey, session_id_); 176 event->SetString(ChromotingEvent::kSessionIdKey, session_id_);
158 } 177 }
159 if (!session_start_time_.is_null()) { 178 if (!session_start_time_.is_null()) {
160 int session_duration = 179 int session_duration =
161 (base::TimeTicks::Now() - session_start_time_).InSeconds(); 180 (base::TimeTicks::Now() - session_start_time_).InSeconds();
162 event->SetInteger(ChromotingEvent::kSessionDurationKey, session_duration); 181 event->SetInteger(ChromotingEvent::kSessionDurationKey, session_duration);
163 } 182 }
164 } 183 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 return event; 258 return event;
240 } 259 }
241 260
242 ChromotingEvent ClientTelemetryLogger::MakeSessionIdNewEvent() { 261 ChromotingEvent ClientTelemetryLogger::MakeSessionIdNewEvent() {
243 ChromotingEvent event(ChromotingEvent::Type::SESSION_ID_NEW); 262 ChromotingEvent event(ChromotingEvent::Type::SESSION_ID_NEW);
244 FillEventContext(&event); 263 FillEventContext(&event);
245 return event; 264 return event;
246 } 265 }
247 266
248 } // namespace remoting 267 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698