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 /** | 5 /** |
6 * @fileoverview | 6 * @fileoverview |
7 * | 7 * |
8 * In Chrome Apps, some platform APIs can only be called from the background | 8 * In Chrome Apps, some platform APIs can only be called from the background |
9 * page (e.g. reloading a chrome.app.AppWindow). Likewise, some chrome API's | 9 * page (e.g. reloading a chrome.app.AppWindow). Likewise, some chrome API's |
10 * must be initiated by user interaction, which can only be called from the | 10 * must be initiated by user interaction, which can only be called from the |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 'use strict'; | 44 'use strict'; |
45 | 45 |
46 /** | 46 /** |
47 * @constructor | 47 * @constructor |
48 * @private | 48 * @private |
49 */ | 49 */ |
50 base.Ipc = function() { | 50 base.Ipc = function() { |
51 base.debug.assert(instance_ === null); | 51 base.debug.assert(instance_ === null); |
52 /** | 52 /** |
53 * @type {!Object.<Function>} | 53 * @type {!Object<Function>} |
54 * @private | 54 * @private |
55 */ | 55 */ |
56 this.handlers_ = {}; | 56 this.handlers_ = {}; |
57 this.onMessageHandler_ = this.onMessage_.bind(this); | 57 this.onMessageHandler_ = this.onMessage_.bind(this); |
58 chrome.runtime.onMessage.addListener(this.onMessageHandler_); | 58 chrome.runtime.onMessage.addListener(this.onMessageHandler_); |
59 }; | 59 }; |
60 | 60 |
61 /** @private */ | 61 /** @private */ |
62 base.Ipc.prototype.dispose_ = function() { | 62 base.Ipc.prototype.dispose_ = function() { |
63 chrome.runtime.onMessage.removeListener(this.onMessageHandler_); | 63 chrome.runtime.onMessage.removeListener(this.onMessageHandler_); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 }; | 178 }; |
179 | 179 |
180 base.Ipc.deleteInstance = function() { | 180 base.Ipc.deleteInstance = function() { |
181 if (instance_) { | 181 if (instance_) { |
182 instance_.dispose_(); | 182 instance_.dispose_(); |
183 instance_ = null; | 183 instance_ = null; |
184 } | 184 } |
185 }; | 185 }; |
186 | 186 |
187 })(); | 187 })(); |
OLD | NEW |