OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/plugin/chromoting_instance.h" | 5 #include "remoting/client/plugin/chromoting_instance.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include <nacl_io/nacl_io.h> | 10 #include <nacl_io/nacl_io.h> |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 60 |
61 // Default DPI to assume for old clients that use notifyClientResolution. | 61 // Default DPI to assume for old clients that use notifyClientResolution. |
62 const int kDefaultDPI = 96; | 62 const int kDefaultDPI = 96; |
63 | 63 |
64 // Size of the random seed blob used to initialize RNG in libjingle. OpenSSL | 64 // Size of the random seed blob used to initialize RNG in libjingle. OpenSSL |
65 // needs at least 32 bytes of entropy (see | 65 // needs at least 32 bytes of entropy (see |
66 // http://wiki.openssl.org/index.php/Random_Numbers), but stores 1039 bytes of | 66 // http://wiki.openssl.org/index.php/Random_Numbers), but stores 1039 bytes of |
67 // state, so we initialize it with 1k or random data. | 67 // state, so we initialize it with 1k or random data. |
68 const int kRandomSeedSize = 1024; | 68 const int kRandomSeedSize = 1024; |
69 | 69 |
| 70 // The connection times and duration values are stored in UMA custom-time |
| 71 // histograms, that are log-scaled by default. The histogram specifications are |
| 72 // based off values seen over a recent 7-day period. |
| 73 // The connection times histograms are in milliseconds and the connection |
| 74 // duration histograms are in minutes. |
| 75 const char kTimeToAuthenticateHistogram[] = |
| 76 "Chromoting.Connections.Times.ToAuthenticate"; |
| 77 const char kTimeToConnectHistogram[] = "Chromoting.Connections.Times.ToConnect"; |
| 78 const char kClosedSessionDurationHistogram[] = |
| 79 "Chromoting.Connections.Durations.Closed"; |
| 80 const char kFailedSessionDurationHistogram[] = |
| 81 "Chromoting.Connections.Durations.Failed"; |
| 82 const int kConnectionTimesHistogramMinMs = 1; |
| 83 const int kConnectionTimesHistogramMaxMs = 30000; |
| 84 const int kConnectionTimesHistogramBuckets = 50; |
| 85 const int kConnectionDurationHistogramMinMinutes = 1; |
| 86 const int kConnectionDurationHistogramMaxMinutes = 24 * 60; |
| 87 const int kConnectionDurationHistogramBuckets = 50; |
| 88 |
70 // TODO(sergeyu): Ideally we should just pass ErrorCode to the webapp | 89 // TODO(sergeyu): Ideally we should just pass ErrorCode to the webapp |
71 // and let it handle it, but it would be hard to fix it now because | 90 // and let it handle it, but it would be hard to fix it now because |
72 // client plugin and webapp versions may not be in sync. It should be | 91 // client plugin and webapp versions may not be in sync. It should be |
73 // easy to do after we are finished moving the client plugin to NaCl. | 92 // easy to do after we are finished moving the client plugin to NaCl. |
74 std::string ConnectionErrorToString(protocol::ErrorCode error) { | 93 std::string ConnectionErrorToString(protocol::ErrorCode error) { |
75 // Values returned by this function must match the | 94 // Values returned by this function must match the |
76 // remoting.ClientSession.Error enum in JS code. | 95 // remoting.ClientSession.Error enum in JS code. |
77 switch (error) { | 96 switch (error) { |
78 case protocol::OK: | 97 case protocol::OK: |
79 return "NONE"; | 98 return "NONE"; |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 } | 376 } |
358 | 377 |
359 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 378 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
360 data->Set("rects", rects_value.release()); | 379 data->Set("rects", rects_value.release()); |
361 PostLegacyJsonMessage("onDebugRegion", data.Pass()); | 380 PostLegacyJsonMessage("onDebugRegion", data.Pass()); |
362 } | 381 } |
363 | 382 |
364 void ChromotingInstance::OnConnectionState( | 383 void ChromotingInstance::OnConnectionState( |
365 protocol::ConnectionToHost::State state, | 384 protocol::ConnectionToHost::State state, |
366 protocol::ErrorCode error) { | 385 protocol::ErrorCode error) { |
| 386 pp::UMAPrivate uma(this); |
| 387 |
| 388 switch (state) { |
| 389 case protocol::ConnectionToHost::INITIALIZING: |
| 390 NOTREACHED(); |
| 391 break; |
| 392 case protocol::ConnectionToHost::CONNECTING: |
| 393 connection_started_time = base::TimeTicks::Now(); |
| 394 break; |
| 395 case protocol::ConnectionToHost::AUTHENTICATED: |
| 396 connection_authenticated_time_ = base::TimeTicks::Now(); |
| 397 uma.HistogramCustomTimes( |
| 398 kTimeToAuthenticateHistogram, |
| 399 (connection_authenticated_time_ - connection_started_time) |
| 400 .InMilliseconds(), |
| 401 kConnectionTimesHistogramMinMs, kConnectionTimesHistogramMaxMs, |
| 402 kConnectionTimesHistogramBuckets); |
| 403 break; |
| 404 case protocol::ConnectionToHost::CONNECTED: |
| 405 connection_connected_time_ = base::TimeTicks::Now(); |
| 406 uma.HistogramCustomTimes( |
| 407 kTimeToConnectHistogram, |
| 408 (connection_connected_time_ - connection_authenticated_time_) |
| 409 .InMilliseconds(), |
| 410 kConnectionTimesHistogramMinMs, kConnectionTimesHistogramMaxMs, |
| 411 kConnectionTimesHistogramBuckets); |
| 412 break; |
| 413 case protocol::ConnectionToHost::CLOSED: |
| 414 if (!connection_connected_time_.is_null()) { |
| 415 uma.HistogramCustomTimes( |
| 416 kClosedSessionDurationHistogram, |
| 417 (base::TimeTicks::Now() - connection_connected_time_) |
| 418 .InMilliseconds(), |
| 419 kConnectionDurationHistogramMinMinutes, |
| 420 kConnectionDurationHistogramMaxMinutes, |
| 421 kConnectionDurationHistogramBuckets); |
| 422 } |
| 423 break; |
| 424 case protocol::ConnectionToHost::FAILED: |
| 425 if (!connection_connected_time_.is_null()) { |
| 426 uma.HistogramCustomTimes( |
| 427 kFailedSessionDurationHistogram, |
| 428 (base::TimeTicks::Now() - connection_connected_time_) |
| 429 .InMilliseconds(), |
| 430 kConnectionDurationHistogramMinMinutes, |
| 431 kConnectionDurationHistogramMaxMinutes, |
| 432 kConnectionDurationHistogramBuckets); |
| 433 } |
| 434 break; |
| 435 } |
| 436 |
367 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 437 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
368 data->SetString("state", protocol::ConnectionToHost::StateToString(state)); | 438 data->SetString("state", protocol::ConnectionToHost::StateToString(state)); |
369 data->SetString("error", ConnectionErrorToString(error)); | 439 data->SetString("error", ConnectionErrorToString(error)); |
370 PostLegacyJsonMessage("onConnectionStatus", data.Pass()); | 440 PostLegacyJsonMessage("onConnectionStatus", data.Pass()); |
371 } | 441 } |
372 | 442 |
373 void ChromotingInstance::FetchThirdPartyToken( | 443 void ChromotingInstance::FetchThirdPartyToken( |
374 const GURL& token_url, | 444 const GURL& token_url, |
375 const std::string& host_public_key, | 445 const std::string& host_public_key, |
376 const std::string& scope, | 446 const std::string& scope, |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1074 | 1144 |
1075 if (is_custom_counts_histogram) | 1145 if (is_custom_counts_histogram) |
1076 uma.HistogramCustomCounts(histogram_name, value, histogram_min, | 1146 uma.HistogramCustomCounts(histogram_name, value, histogram_min, |
1077 histogram_max, histogram_buckets); | 1147 histogram_max, histogram_buckets); |
1078 else | 1148 else |
1079 uma.HistogramCustomTimes(histogram_name, value, histogram_min, | 1149 uma.HistogramCustomTimes(histogram_name, value, histogram_min, |
1080 histogram_max, histogram_buckets); | 1150 histogram_max, histogram_buckets); |
1081 } | 1151 } |
1082 | 1152 |
1083 } // namespace remoting | 1153 } // namespace remoting |
OLD | NEW |