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

Side by Side Diff: remoting/webapp/base/js/xmpp_error_cache.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 5
6 /** @suppress {duplicate} */ 6 /** @suppress {duplicate} */
7 var remoting = remoting || {}; 7 var remoting = remoting || {};
8 8
9 (function() { 9 (function() {
10 10
11 'use strict'; 11 'use strict';
12 12
13 /** 13 /**
14 * This class monitors incoming XMPP stanza and records the first 14 * This class monitors incoming XMPP stanza and records the first
15 * error encountered. It also strips all PII from the error stanza, 15 * error encountered. It also strips all PII from the error stanza,
16 * so that it can be uploaded to the cloud for error analysis. 16 * so that it can be uploaded to the cloud for error analysis.
17 * 17 *
18 * @constructor 18 * @constructor
19 */ 19 */
20 20
21 remoting.XmppErrorCache = function() { 21 remoting.XmppErrorCache = function() {
22 /** @private {remoting.ChromotingEvent.XmppError} */ 22 /** @private {string} */
23 this.firstError_ = null; 23 this.firstErrorStanza_ = '';
kelvinp 2015/11/07 04:44:11 convert to a string so that it can fit in the erro
24 }; 24 };
25 25
26 /** 26 /**
27 * @return {remoting.ChromotingEvent.XmppError} The first XMPP error that the 27 * @return {string} The first XMPP error stanza that the monitor encountered.
28 * monitor encountered. Returns null if no errors have been encountered so 28 * Returns an empty string if no errors have been encountered so far.
29 * far.
30 */ 29 */
31 remoting.XmppErrorCache.prototype.getFirstError = function() { 30 remoting.XmppErrorCache.prototype.getFirstErrorStanza = function() {
32 return this.firstError_; 31 return this.firstErrorStanza_;
33 }; 32 };
34 33
35 /** 34 /**
36 * Monitor the incoming stanza for error. 35 * Monitor the incoming stanza for error.
37 * 36 *
38 * @param {Element} iqNode 37 * @param {Element} iqNode
39 */ 38 */
40 remoting.XmppErrorCache.prototype.processStanza = function(iqNode) { 39 remoting.XmppErrorCache.prototype.processStanza = function(iqNode) {
41 if (this.firstError_ != null) { 40 if (this.firstErrorStanza_ != '') {
42 return; 41 return;
43 } 42 }
44 // The XML structure is as follows: 43 // The XML structure is as follows:
45 // <iq type='error'> 44 // <iq type='error'>
46 // <jingle action='session-accept'/> 45 // <jingle action='session-accept'/>
47 // <error type='modify' code=''/> 46 // <error type='modify' code=''/>
48 // </iq> 47 // </iq>
49 if (iqNode.getAttribute('type') != 'error') { 48 if (iqNode.getAttribute('type') != 'error') {
50 return; 49 return;
51 } 50 }
52 51
53 var strippedStanza = this.stripPII_(iqNode); 52 var strippedStanza = this.stripPII_(iqNode);
54 this.firstError_ = new remoting.ChromotingEvent.XmppError(strippedStanza); 53 this.firstErrorStanza_ = strippedStanza;
55 }; 54 };
56 55
57 /** 56 /**
58 * @param {Element} iqNode 57 * @param {Element} iqNode
59 * @return {string} Return a string representation of |iqNode| with all PII 58 * @return {string} Return a string representation of |iqNode| with all PII
60 * removed. 59 * removed.
61 * @private 60 * @private
62 */ 61 */
63 remoting.XmppErrorCache.prototype.stripPII_ = function(iqNode) { 62 remoting.XmppErrorCache.prototype.stripPII_ = function(iqNode) {
64 var parser = new DOMParser(); 63 var parser = new DOMParser();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 var children = node.children; 130 var children = node.children;
132 for (i = 0; i < children.length; i++) { 131 for (i = 0; i < children.length; i++) {
133 var child = /** @type{Element}*/ (children[i]); 132 var child = /** @type{Element}*/ (children[i]);
134 var childCopy = outNode.ownerDocument.createElement(child.tagName); 133 var childCopy = outNode.ownerDocument.createElement(child.tagName);
135 outNode.appendChild(childCopy); 134 outNode.appendChild(childCopy);
136 stripPII(child, childCopy); 135 stripPII(child, childCopy);
137 } 136 }
138 } 137 }
139 138
140 })(); 139 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698