| 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, specified based off values seen over a recent 7-day period. |
| 72 // The connection times histograms are in milliseconds and the connection |
| 73 // duration histograms are in minutes. |
| 74 const char kTimeToAuthenticateHistogram[] = |
| 75 "Chromoting.Connections.TimesMs.Authenticate"; |
| 76 const char kTimeToConnectHistogram[] = "Chromoting.Connections.TimesMs.Connect"; |
| 77 const char kClosedSessionDurationHistogram[] = |
| 78 "Chromoting.Connections.DurationsMinutes.Closed"; |
| 79 const char kFailedSessionDurationHistogram[] = |
| 80 "Chromoting.Connections.DurationsMinutes.Failed"; |
| 81 const int kConnectionTimesHistogramMinMs = 1; |
| 82 const int kConnectionTimesHistogramMaxMs = 30000; |
| 83 const int kConnectionTimesHistogramBuckets = 50; |
| 84 const int kConnectionDurationHistogramMinMinutes = 1; |
| 85 const int kConnectionDurationHistogramMaxMinutes = 24 * 60; |
| 86 const int kConnectionDurationHistogramBuckets = 50; |
| 87 |
| 70 // TODO(sergeyu): Ideally we should just pass ErrorCode to the webapp | 88 // 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 | 89 // 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 | 90 // 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. | 91 // easy to do after we are finished moving the client plugin to NaCl. |
| 74 std::string ConnectionErrorToString(protocol::ErrorCode error) { | 92 std::string ConnectionErrorToString(protocol::ErrorCode error) { |
| 75 // Values returned by this function must match the | 93 // Values returned by this function must match the |
| 76 // remoting.ClientSession.Error enum in JS code. | 94 // remoting.ClientSession.Error enum in JS code. |
| 77 switch (error) { | 95 switch (error) { |
| 78 case protocol::OK: | 96 case protocol::OK: |
| 79 return "NONE"; | 97 return "NONE"; |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 } | 375 } |
| 358 | 376 |
| 359 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 377 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
| 360 data->Set("rects", rects_value.release()); | 378 data->Set("rects", rects_value.release()); |
| 361 PostLegacyJsonMessage("onDebugRegion", data.Pass()); | 379 PostLegacyJsonMessage("onDebugRegion", data.Pass()); |
| 362 } | 380 } |
| 363 | 381 |
| 364 void ChromotingInstance::OnConnectionState( | 382 void ChromotingInstance::OnConnectionState( |
| 365 protocol::ConnectionToHost::State state, | 383 protocol::ConnectionToHost::State state, |
| 366 protocol::ErrorCode error) { | 384 protocol::ErrorCode error) { |
| 385 pp::UMAPrivate uma(this); |
| 386 |
| 387 switch (state) { |
| 388 case protocol::ConnectionToHost::CONNECTING: |
| 389 connection_started_time = base::TimeTicks::Now(); |
| 390 break; |
| 391 case protocol::ConnectionToHost::AUTHENTICATED: |
| 392 connection_authenticated_time_ = base::TimeTicks::Now(); |
| 393 uma.HistogramCustomTimes( |
| 394 kTimeToAuthenticateHistogram, |
| 395 (connection_authenticated_time_ - connection_started_time) |
| 396 .InMilliseconds(), |
| 397 kConnectionTimesHistogramMinMs, kConnectionTimesHistogramMaxMs, |
| 398 kConnectionTimesHistogramBuckets); |
| 399 break; |
| 400 case protocol::ConnectionToHost::CONNECTED: |
| 401 connection_connected_time_ = base::TimeTicks::Now(); |
| 402 uma.HistogramCustomTimes( |
| 403 kTimeToConnectHistogram, |
| 404 (connection_connected_time_ - connection_authenticated_time_) |
| 405 .InMilliseconds(), |
| 406 kConnectionTimesHistogramMinMs, kConnectionTimesHistogramMaxMs, |
| 407 kConnectionTimesHistogramBuckets); |
| 408 break; |
| 409 case protocol::ConnectionToHost::CLOSED: |
| 410 if (!connection_connected_time_.is_null()) { |
| 411 uma.HistogramCustomTimes( |
| 412 kClosedSessionDurationHistogram, |
| 413 (base::TimeTicks::Now() - connection_connected_time_) |
| 414 .InMilliseconds(), |
| 415 kConnectionDurationHistogramMinMinutes, |
| 416 kConnectionDurationHistogramMaxMinutes, |
| 417 kConnectionDurationHistogramBuckets); |
| 418 } |
| 419 break; |
| 420 case protocol::ConnectionToHost::FAILED: |
| 421 if (!connection_connected_time_.is_null()) { |
| 422 uma.HistogramCustomTimes( |
| 423 kFailedSessionDurationHistogram, |
| 424 (base::TimeTicks::Now() - connection_connected_time_) |
| 425 .InMilliseconds(), |
| 426 kConnectionDurationHistogramMinMinutes, |
| 427 kConnectionDurationHistogramMaxMinutes, |
| 428 kConnectionDurationHistogramBuckets); |
| 429 } |
| 430 break; |
| 431 case protocol::ConnectionToHost::INITIALIZING: |
| 432 break; |
| 433 } |
| 434 |
| 367 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 435 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
| 368 data->SetString("state", protocol::ConnectionToHost::StateToString(state)); | 436 data->SetString("state", protocol::ConnectionToHost::StateToString(state)); |
| 369 data->SetString("error", ConnectionErrorToString(error)); | 437 data->SetString("error", ConnectionErrorToString(error)); |
| 370 PostLegacyJsonMessage("onConnectionStatus", data.Pass()); | 438 PostLegacyJsonMessage("onConnectionStatus", data.Pass()); |
| 371 } | 439 } |
| 372 | 440 |
| 373 void ChromotingInstance::FetchThirdPartyToken( | 441 void ChromotingInstance::FetchThirdPartyToken( |
| 374 const GURL& token_url, | 442 const GURL& token_url, |
| 375 const std::string& host_public_key, | 443 const std::string& host_public_key, |
| 376 const std::string& scope, | 444 const std::string& scope, |
| (...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1074 | 1142 |
| 1075 if (is_custom_counts_histogram) | 1143 if (is_custom_counts_histogram) |
| 1076 uma.HistogramCustomCounts(histogram_name, value, histogram_min, | 1144 uma.HistogramCustomCounts(histogram_name, value, histogram_min, |
| 1077 histogram_max, histogram_buckets); | 1145 histogram_max, histogram_buckets); |
| 1078 else | 1146 else |
| 1079 uma.HistogramCustomTimes(histogram_name, value, histogram_min, | 1147 uma.HistogramCustomTimes(histogram_name, value, histogram_min, |
| 1080 histogram_max, histogram_buckets); | 1148 histogram_max, histogram_buckets); |
| 1081 } | 1149 } |
| 1082 | 1150 |
| 1083 } // namespace remoting | 1151 } // namespace remoting |
| OLD | NEW |