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

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

Issue 1410563006: [Chromoting] SessionLogger refactor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 /** @suppress {duplicate} */ 5 /** @suppress {duplicate} */
6 var remoting = remoting || {}; 6 var remoting = remoting || {};
7 7
8 (function() { 8 (function() {
9 9
10 'use strict'; 10 'use strict';
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 function(listener, logger) { 45 function(listener, logger) {
46 var that = this; 46 var that = this;
47 /** @type {string} */ 47 /** @type {string} */
48 var token; 48 var token;
49 /** @type {remoting.SignalStrategy} */ 49 /** @type {remoting.SignalStrategy} */
50 var signalStrategy; 50 var signalStrategy;
51 /** @type {remoting.ClientPlugin} */ 51 /** @type {remoting.ClientPlugin} */
52 var clientPlugin; 52 var clientPlugin;
53 53
54 function OnError(/** !remoting.Error */ error) { 54 function OnError(/** !remoting.Error */ error) {
55 logError(logger, error); 55 logger.logSessionStateChange(
56 remoting.ChromotingEvent.SessionState.CONNECTION_FAILED, error);
56 base.dispose(signalStrategy); 57 base.dispose(signalStrategy);
57 base.dispose(clientPlugin); 58 base.dispose(clientPlugin);
58 throw error; 59 throw error;
59 } 60 }
60 61
61 var promise = remoting.identity.getToken().then( 62 var promise = remoting.identity.getToken().then(
62 function(/** string */ authToken) { 63 function(/** string */ authToken) {
63 token = authToken; 64 token = authToken;
64 return remoting.identity.getUserInfo(); 65 return remoting.identity.getUserInfo();
65 }).then(function(/** {email: string, name: string} */ userInfo) { 66 }).then(function(/** {email: string, name: string} */ userInfo) {
66 logger.logSessionStateChange( 67 logger.logSessionStateChange(
67 remoting.ChromotingEvent.SessionState.SIGNALING, 68 remoting.ChromotingEvent.SessionState.SIGNALING);
68 remoting.ChromotingEvent.ConnectionError.NONE);
69 return connectSignaling(userInfo.email, token); 69 return connectSignaling(userInfo.email, token);
70 }).then(function(/** remoting.SignalStrategy */ strategy) { 70 }).then(function(/** remoting.SignalStrategy */ strategy) {
71 signalStrategy = strategy; 71 signalStrategy = strategy;
72 logger.logSessionStateChange( 72 logger.logSessionStateChange(
73 remoting.ChromotingEvent.SessionState.CREATING_PLUGIN, 73 remoting.ChromotingEvent.SessionState.CREATING_PLUGIN);
74 remoting.ChromotingEvent.ConnectionError.NONE);
75 return createPlugin(that.container_, that.requiredCapabilities_); 74 return createPlugin(that.container_, that.requiredCapabilities_);
76 }).then(function(/** remoting.ClientPlugin */ plugin) { 75 }).then(function(/** remoting.ClientPlugin */ plugin) {
77 clientPlugin = plugin; 76 clientPlugin = plugin;
78 return new remoting.ClientSession(plugin, signalStrategy, logger, listener); 77 return new remoting.ClientSession(plugin, signalStrategy, logger, listener);
79 }).catch( 78 }).catch(
80 remoting.Error.handler(OnError) 79 remoting.Error.handler(OnError)
81 ); 80 );
82 81
83 return /** @type {Promise<!remoting.ClientSession>} */ (promise); 82 return /** @type {Promise<!remoting.ClientSession>} */ (promise);
84 }; 83 };
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 * @return {Promise<!remoting.ClientPlugin>} 116 * @return {Promise<!remoting.ClientPlugin>}
118 */ 117 */
119 function createPlugin(container, capabilities) { 118 function createPlugin(container, capabilities) {
120 var plugin = remoting.ClientPlugin.factory.createPlugin( 119 var plugin = remoting.ClientPlugin.factory.createPlugin(
121 container, capabilities); 120 container, capabilities);
122 return plugin.initialize().then(function() { 121 return plugin.initialize().then(function() {
123 return plugin; 122 return plugin;
124 }); 123 });
125 } 124 }
126 125
127 /**
128 * Converts |e| to remoting.ChromotingEvent.ConnectionError and logs
129 * it to the telemetry service.
130 *
131 * TODO(kelvinp): Move this block to remoting.SessionLogger and consolidate
132 * the code path with xmpp_error.
133 *
134 * @param {remoting.SessionLogger} logger
135 * @param {remoting.Error} e
136 */
137 function logError(logger, e) {
138 var error = remoting.ChromotingEvent.ConnectionError.UNEXPECTED;
139
140 if (e instanceof remoting.Error) {
141 error = e.toConnectionError();
142
143 if (e.hasTag(remoting.Error.Tag.MISSING_PLUGIN)) {
144 var pluginError = /** @type {string} */ (e.getDetail());
145 console.assert(Boolean(pluginError), 'Missing plugin error string.');
146 logger.setPluginError(pluginError);
Jamie 2015/11/09 18:46:02 Don't you want to associate the pluginError with t
kelvinp 2015/11/09 22:59:10 It is now set in |detail| when the error is first
Jamie 2015/11/09 23:23:09 I don't see that in this CL. Was it duplicated log
kelvinp 2015/11/10 00:02:44 Yup, it is implemented in the previous CL. https:
147 }
148 }
149
150 logger.logSessionStateChange(
151 remoting.ChromotingEvent.SessionState.CONNECTION_FAILED, error);
152 }
153
154 })(); 126 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698