Chromium Code Reviews| 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 kDroppedSessionDurationHistogram[] = | |
| 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_connecting_ = base::Time::Now(); | |
| 390 break; | |
| 391 case protocol::ConnectionToHost::AUTHENTICATED: | |
| 392 connection_authenticated_ = base::Time::Now(); | |
| 393 uma.HistogramCustomTimes( | |
| 394 kTimeToAuthenticateHistogram, | |
| 395 (connection_authenticated_ - connection_connecting_).InMilliseconds(), | |
| 396 kConnectionTimesHistogramMinMs, kConnectionTimesHistogramMaxMs, | |
| 397 kConnectionTimesHistogramBuckets); | |
| 398 break; | |
| 399 case protocol::ConnectionToHost::CONNECTED: | |
| 400 connection_connected_ = base::Time::Now(); | |
| 401 uma.HistogramCustomTimes( | |
| 402 kTimeToConnectHistogram, | |
| 403 (connection_connected_ - connection_authenticated_).InMilliseconds(), | |
| 404 kConnectionTimesHistogramMinMs, kConnectionTimesHistogramMaxMs, | |
| 405 kConnectionTimesHistogramBuckets); | |
| 406 break; | |
| 407 case protocol::ConnectionToHost::CLOSED: | |
| 408 uma.HistogramCustomTimes( | |
| 409 kClosedSessionDurationHistogram, | |
| 410 (base::Time::Now() - connection_connected_).InMilliseconds(), | |
| 411 kConnectionDurationHistogramMinMinutes, | |
| 412 kConnectionDurationHistogramMaxMinutes, | |
| 413 kConnectionDurationHistogramBuckets); | |
| 414 break; | |
| 415 case protocol::ConnectionToHost::FAILED: | |
| 416 uma.HistogramCustomTimes( | |
| 417 kDroppedSessionDurationHistogram, | |
| 418 (base::Time::Now() - connection_connected_).InMilliseconds(), | |
|
Sergey Ulanov
2015/08/20 21:05:19
connection_connected_ is set only if the session w
anandc
2015/08/20 23:12:01
Done.
| |
| 419 kConnectionDurationHistogramMinMinutes, | |
| 420 kConnectionDurationHistogramMaxMinutes, | |
| 421 kConnectionDurationHistogramBuckets); | |
| 422 break; | |
| 423 case protocol::ConnectionToHost::INITIALIZING: | |
| 424 break; | |
| 425 } | |
| 426 | |
| 367 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 427 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
| 368 data->SetString("state", protocol::ConnectionToHost::StateToString(state)); | 428 data->SetString("state", protocol::ConnectionToHost::StateToString(state)); |
| 369 data->SetString("error", ConnectionErrorToString(error)); | 429 data->SetString("error", ConnectionErrorToString(error)); |
| 370 PostLegacyJsonMessage("onConnectionStatus", data.Pass()); | 430 PostLegacyJsonMessage("onConnectionStatus", data.Pass()); |
| 371 } | 431 } |
| 372 | 432 |
| 373 void ChromotingInstance::FetchThirdPartyToken( | 433 void ChromotingInstance::FetchThirdPartyToken( |
| 374 const GURL& token_url, | 434 const GURL& token_url, |
| 375 const std::string& host_public_key, | 435 const std::string& host_public_key, |
| 376 const std::string& scope, | 436 const std::string& scope, |
| (...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1074 | 1134 |
| 1075 if (is_custom_counts_histogram) | 1135 if (is_custom_counts_histogram) |
| 1076 uma.HistogramCustomCounts(histogram_name, value, histogram_min, | 1136 uma.HistogramCustomCounts(histogram_name, value, histogram_min, |
| 1077 histogram_max, histogram_buckets); | 1137 histogram_max, histogram_buckets); |
| 1078 else | 1138 else |
| 1079 uma.HistogramCustomTimes(histogram_name, value, histogram_min, | 1139 uma.HistogramCustomTimes(histogram_name, value, histogram_min, |
| 1080 histogram_max, histogram_buckets); | 1140 histogram_max, histogram_buckets); |
| 1081 } | 1141 } |
| 1082 | 1142 |
| 1083 } // namespace remoting | 1143 } // namespace remoting |
| OLD | NEW |