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

Unified 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: Log connection-canceled if the user cancels installation. 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 side-by-side diff with in-line comments
Download patch
Index: remoting/webapp/crd/js/buffered_signal_strategy.js
diff --git a/remoting/webapp/crd/js/buffered_signal_strategy.js b/remoting/webapp/crd/js/buffered_signal_strategy.js
new file mode 100644
index 0000000000000000000000000000000000000000..0dba7b53048536a07b2bf36d5b911e246b0d0b4c
--- /dev/null
+++ b/remoting/webapp/crd/js/buffered_signal_strategy.js
@@ -0,0 +1,107 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+'use strict';
+
+/** @suppress {duplicate} */
+var remoting = remoting || {};
+
+/**
+ * Simplified SignalStrategy implementation that wraps an underlying signal
+ * strategy and forwards messages when it is CONNECTED. It is used only to
+ * log status messages during IT2Me connection setup, and only those methods
+ * required for that are implemented.
+ *
+ * TODO(jamiewalch): Remove this class once a signal strategy is no longer
+ * required for logging (crbug.com/497269).
+ *
+ * @constructor
+ * @param {remoting.SignalStrategy} underlying The underlying implementation.
+ * @implements {remoting.SignalStrategy}
+ */
+remoting.BufferedSignalStrategy = function(underlying) {
+ /** @private */
+ this.underlying_ = underlying;
+ /** @private {Array<string>} */
+ this.pendingMessages_ = [];
+
+ this.underlying_.setStateChangedCallback(this.flush_.bind(this));
+};
+
+remoting.BufferedSignalStrategy.prototype.dispose = function() {
+ this.underlying_.dispose();
+};
+
+/**
+ * Sends a message. Can be called only in CONNECTED state.
+ * @param {string} message
+ */
+remoting.BufferedSignalStrategy.prototype.sendMessage = function(message) {
+ this.pendingMessages_.push(message);
+ this.flush_();
+};
+
+/**
+ * Send any messages accumulated during connection set-up.
+ *
+ * @param {remoting.LogToServer} logToServer The LogToServer instance for the
+ * connection.
+ */
+remoting.BufferedSignalStrategy.prototype.sendConnectionSetupResults =
+ function(logToServer) {
+ this.underlying_.sendConnectionSetupResults(logToServer);
+};
+
+/**
+ * If the underlying implementation is connected, flush all pending messages.
+ * @private
+ */
+remoting.BufferedSignalStrategy.prototype.flush_ = function() {
+ if (this.underlying_.getState() !== remoting.SignalStrategy.State.CONNECTED) {
+ return;
+ }
+ for (var i = 0; i < this.pendingMessages_.length; ++i) {
+ this.underlying_.sendMessage(this.pendingMessages_[i]);
+ }
+ this.pendingMessages_ = [];
+};
+
+
+// The following methods are not used by LogToServer and are not implemented.
+
+remoting.BufferedSignalStrategy.prototype.setStateChangedCallback =
+ function(onStateChangedCallback) {
+ base.debug.assert(false);
+};
+
+remoting.BufferedSignalStrategy.prototype.setIncomingStanzaCallback =
+ function(onIncomingStanzaCallback) {
+ base.debug.assert(false);
+};
+
+remoting.BufferedSignalStrategy.prototype.connect =
+ function(server, username, authToken) {
+ base.debug.assert(false);
+};
+
+remoting.BufferedSignalStrategy.prototype.sendConnectionSetupResults =
+ function(logToServer) {
+ base.debug.assert(false);
+};
+
+remoting.BufferedSignalStrategy.prototype.getState = function() {
+ base.debug.assert(false);
+};
+
+remoting.BufferedSignalStrategy.prototype.getError = function() {
+ base.debug.assert(false);
+};
+
+remoting.BufferedSignalStrategy.prototype.getJid = function() {
+ base.debug.assert(false);
+};
+
+remoting.BufferedSignalStrategy.prototype.getType = function() {
+ base.debug.assert(false);
+};

Powered by Google App Engine
This is Rietveld 408576698