Index: remoting/webapp/background/background.js |
diff --git a/remoting/webapp/background/background.js b/remoting/webapp/background/background.js |
index 5f2678898e2a13f6e782b0c85e16586463091920..28c20105185d94023b38e20f430d55109a010f91 100644 |
--- a/remoting/webapp/background/background.js |
+++ b/remoting/webapp/background/background.js |
@@ -43,6 +43,29 @@ function initializeAppV2(appLauncher) { |
); |
} |
+/** |
+ * The background service is responsible for listening to incoming connection |
+ * requests from Hangouts and the webapp. |
+ * |
+ * @param {remoting.AppLauncher} appLauncher |
+ */ |
+function initializeBackgroundService(appLauncher) { |
+ function initializeIt2MeService() { |
+ /** @type {remoting.It2MeService} */ |
+ remoting.it2meService = new remoting.It2MeService(appLauncher); |
+ remoting.it2meService.init(); |
+ } |
+ |
+ chrome.runtime.onSuspend.addListener(function() { |
+ base.debug.assert(remoting.it2meService != null); |
+ remoting.it2meService.dispose(); |
+ remoting.it2meService = null; |
+ }); |
+ |
+ chrome.runtime.onSuspendCanceled.addListener(initializeIt2MeService); |
+ initializeIt2MeService(); |
+} |
+ |
function main() { |
/** @type {remoting.AppLauncher} */ |
var appLauncher = new remoting.V1AppLauncher(); |
@@ -50,6 +73,7 @@ function main() { |
appLauncher = new remoting.V2AppLauncher(); |
initializeAppV2(appLauncher); |
} |
+ initializeBackgroundService(appLauncher); |
} |
window.addEventListener('load', main, false); |