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

Side by Side Diff: mojo/public/bindings/js/connection.js

Issue 207503004: Mojo: add javascript bindings for request/response (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: --similarity=15 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « mojo/public/bindings/js/codec.js ('k') | mojo/public/bindings/js/connector.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 timers = new (function() { 5 define("mojo/public/bindings/js/connection", [
6 "mojo/public/bindings/js/router",
7 ], function(router) {
6 8
7 this.timers_ = {}; 9 function Connection(handle, localFactory, remoteFactory) {
10 this.router_ = new router.Router(handle);
11 this.remote = new remoteFactory(this.router_);
12 this.local = new localFactory(this.remote);
13 this.router_.setIncomingReceiver(this.local);
14 }
8 15
9 this.start = function(name, callback, intervalSeconds) { 16 Connection.prototype.close = function() {
10 this.stop(name); 17 this.router_.close();
11 18 this.router_ = null;
12 var timerId = setInterval(callback, intervalSeconds * 1000); 19 this.local = null;
13 20 this.remote = null;
14 this.timers_[name] = {
15 name: name,
16 callback: callback,
17 timerId: timerId,
18 intervalSeconds: intervalSeconds
19 }; 21 };
20 22
21 callback(); 23 Connection.prototype.encounteredError = function() {
22 }; 24 return this.router_.encounteredError();
25 };
23 26
24 this.stop = function(name) { 27 var exports = {};
25 if (name in this.timers_) { 28 exports.Connection = Connection;
26 clearInterval(this.timers_[name].timerId); 29 return exports;
27 delete this.timers_[name]; 30 });
28 }
29 };
30
31 this.stopAll = function() {
32 for (var name in this.timers_) {
33 clearInterval(this.timers_[name].timerId);
34 }
35 this.timers_ = {};
36 };
37
38 })();
OLDNEW
« no previous file with comments | « mojo/public/bindings/js/codec.js ('k') | mojo/public/bindings/js/connector.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698