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

Side by Side Diff: remoting/webapp/crd/js/buffered_signal_strategy.js

Issue 1176693002: Add more host-side connection state logging for IT2Me. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reviewer feedback. Created 5 years, 6 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/webapp/base/js/server_log_entry.js ('k') | remoting/webapp/crd/js/host_controller.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 'use strict';
6
7 /** @suppress {duplicate} */
8 var remoting = remoting || {};
9
10 /**
11 * Simplified SignalStrategy implementation that wraps an underlying signal
12 * strategy and forwards messages when it is CONNECTED. It is used only to
13 * log status messages during IT2Me connection setup, and only those methods
14 * required for that are implemented.
15 *
16 * TODO(jamiewalch): Remove this class once a signal strategy is no longer
17 * required for logging (crbug.com/497269).
18 *
19 * @constructor
20 * @param {remoting.SignalStrategy} underlying The underlying implementation.
21 * @implements {remoting.SignalStrategy}
22 */
23 remoting.BufferedSignalStrategy = function(underlying) {
24 /** @private */
25 this.underlying_ = underlying;
26 /** @private {Array<string>} */
27 this.pendingMessages_ = [];
28
29 this.underlying_.setStateChangedCallback(this.flush_.bind(this));
30 };
31
32 remoting.BufferedSignalStrategy.prototype.dispose = function() {
33 this.underlying_.dispose();
34 };
35
36 /**
37 * Sends a message. Can be called only in CONNECTED state.
38 * @param {string} message
39 */
40 remoting.BufferedSignalStrategy.prototype.sendMessage = function(message) {
41 this.pendingMessages_.push(message);
42 this.flush_();
43 };
44
45 /**
46 * Send any messages accumulated during connection set-up.
47 *
48 * @param {remoting.LogToServer} logToServer The LogToServer instance for the
49 * connection.
50 */
51 remoting.BufferedSignalStrategy.prototype.sendConnectionSetupResults =
52 function(logToServer) {
53 this.underlying_.sendConnectionSetupResults(logToServer);
54 };
55
56 /**
57 * If the underlying implementation is connected, flush all pending messages.
58 * @private
59 */
60 remoting.BufferedSignalStrategy.prototype.flush_ = function() {
61 if (this.underlying_.getState() !== remoting.SignalStrategy.State.CONNECTED) {
62 return;
63 }
64 for (var i = 0; i < this.pendingMessages_.length; ++i) {
65 this.underlying_.sendMessage(this.pendingMessages_[i]);
66 }
67 this.pendingMessages_ = [];
68 };
69
70
71 // The following methods are not used by LogToServer and are not implemented.
72
73 remoting.BufferedSignalStrategy.prototype.setStateChangedCallback =
74 function(onStateChangedCallback) {
75 base.debug.assert(false);
76 };
77
78 remoting.BufferedSignalStrategy.prototype.setIncomingStanzaCallback =
79 function(onIncomingStanzaCallback) {
80 base.debug.assert(false);
81 };
82
83 remoting.BufferedSignalStrategy.prototype.connect =
84 function(server, username, authToken) {
85 base.debug.assert(false);
86 };
87
88 remoting.BufferedSignalStrategy.prototype.sendConnectionSetupResults =
89 function(logToServer) {
90 base.debug.assert(false);
91 };
92
93 remoting.BufferedSignalStrategy.prototype.getState = function() {
94 base.debug.assert(false);
95 };
96
97 remoting.BufferedSignalStrategy.prototype.getError = function() {
98 base.debug.assert(false);
99 };
100
101 remoting.BufferedSignalStrategy.prototype.getJid = function() {
102 base.debug.assert(false);
103 };
104
105 remoting.BufferedSignalStrategy.prototype.getType = function() {
106 base.debug.assert(false);
107 };
OLDNEW
« no previous file with comments | « remoting/webapp/base/js/server_log_entry.js ('k') | remoting/webapp/crd/js/host_controller.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698