#error INJECTED_BUNDLE_PATH is not set.
#endif
-#define TIMER_INTERVAL 0.1
+#define SESSION_COUNTER_INTERVAL 0.1
+#define MAIN_LOOP_INTERVAL 1
using namespace extensions;
void WebApplication::Terminate() {
is_terminate_called_ = true;
- if (terminator_) {
- LOGGER(DEBUG) << "terminator_";
- terminator_();
- } else {
- LOGGER(ERROR) << "There's no registered terminator.";
- elm_exit();
- }
- auto extension_server = extensions::XWalkExtensionServer::GetInstance();
- LOGGER(DEBUG) << "Shutdown extension server";
- extension_server->Shutdown();
+ ClosePage();
+}
+
+// static
+Eina_Bool WebApplication::ClosePageInExtendedMainLoop(void* user_data)
+{
+ LOGGER(DEBUG);
+ struct Timer* main_loop = static_cast<Timer*>(user_data);
+ main_loop->application->ClosePage();
+ return ECORE_CALLBACK_CANCEL;
+}
+
+void WebApplication::ProcessClosingPage() {
+ LOGGER(DEBUG);
+
+ main_loop.application = this;
+ main_loop.timer = ecore_timer_add(MAIN_LOOP_INTERVAL,
+ ClosePageInExtendedMainLoop, &main_loop);
+ if (!main_loop.timer)
+ LOGGER(ERROR) << "It's failed to create main_loop timer";
+ LOGGER(DEBUG) << "Defer termination of main loop";
+ ecore_main_loop_begin();
+ ecore_timer_del(main_loop.timer);
+ ecore_timer_del(session_counter.timer);
}
void WebApplication::ClosePage() {
LOGGER(DEBUG);
+
int valid_evas_object_count = 0;
auto it = view_stack_.begin();
if (it != view_stack_.end()) {
}
}
}
- if (valid_evas_object_count == 0) {
- if (is_terminate_called_) {
- ecore_main_loop_quit();
- } else {
- if (terminator_) {
- LOGGER(DEBUG) << "terminator_";
- terminator_();
- } else {
- LOGGER(ERROR) << "There's no registered terminator.";
- elm_exit();
- }
- }
+ if (valid_evas_object_count == 0)
+ Exit();
+}
+
+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();
}
}
}
if (view_stack_.size() == 0) {
- // If |Terminate()| hasn't been called,
- // main loop shouldn't be terminated here.
- if (!is_terminate_called_) {
- auto extension_server = XWalkExtensionServer::GetInstance();
- LOGGER(DEBUG) << "Shutdown extension server";
- extension_server->Shutdown();
- }
+ auto extension_server = XWalkExtensionServer::GetInstance();
+ LOGGER(DEBUG) << "Shutdown extension server";
+ extension_server->Shutdown();
} else if (current != view_stack_.front()) {
view_stack_.front()->SetVisibility(true);
window_->SetContent(view_stack_.front()->evas_object());
Eina_Bool WebApplication::CheckPluginSession(void* user_data)
{
- WebApplication* that = static_cast<WebApplication*>(user_data);
+ struct Timer* session_counter = static_cast<Timer*>(user_data);
if(XWalkExtensionRendererController::plugin_session_count > 0) {
LOGGER(ERROR) << "plugin_session_count : " <<
XWalkExtensionRendererController::plugin_session_count;
LOGGER(DEBUG) << "plugin_session_count : " <<
XWalkExtensionRendererController::plugin_session_count;
LOGGER(DEBUG) << "Execute deferred termination of main loop";
- if (that->is_terminate_called_) {
- ecore_main_loop_quit();
- } else {
- if (that->terminator_) {
- LOGGER(DEBUG) << "terminator_";
- that->terminator_();
- } else {
- LOGGER(ERROR) << "There's no registered terminator.";
- elm_exit();
- }
- }
+ session_counter->application->Exit();
return ECORE_CALLBACK_CANCEL;
}
void WebApplication::OnClosedWebView(WebView* view) {
- Ecore_Timer* timeout_id = NULL;
// Reply to javascript dialog for preventing freeze issue.
view->ReplyToJavascriptDialog();
RemoveWebViewFromStack(view);
LOGGER(DEBUG) << "plugin_session_count : " <<
XWalkExtensionRendererController::plugin_session_count;
- if (!ecore_timer_add(TIMER_INTERVAL, CheckPluginSession, this))
- LOGGER(ERROR) << "It's failed to create timer";
+ session_counter.application = this;
+ session_counter.timer = ecore_timer_add(SESSION_COUNTER_INTERVAL,
+ CheckPluginSession, &session_counter);
+ if (!session_counter.timer)
+ LOGGER(ERROR) << "It's failed to create session_counter timer";
}
void WebApplication::OnReceivedWrtMessage(WebView* view,