Refactor call of terminator 93/110793/5
authorYoungsoo Choi <kenshin.choi@samsung.com>
Wed, 18 Jan 2017 05:29:29 +0000 (14:29 +0900)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Wed, 18 Jan 2017 06:12:45 +0000 (15:12 +0900)
The terminator has been registered by Runtime.
It makes a dependency from WebApplication to Runtime and does not assure
the existence of the Runtime instance.

Bug: DF170116-01203
Url: http://suprem.sec.samsung.net/jira/browse/TWF-2805

Change-Id: I700bddab8fb392dca131ab5d3a913ed63e45b792
Signed-off-by: Youngsoo Choi <kenshin.choi@samsung.com>
runtime/browser/ui_runtime.cc
runtime/browser/watch_runtime.cc
runtime/browser/web_application.cc
runtime/browser/web_application.h

index 41fa8d9..7a6188f 100755 (executable)
@@ -107,10 +107,7 @@ void UiRuntime::ResetWebApplication(NativeWindow::Type windowType) {
                                         app_data_,
                                         context_));
   LOGGER(DEBUG) << "runtime.cc created web application";
-  application_->set_terminator([](){ ui_app_exit(); });
-
   LOGGER(DEBUG) << "runtime.cc ResetWebApplication() finished";
-
   STEP_PROFILE_END("Runtime ResetWebApplication");
 }
 
index f166e72..4ec298b 100644 (file)
@@ -90,7 +90,6 @@ bool WatchRuntime::OnCreate() {
   STEP_PROFILE_START("WebApplication Create");
   application_ = new WebApplication(native_window_, app_data_);
   STEP_PROFILE_END("WebApplication Create");
-  application_->set_terminator([](){ watch_app_exit(); });
 
   setlocale(LC_ALL, "");
   bindtextdomain(kTextDomainRuntime, kTextLocalePath);
index dd6383e..5ffaa5c 100755 (executable)
@@ -301,8 +301,7 @@ WebApplication::WebApplication(
       window_(window),
       appid_(app_data->app_id()),
       app_data_(app_data),
-      locale_manager_(new common::LocaleManager()),
-      terminator_(NULL) {
+      locale_manager_(new common::LocaleManager()) {
   Initialize();
 }
 
@@ -320,8 +319,7 @@ WebApplication::WebApplication(
       window_(window),
       appid_(app_data->app_id()),
       app_data_(app_data),
-      locale_manager_(new common::LocaleManager()),
-      terminator_(NULL) {
+      locale_manager_(new common::LocaleManager()) {
   Initialize();
 }
 
@@ -706,12 +704,20 @@ void WebApplication::Exit() {
   if (!is_terminate_called_)
     ecore_main_loop_quit();
 
-  if (terminator_) {
-    LOGGER(DEBUG) << "terminator_";
-    terminator_();
-  } else {
-    LOGGER(ERROR) << "There's no registered terminator.";
-    elm_exit();
+  switch (app_data_->app_type()) {
+    case common::ApplicationData::AppType::UI:
+      LOGGER(ERROR) << "app_ui_exit";
+      ui_app_exit();
+      break;
+#ifdef WATCH_FACE_FEATURE_SUPPORT
+    case common::ApplicationData::AppType::WATCH:
+      LOGGER(ERROR) << "watch_ui_exit";
+      watch_app_exit();
+      break;
+#endif
+    default:
+      LOGGER(ERROR) << "default terminator";
+      elm_exit();
   }
 }
 
index f35fd04..20d9082 100755 (executable)
@@ -57,9 +57,6 @@ class WebApplication : public WebView::EventListener {
   void ProcessClosingPage();
 
   std::string data_path() const { return app_data_path_; }
-  void set_terminator(std::function<void(void)> terminator) {
-    terminator_ = terminator;
-  }
   bool launched() const { return launched_; }
   std::list<WebView*> view_stack() const { return view_stack_; }
 
@@ -152,7 +149,6 @@ class WebApplication : public WebView::EventListener {
   std::unique_ptr<SplashScreen> splash_screen_;
   std::unique_ptr<common::LocaleManager> locale_manager_;
   std::unique_ptr<common::ResourceManager> resource_manager_;
-  std::function<void(void)> terminator_;
   int security_model_version_;
   std::string csp_rule_;
   std::string csp_report_rule_;