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

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: Rebase. 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
« no previous file with comments | « remoting/compile_js.gypi ('k') | remoting/webapp/js_proto/chrome_mocks.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 128
129 // Note that the positive values in both of these enums are copied directly 129 // Note that the positive values in both of these enums are copied directly
130 // from connection_to_host.h and must be kept in sync. Code in 130 // from connection_to_host.h and must be kept in sync. Code in
131 // chromoting_instance.cc converts the C++ enums into strings that must match 131 // chromoting_instance.cc converts the C++ enums into strings that must match
132 // the names given here. 132 // the names given here.
133 // The negative values represent state transitions that occur within the 133 // The negative values represent state transitions that occur within the
134 // web-app that have no corresponding plugin state transition. 134 // web-app that have no corresponding plugin state transition.
135 // 135 //
136 // TODO(kelvinp): Merge this enum with remoting.ChromotingEvent.SessionState 136 // TODO(kelvinp): Merge this enum with remoting.ChromotingEvent.SessionState
137 // once we have migrated away from XMPP-based logging (crbug.com/523423). 137 // once we have migrated away from XMPP-based logging (crbug.com/523423).
138 // NOTE: The enums here correspond to the Chromoting.Connections enumerated
139 // histogram defined in src/tools/metrics/histograms/histograms.xml. UMA
140 // histograms don't work well with negative values, so only non-negative values
141 // have been used for Chromoting.Connections.
142 // The maximum values for the UMA enumerated histogram is included here for use
143 // when uploading values to UMA.
144 // The 2 lists should be kept in sync, and any new enums should be append-only.
138 /** @enum {number} */ 145 /** @enum {number} */
139 remoting.ClientSession.State = { 146 remoting.ClientSession.State = {
147 MIN_STATE_ENUM: -3,
140 CONNECTION_CANCELED: -3, // Connection closed (gracefully) before connecting. 148 CONNECTION_CANCELED: -3, // Connection closed (gracefully) before connecting.
141 CONNECTION_DROPPED: -2, // Succeeded, but subsequently closed with an error. 149 CONNECTION_DROPPED: -2, // Succeeded, but subsequently closed with an error.
142 CREATED: -1, 150 CREATED: -1,
143 UNKNOWN: 0, 151 UNKNOWN: 0,
144 INITIALIZING: 1, 152 INITIALIZING: 1,
145 CONNECTING: 2, 153 CONNECTING: 2,
146 AUTHENTICATED: 3, 154 AUTHENTICATED: 3,
147 CONNECTED: 4, 155 CONNECTED: 4,
148 CLOSED: 5, 156 CLOSED: 5,
149 FAILED: 6 157 FAILED: 6,
158 MAX_STATE_ENUM: 6,
150 }; 159 };
151 160
152 /** 161 /**
153 * @param {string} state The state name. 162 * @param {string} state The state name.
154 * @return {remoting.ClientSession.State} The session state enum value. 163 * @return {remoting.ClientSession.State} The session state enum value.
155 */ 164 */
156 remoting.ClientSession.State.fromString = function(state) { 165 remoting.ClientSession.State.fromString = function(state) {
157 if (!remoting.ClientSession.State.hasOwnProperty(state)) { 166 if (!remoting.ClientSession.State.hasOwnProperty(state)) {
158 throw "Invalid ClientSession.State: " + state; 167 throw "Invalid ClientSession.State: " + state;
159 } 168 }
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 if (this.plugin_.hasCapability( 544 if (this.plugin_.hasCapability(
536 remoting.ClientSession.Capability.TOUCH_EVENTS)) { 545 remoting.ClientSession.Capability.TOUCH_EVENTS)) {
537 this.plugin_.enableTouchEvents(true); 546 this.plugin_.enableTouchEvents(true);
538 } 547 }
539 } else if (this.isFinished()) { 548 } else if (this.isFinished()) {
540 base.dispose(this.connectedDisposables_); 549 base.dispose(this.connectedDisposables_);
541 this.connectedDisposables_ = null; 550 this.connectedDisposables_ = null;
542 } 551 }
543 552
544 this.notifyStateChanges_(oldState, this.state_); 553 this.notifyStateChanges_(oldState, this.state_);
554 // Record state count in an UMA enumerated histogram.
555 recordState(this.state_);
545 this.logger_.logClientSessionStateChange( 556 this.logger_.logClientSessionStateChange(
546 this.state_, this.error_, this.xmppErrorCache_.getFirstError()); 557 this.state_, this.error_, this.xmppErrorCache_.getFirstError());
547 }; 558 };
548 559
549 /** 560 /**
561 * Records a Chromoting Connection State, stored in an UMA enumerated histogram.
562 * @param {remoting.ClientSession.State} state State identifier.
563 */
564 function recordState(state) {
565 // According to src/base/metrics/histogram.h, for a UMA enumerated histogram,
566 // the upper limit should be 1 above the max-enum. Because SessionState's
567 // minimum enum value is negative, we'll just take the difference of the max
568 // and min enums.
569 var histogram_max = (remoting.ClientSession.State.MAX_STATE_ENUM -
570 remoting.ClientSession.State.MIN_STATE_ENUM);
Ilya Sherman 2015/08/25 01:34:25 I'm pretty sure you're missing a "+1" in this comp
571
572 var metricDescription = {
573 metricName: 'Chromoting.Connections',
574 type: 'histogram-linear',
575 // According to histogram.h, minimum should be 1. Values less than minimum
576 // end up in the 0th bucket.
577 min: 1,
578 max: histogram_max,
579 // The # of buckets should include 1 for underflow.
580 buckets: histogram_max + 1
581 };
582
583 chrome.metricsPrivate.recordValue(metricDescription, state -
584 remoting.ClientSession.State.MIN_STATE_ENUM);
585 }
586
587 /**
550 * @param {remoting.ClientSession.State} oldState The new state for the session. 588 * @param {remoting.ClientSession.State} oldState The new state for the session.
551 * @param {remoting.ClientSession.State} newState The new state for the session. 589 * @param {remoting.ClientSession.State} newState The new state for the session.
552 * @private 590 * @private
553 */ 591 */
554 remoting.ClientSession.prototype.notifyStateChanges_ = 592 remoting.ClientSession.prototype.notifyStateChanges_ =
555 function(oldState, newState) { 593 function(oldState, newState) {
556 /** @type {remoting.Error} */ 594 /** @type {remoting.Error} */
557 var error; 595 var error;
558 switch (this.state_) { 596 switch (this.state_) {
559 case remoting.ClientSession.State.CONNECTED: 597 case remoting.ClientSession.State.CONNECTED:
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 } else if (previous == State.CONNECTED && current == State.FAILED) { 655 } else if (previous == State.CONNECTED && current == State.FAILED) {
618 return State.CONNECTION_DROPPED; 656 return State.CONNECTION_DROPPED;
619 } 657 }
620 return current; 658 return current;
621 }; 659 };
622 660
623 /** @private */ 661 /** @private */
624 remoting.ClientSession.prototype.reportStatistics = function() { 662 remoting.ClientSession.prototype.reportStatistics = function() {
625 this.logger_.logStatistics(this.plugin_.getPerfStats()); 663 this.logger_.logStatistics(this.plugin_.getPerfStats());
626 }; 664 };
OLDNEW
« no previous file with comments | « remoting/compile_js.gypi ('k') | remoting/webapp/js_proto/chrome_mocks.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698