| OLD | NEW |
| 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 define('keep_alive', [ | 5 define('keep_alive', [ |
| 6 'content/public/renderer/frame_service_registry', | 6 'content/public/renderer/frame_service_registry', |
| 7 'extensions/common/mojo/keep_alive.mojom', | 7 'extensions/common/mojo/keep_alive.mojom', |
| 8 'mojo/public/js/core', | 8 'mojo/public/js/core', |
| 9 ], function(serviceProvider, mojom, core) { | 9 ], function(serviceProvider, mojom, core) { |
| 10 | 10 |
| 11 // Putting the handles somewhere causes them to not get lost. |
| 12 var allHandles = []; |
| 13 |
| 11 /** | 14 /** |
| 12 * An object that keeps the background page alive until closed. | 15 * An object that keeps the background page alive until closed. |
| 13 * @constructor | 16 * @constructor |
| 14 * @alias module:keep_alive~KeepAlive | 17 * @alias module:keep_alive~KeepAlive |
| 15 */ | 18 */ |
| 16 function KeepAlive() { | 19 function KeepAlive() { |
| 17 /** | 20 /** |
| 18 * The handle to the keep-alive object in the browser. | 21 * The handle to the keep-alive object in the browser. |
| 19 * @type {!MojoHandle} | 22 * @type {!MojoHandle} |
| 20 * @private | 23 * @private |
| 21 */ | 24 */ |
| 22 this.handle_ = serviceProvider.connectToService(mojom.KeepAlive.name); | 25 this.handle_ = serviceProvider.connectToService(mojom.KeepAlive.name); |
| 26 allHandles.push(this.handle_); |
| 23 } | 27 } |
| 24 | 28 |
| 25 /** | 29 /** |
| 26 * Removes this keep-alive. | 30 * Removes this keep-alive. |
| 27 */ | 31 */ |
| 28 KeepAlive.prototype.close = function() { | 32 KeepAlive.prototype.close = function() { |
| 29 core.close(this.handle_); | 33 core.close(this.handle_); |
| 30 }; | 34 }; |
| 31 | 35 |
| 32 var exports = {}; | 36 var exports = {}; |
| 33 | 37 |
| 34 return { | 38 return { |
| 35 /** | 39 /** |
| 36 * Creates a keep-alive. | 40 * Creates a keep-alive. |
| 37 * @return {!module:keep_alive~KeepAlive} A new keep-alive. | 41 * @return {!module:keep_alive~KeepAlive} A new keep-alive. |
| 38 */ | 42 */ |
| 39 createKeepAlive: function() { return new KeepAlive(); } | 43 createKeepAlive: function() { return new KeepAlive(); } |
| 40 }; | 44 }; |
| 41 }); | 45 }); |
| OLD | NEW |