}
void ImeRuntime::OnTerminate() {
+}
+
+void ImeRuntime::Terminate() {
LOGGER(DEBUG) << "ime_app_terminate";
- ClosePageFromOnTerminate(application_);
+ ProcessClosingPage(application_);
}
void ImeRuntime::OnShow(int context_id, ime_context_h context) {
virtual void OnHide(int context_id);
virtual void OnAppControl();
+ virtual void Terminate();
private:
WebApplication* application_;
NativeWindow* native_window_;
#include "common/application_data.h"
#include "common/command_line.h"
+#include "common/logger.h"
#include "runtime/common/constants.h"
#include "runtime/browser/runtime.h"
#include "runtime/browser/ui_runtime.h"
#include "runtime/browser/watch_runtime.h"
#endif // WATCH_FACE_FEATURE_SUPPORT
+#define MAIN_LOOP_INTERVAL 1
+
namespace runtime {
Runtime::~Runtime() {
}
}
-void Runtime::ClosePageFromOnTerminate(WebApplication* app) {
- if (app)
- app->ClosePageFromOnTerminate();
+// static
+Eina_Bool Runtime::ClosePageInExtendedMainLoop(void* user_data)
+{
+ LOGGER(DEBUG);
+ struct Timer* main_loop = static_cast<Timer*>(user_data);
+ main_loop->application->ClosePage();
+ return ECORE_CALLBACK_CANCEL;
+}
+
+void Runtime::ProcessClosingPage(WebApplication* application) {
+ LOGGER(DEBUG);
+ if (application) {
+ struct Timer main_loop;
+ main_loop.application = application;
+ main_loop.timer = ecore_timer_add(MAIN_LOOP_INTERVAL, ClosePageInExtendedMainLoop, &main_loop);
+ LOGGER(DEBUG) << "Defer termination of main loop";
+ ecore_main_loop_begin();
+ ecore_timer_del(main_loop.timer);
+ }
}
} // namespace runtime
class Runtime {
public:
virtual ~Runtime() = 0;
+ virtual void Terminate() = 0;
virtual int Exec(int argc, char* argv[]) = 0;
common::ApplicationData* app_data);
protected:
- void ClosePageFromOnTerminate(WebApplication* app);
+ void ProcessClosingPage(WebApplication* application);
+
+ private:
+ static Eina_Bool ClosePageInExtendedMainLoop(void* user_data);
+ struct Timer
+ {
+ WebApplication* application;
+ Ecore_Timer* timer;
+ };
};
} // namespace runtime
#endif // WATCH_FACE_FEATURE_SUPPORT
}
- int ret = 0;
// Runtime's destructor should be called before ewk_shutdown()
{
std::unique_ptr<runtime::Runtime> runtime =
runtime::Runtime::MakeRuntime(appdata);
- ret = runtime->Exec(argc, argv);
- if (ret)
+ if (runtime->Exec(argc, argv))
LOGGER(ERROR) << "Exec returns non zero.";
- LOGGER(DEBUG) << "plugin_session_count : " <<
- XWalkExtensionRendererController::plugin_session_count;
- if (XWalkExtensionRendererController::plugin_session_count > 0) {
- LOGGER(DEBUG) << "Defer termination of main loop";
- ecore_main_loop_begin();
- }
+ runtime->Terminate();
runtime.reset();
}
LOGGER(DEBUG) << "ewk_shutdown";
}
void UiRuntime::OnTerminate() {
- ClosePageFromOnTerminate(application_.get());
+}
+
+void UiRuntime::Terminate() {
+ LOGGER(DEBUG);
+ ProcessClosingPage(application_.get());
}
void UiRuntime::OnPause() {
virtual void OnAppControl(app_control_h app_control);
virtual void OnLanguageChanged(const std::string& language);
virtual void OnLowMemory();
+ virtual void Terminate();
private:
void ResetWebApplication(NativeWindow::Type windowType);
}
void WatchRuntime::OnTerminate() {
- ClosePageFromOnTerminate(application_);
+}
+
+void WatchRuntime::Terminate() {
+ ProcessClosingPage(application_);
}
void WatchRuntime::OnPause() {
virtual void OnAmbientTick(watch_time_h watch_time);
virtual void OnAmbientChanged(bool ambient_mode);
+ virtual void Terminate();
private:
WebApplication* application_;
NativeWindow* native_window_;
extension_server->Shutdown();
}
-void WebApplication::ClosePageFromOnTerminate() {
+void WebApplication::ClosePage() {
LOGGER(DEBUG);
+ int valid_evas_object_count = 0;
auto it = view_stack_.begin();
if (it != view_stack_.end()) {
for (; it != view_stack_.end(); ++it) {
(*it)->ReplyToJavascriptDialog();
view_stack_.front()->SetVisibility(false);
- LOGGER(DEBUG) << "ewk_view_page_close";
- ewk_view_page_close((*it)->evas_object());
+ if (ewk_view_page_close((*it)->evas_object())) {
+ LOGGER(DEBUG) << "ewk_view_page_close returns true";
+ valid_evas_object_count++;
+ } else {
+ LOGGER(DEBUG) << "ewk_view_page_close returns false";
+ }
+ }
+ }
+ 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();
+ }
}
}
}
LOGGER(DEBUG) << "plugin_session_count : " <<
XWalkExtensionRendererController::plugin_session_count;
- if (XWalkExtensionRendererController::plugin_session_count > 0) {
- timeout_id = ecore_timer_add(TIMER_INTERVAL, CheckPluginSession, this);
- if (!timeout_id)
- LOGGER(ERROR) << "It's failed to create timer";
- }
+ if (!ecore_timer_add(TIMER_INTERVAL, CheckPluginSession, this))
+ LOGGER(ERROR) << "It's failed to create timer";
}
void WebApplication::OnReceivedWrtMessage(WebView* view,
void Suspend();
void Terminate();
- void ClosePageFromOnTerminate();
+ void ClosePage();
std::string data_path() const { return app_data_path_; }
void set_terminator(std::function<void(void)> terminator) {
terminator_ = terminator;
auto close_callback = [](void* user_data,
Evas_Object*,
void*) {
+ LOGGER(DEBUG) << "close_callback is called";
WebViewImpl* self = static_cast<WebViewImpl*>(user_data);
if (!self->listener_) {
return;