Remove unnecessary event handling during termination 98/209198/2
authorSangYong Park <sy302.park@samsung.com>
Wed, 3 Jul 2019 09:32:50 +0000 (18:32 +0900)
committerSangYong Park <sy302.park@samsung.com>
Thu, 11 Jul 2019 02:48:04 +0000 (11:48 +0900)
Add code for preventing unnecessary event handling. and remove unusing code.

Change-Id: I48ea7e9f6b36fe0eb0c19fb49a4ec4a10363e795
Signed-off-by: SangYong Park <sy302.park@samsung.com>
wrt_app/src/runtime.js
wrt_app/src/web_application.js

index 36e0eb1..ac408d2 100644 (file)
@@ -48,11 +48,12 @@ class Runtime {
                         }, timeout, null);
                 }
             }
+            _this.webApplication.finalize();
+            _this.webApplication = null;
         });
         app.on('will-quit', function(event) {
             console.log('will-quit');
             _this.addonManager.deactivateAll(app);
-            _this.killAllProcesses();
         });
         app.on('quit', function(event) {
             console.log('quit');
@@ -173,20 +174,14 @@ class Runtime {
         });
         wrt.on('suspend', function() {
             console.log('suspend');
-            _this.webApplication.suspend(_this.addonManager.suspend_path);
+            if (_this.webApplication)
+                _this.webApplication.suspend(_this.addonManager.suspend_path);
         });
         wrt.on('resume', function() {
             console.log('resume');
             _this.webApplication.resume(_this.addonManager.resume_path);
         });
-        wrt.on('terminate', function() {
-            console.log('terminate');
-            _this.webApplication.terminate();
-        });
     }
-    onLanguageChanged() {}
-    onLowMemory() {}
-    killAllProcesses() {}
     handleIpcMessages() {
         var _this = this;
         ipcMain.on(IPC_MESSAGE.ADDONS.INSTALLED, (sender, name) => {
index 3b0f964..65aa1da 100755 (executable)
@@ -43,7 +43,6 @@ class WebApplication {
         }
         this.accessiblePath = wrt.getAccessiblePath();
         this.isAlwaysReload = wrt.isAlwaysReload();
-        this.isTerminating = false;
         this.suspended = true;
         this.loadFinished = false;
         this.runningStatus = 'none';
@@ -62,7 +61,7 @@ class WebApplication {
                 console.log(`window closed : #${self.windowList.length}`);
                 let index = self.windowList.indexOf(window);
                 self.windowList.splice(index, 1);
-                if (!self.isTerminating && index === self.windowList.length && self.windowList.length > 0)
+                if (index === self.windowList.length && self.windowList.length > 0)
                     self.windowList[self.windowList.length - 1].show();
             });
         });
@@ -256,11 +255,6 @@ class WebApplication {
             }
         }
         this.suspended = true;
-        if (this.isTerminating) {
-            console.log('App has been terminated; return');
-            return;
-        }
-        let windows = WRTWindow.getAllWindows();
         if (this.isTVProfile) {
             wrt.flushCookie();
             this.windowList.forEach((window) => window.webContents.session.flushStorageData());
@@ -272,7 +266,7 @@ class WebApplication {
                 app.quit();
             }, 1000);
         } else if (!this.backgroundSupport) {
-            windows.forEach((window) => window.setEnabled(false));
+            this.windowList.forEach((window) => window.setEnabled(false));
         }
         this.windowList[this.windowList.length - 1].hide();
     }
@@ -293,14 +287,15 @@ class WebApplication {
             }
             return;
         }
-        WRTWindow.getAllWindows().forEach((window) => {
-            if (!this.backgroundSupport)
-                window.setEnabled(true);
-        });
+        if (!this.backgroundSupport) {
+            this.windowList.forEach((window) => window.setEnabled(true));
+        }
         this.windowList[this.windowList.length - 1].show();
     }
-    terminate() {
-        this.isTerminating = true;
+    finalize() {
+        this.windowList.forEach((window) => {
+            window.removeAllListeners();
+        });
     }
     quit(path) {
        console.log('WebApplication : quit');
@@ -343,7 +338,7 @@ class WebApplication {
         }
     }
     closeWindows() {
-        WRTWindow.getAllWindows().forEach((window) => {
+        this.windowList.forEach((window) => {
             if (window != this.mainWindow)
                 window.destroy();
         });