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

Side by Side Diff: remoting/webapp/base/js/client_session.js

Issue 1305453002: Add UMA stats for Chromoting connection details. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Include all SessionState enums in UMA enumerated-histogram. Cleanup plugin code. Created 5 years, 4 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 (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 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * Class handling creation and teardown of a remoting client session. 7 * Class handling creation and teardown of a remoting client session.
8 * 8 *
9 * The ClientSession class controls lifetime of the client plugin 9 * The ClientSession class controls lifetime of the client plugin
10 * object and provides the plugin with the functionality it needs to 10 * object and provides the plugin with the functionality it needs to
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 */ 132 */
133 remoting.ClientSession.EventHandler.prototype.onDisconnected = 133 remoting.ClientSession.EventHandler.prototype.onDisconnected =
134 function(reason) {}; 134 function(reason) {};
135 135
136 // Note that the positive values in both of these enums are copied directly 136 // Note that the positive values in both of these enums are copied directly
137 // from connection_to_host.h and must be kept in sync. Code in 137 // from connection_to_host.h and must be kept in sync. Code in
138 // chromoting_instance.cc converts the C++ enums into strings that must match 138 // chromoting_instance.cc converts the C++ enums into strings that must match
139 // the names given here. 139 // the names given here.
140 // The negative values represent state transitions that occur within the 140 // The negative values represent state transitions that occur within the
141 // web-app that have no corresponding plugin state transition. 141 // web-app that have no corresponding plugin state transition.
142 // NOTE: The enums here are also defined in histograms.xml for our UMA
143 // Chromoting.Connections histogram. The 2 lists should be kept in sync.
Ilya Sherman 2015/08/21 19:48:29 Please also document that the enum should be treat
anandc 2015/08/21 21:30:03 Done.
142 /** @enum {number} */ 144 /** @enum {number} */
143 remoting.ClientSession.State = { 145 remoting.ClientSession.State = {
146 MIN_STATE_ENUM: -3,
144 CONNECTION_CANCELED: -3, // Connection closed (gracefully) before connecting. 147 CONNECTION_CANCELED: -3, // Connection closed (gracefully) before connecting.
145 CONNECTION_DROPPED: -2, // Succeeded, but subsequently closed with an error. 148 CONNECTION_DROPPED: -2, // Succeeded, but subsequently closed with an error.
146 CREATED: -1, 149 CREATED: -1,
147 UNKNOWN: 0, 150 UNKNOWN: 0,
148 INITIALIZING: 1, 151 INITIALIZING: 1,
149 CONNECTING: 2, 152 CONNECTING: 2,
150 AUTHENTICATED: 3, 153 AUTHENTICATED: 3,
151 CONNECTED: 4, 154 CONNECTED: 4,
152 CLOSED: 5, 155 CLOSED: 5,
153 FAILED: 6 156 FAILED: 6,
157 MAX_STATE_ENUM: 7 // The upper limit for a UMA enumerated histogram should be
158 // 1 above the max-enum. See src/base/metrics/histogram.h.
154 }; 159 };
155 160
156 /** 161 /**
157 * @param {string} state The state name. 162 * @param {string} state The state name.
158 * @return {remoting.ClientSession.State} The session state enum value. 163 * @return {remoting.ClientSession.State} The session state enum value.
159 */ 164 */
160 remoting.ClientSession.State.fromString = function(state) { 165 remoting.ClientSession.State.fromString = function(state) {
161 if (!remoting.ClientSession.State.hasOwnProperty(state)) { 166 if (!remoting.ClientSession.State.hasOwnProperty(state)) {
162 throw "Invalid ClientSession.State: " + state; 167 throw "Invalid ClientSession.State: " + state;
163 } 168 }
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 if (this.plugin_.hasCapability( 564 if (this.plugin_.hasCapability(
560 remoting.ClientSession.Capability.TOUCH_EVENTS)) { 565 remoting.ClientSession.Capability.TOUCH_EVENTS)) {
561 this.plugin_.enableTouchEvents(true); 566 this.plugin_.enableTouchEvents(true);
562 } 567 }
563 } else if (this.isFinished()) { 568 } else if (this.isFinished()) {
564 base.dispose(this.connectedDisposables_); 569 base.dispose(this.connectedDisposables_);
565 this.connectedDisposables_ = null; 570 this.connectedDisposables_ = null;
566 } 571 }
567 572
568 this.notifyStateChanges_(oldState, this.state_); 573 this.notifyStateChanges_(oldState, this.state_);
574 // Record state count in an UMA enumerated histogram.
575 recordState(this.state_);
569 this.logger_.logClientSessionStateChange( 576 this.logger_.logClientSessionStateChange(
570 this.state_, this.error_, this.xmppErrorCache_.getFirstError()); 577 this.state_, this.error_, this.xmppErrorCache_.getFirstError());
571 }; 578 };
572 579
573 /** 580 /**
581 * Records a Chromoting Connection State, stored in an UMA enumerated histogram.
582 * @param {remoting.ClientSession.State} state State identifier.
583 */
584 function recordState(state) {
585 var metricDescription = {
586 metricName: 'Chromoting.Connections',
587 type: 'histogram-linear',
588 min: remoting.ClientSession.State.MIN_STATE_ENUM,
Ilya Sherman 2015/08/21 19:48:29 Hmm, I'm not actually sure whether negative bucket
anandc 2015/08/21 21:30:03 Thanks. Negative values were actually not working
589 max: remoting.ClientSession.State.MAX_STATE_ENUM,
590 // The # of buckets should include 1 for overflow. Use the boundary values
591 // for the ClientSession.State enum to set the # of buckets.
592 buckets: (remoting.ClientSession.State.MAX_STATE_ENUM) -
593 (remoting.ClientSession.State.MIN_STATE_ENUM) + 2
Ilya Sherman 2015/08/21 19:48:29 nit: Is the indentation correct here?
Ilya Sherman 2015/08/21 19:48:29 MAX_STATE_ENUM Is already reserving an extra bucke
anandc 2015/08/21 21:30:03 Done.
anandc 2015/08/21 21:30:03 Thanks for catching. Forgot to update here when ch
594 };
595
596 chrome.metricsPrivate.recordValue(metricDescription, state);
597 }
598
599 /**
574 * @param {remoting.ClientSession.State} oldState The new state for the session. 600 * @param {remoting.ClientSession.State} oldState The new state for the session.
575 * @param {remoting.ClientSession.State} newState The new state for the session. 601 * @param {remoting.ClientSession.State} newState The new state for the session.
576 * @private 602 * @private
577 */ 603 */
578 remoting.ClientSession.prototype.notifyStateChanges_ = 604 remoting.ClientSession.prototype.notifyStateChanges_ =
579 function(oldState, newState) { 605 function(oldState, newState) {
580 /** @type {remoting.Error} */ 606 /** @type {remoting.Error} */
581 var error; 607 var error;
582 switch (this.state_) { 608 switch (this.state_) {
583 case remoting.ClientSession.State.CONNECTED: 609 case remoting.ClientSession.State.CONNECTED:
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 * Enable or disable logging of connection errors due to a host being offline. 686 * Enable or disable logging of connection errors due to a host being offline.
661 * For example, if attempting a connection using a cached JID, host-offline 687 * For example, if attempting a connection using a cached JID, host-offline
662 * errors should not be logged because the JID will be refreshed and the 688 * errors should not be logged because the JID will be refreshed and the
663 * connection retried. 689 * connection retried.
664 * 690 *
665 * @param {boolean} enable True to log host-offline errors; false to suppress. 691 * @param {boolean} enable True to log host-offline errors; false to suppress.
666 */ 692 */
667 remoting.ClientSession.prototype.logHostOfflineErrors = function(enable) { 693 remoting.ClientSession.prototype.logHostOfflineErrors = function(enable) {
668 this.logHostOfflineErrors_ = enable; 694 this.logHostOfflineErrors_ = enable;
669 }; 695 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698