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

Unified Diff: mojo/public/bindings/js/connection.js

Issue 216443002: Reland: Mojo: add javascript bindings for request/response (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disable WebUIMojoTest.EndToEnd Created 6 years, 9 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: mojo/public/bindings/js/connection.js
diff --git a/tools/memory_inspector/memory_inspector/frontends/www_content/js/timers.js b/mojo/public/bindings/js/connection.js
similarity index 20%
copy from tools/memory_inspector/memory_inspector/frontends/www_content/js/timers.js
copy to mojo/public/bindings/js/connection.js
index b26955780033c94b881d3416215a3fd5d565cf6b..96c7419decb9771ac8f34f1af95bcc906b346086 100644
--- a/tools/memory_inspector/memory_inspector/frontends/www_content/js/timers.js
+++ b/mojo/public/bindings/js/connection.js
@@ -2,37 +2,29 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-timers = new (function() {
-
-this.timers_ = {};
-
-this.start = function(name, callback, intervalSeconds) {
- this.stop(name);
-
- var timerId = setInterval(callback, intervalSeconds * 1000);
+define("mojo/public/bindings/js/connection", [
+ "mojo/public/bindings/js/router",
+], function(router) {
+
+ function Connection(handle, localFactory, remoteFactory) {
+ this.router_ = new router.Router(handle);
+ this.remote = new remoteFactory(this.router_);
+ this.local = new localFactory(this.remote);
+ this.router_.setIncomingReceiver(this.local);
+ }
- this.timers_[name] = {
- name: name,
- callback: callback,
- timerId: timerId,
- intervalSeconds: intervalSeconds
+ Connection.prototype.close = function() {
+ this.router_.close();
+ this.router_ = null;
+ this.local = null;
+ this.remote = null;
};
- callback();
-};
-
-this.stop = function(name) {
- if (name in this.timers_) {
- clearInterval(this.timers_[name].timerId);
- delete this.timers_[name];
- }
-};
-
-this.stopAll = function() {
- for (var name in this.timers_) {
- clearInterval(this.timers_[name].timerId);
- }
- this.timers_ = {};
-};
+ Connection.prototype.encounteredError = function() {
+ return this.router_.encounteredError();
+ };
-})();
+ var exports = {};
+ exports.Connection = Connection;
+ return exports;
+});

Powered by Google App Engine
This is Rietveld 408576698