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

Unified Diff: remoting/webapp/me2mom/log_to_server.js

Issue 8527011: The chromoting client sends simple logging to the server. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review. Created 9 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 side-by-side diff with in-line comments
Download patch
Index: remoting/webapp/me2mom/log_to_server.js
diff --git a/remoting/webapp/me2mom/log_to_server.js b/remoting/webapp/me2mom/log_to_server.js
new file mode 100644
index 0000000000000000000000000000000000000000..e65260b4ccbf7402ddf45e68e8d5e05d5640baea
--- /dev/null
+++ b/remoting/webapp/me2mom/log_to_server.js
@@ -0,0 +1,60 @@
+// Copyright (c) 2011 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.
+
+/**
+ * @fileoverview
+ * Module for sending log entries to the server.
+ */
+
+'use strict';
+
+/** @suppress {duplicate} */
+var remoting = remoting || {};
+
+/**
+ * @constructor
+ */
+remoting.LogToServer = function() {
+ /** @type Array.<string> */ this.pendingEntries = [];
+};
+
+/**
+ * Logs a client session state change.
+ *
+ * @param {remoting.ClientSession.State} state
+ * @param {remoting.ClientSession.ConnectionError} connectionError
+ */
+remoting.LogToServer.prototype.logClientSessionStateChange =
+ function(state, connectionError) {
+ var entry = remoting.ServerLogEntry.prototype.makeClientSessionStateChange(
Jamie 2011/11/11 19:08:40 If this is effectively a static function, there's
+ state, connectionError);
+ entry.addHostFields();
+ entry.addChromeVersionField();
+ entry.addWebappVersionField();
+ this.log(entry);
+};
+
+/**
+ * Sends a log entry to the server.
+ *
+ * @private
+ * @param {remoting.ServerLogEntry} entry
+ */
+remoting.LogToServer.prototype.log = function(entry) {
+ // Store a stanza for the entry
+ this.pendingEntries.push(entry.toStanza());
+ // Stop if there's no connection to the server.
+ if (!remoting.wcs) {
+ return;
+ }
+ // Send all pending entries to the server.
+ var stanza = '<cli:iq to="remoting@bot.talk.google.com" type="set" ' +
+ 'xmlns:cli="jabber:client"><gr:log xmlns:gr="google:remoting">';
+ while (this.pendingEntries.length > 0) {
+ stanza += /** @type string */ this.pendingEntries.shift();
+ }
+ stanza += '</gr:log></cli:iq>';
+ remoting.debug.logIq(true, stanza);
+ remoting.wcs.sendIq(stanza);
+};

Powered by Google App Engine
This is Rietveld 408576698