* limitations under the License.
*/
#include "wrt-client.h"
+#include <aul.h>
+#include <sys/time.h>
+#include <sys/resource.h>
#include <appcore-efl.h>
#include <appcore-common.h>
#include <cstdlib>
#include <dpl/localization/LanguageTagsProvider.h>
#include "webkit/bundles/plugin_module_support.h"
+#include "process_pool.h"
+#include "menu_db_util.h"
+#include "launchpad_util.h"
+
//W3C PACKAGING enviroment variable name
#define W3C_DEBUG_ENV_VARIABLE "DEBUG_LOAD_FINISH"
char const* const ELM_SWALLOW_CONTENT = "elm.swallow.content";
const char* const BUNDLE_PATH = "/usr/lib/wrt-wk2-bundles/libwrt-wk2-bundle.so";
-static Ewk_Context* s_ewk_context = NULL;
+// process pool
+const char* const DUMMY_PROCESS_PATH = "/usr/bin/wrt_launchpad_daemon_candidate";
+static Ewk_Context* s_preparedEwkContext = NULL;
+static WindowData* s_preparedWindowData = NULL;
+static int app_argc = 0;
+static char** app_argv = NULL;
WrtClient::WrtClient(int argc, char **argv) :
Application(argc, argv, "wrt-client", false),
// languageChangedCallback, this);
ADD_PROFILING_POINT("CreateWindow", "start");
- m_windowData.reset(new WindowData(static_cast<unsigned long>(getpid()),
- true));
+ if (s_preparedWindowData == NULL)
+ {
+ m_windowData.reset(new WindowData(static_cast<unsigned long>(getpid()), true));
+ }
+ else
+ {
+ m_windowData.reset(s_preparedWindowData);
+ s_preparedWindowData = NULL;
+ }
ADD_PROFILING_POINT("CreateWindow", "stop");
WRT::UserDelegatesPtr cbs(new WRT::UserDelegates);
ADD_PROFILING_POINT("Create splash screen", "stop");
DPL::OptionalString startUrl = W3CFileLocalization::getStartFile(m_dao);
if (!m_widget->PrepareView(DPL::ToUTF8String(*startUrl),
- m_windowData->m_win, s_ewk_context))
+ m_windowData->m_win, s_preparedEwkContext))
{
DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
NextStepEvent());
m_widget->SetUserDelegates(cbs);
m_widget->Show();
+
m_windowData->emitSignalForUserLayout(EDJE_SHOW_BACKWARD_SIGNAL, "");
+
ADD_PROFILING_POINT("launchStep", "stop");
}
m_widgetState = WidgetState_Stopped;
m_widget->Hide();
m_widget.reset();
- ewk_context_delete(s_ewk_context);
+ ewk_context_delete(s_preparedEwkContext);
WRT::CoreModuleSingleton::Instance().Terminate();
}
if (m_initialized) {
DPL::Application::Quit();
}
+static Eina_Bool proces_pool_fd_handler(void* /*data*/, Ecore_Fd_Handler *handler)
+{
+ int fd = ecore_main_fd_handler_fd_get(handler);
+
+ if (ecore_main_fd_handler_active_get(handler, ECORE_FD_ERROR))
+ {
+ LogDebug("ECORE_FD_ERROR");
+ close(fd);
+ exit(-1);
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ if (ecore_main_fd_handler_active_get(handler, ECORE_FD_READ))
+ {
+ LogDebug("ECORE_FD_READ");
+ {
+ app_pkt_t* pkt = (app_pkt_t*) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
+ memset(pkt, 0, AUL_SOCK_MAXBUFF);
+
+ int recv_ret = recv(fd, pkt, AUL_SOCK_MAXBUFF, 0);
+
+ close(fd);
+
+ if (recv_ret == -1)
+ {
+ LogDebug("recv error!");
+ exit(-1);
+ }
+ LogDebug("recv_ret : " << recv_ret << ", pkt->len : " << pkt->len);
+
+ ecore_main_fd_handler_del(handler);
+
+ __wrt_launchpad_main_loop(pkt, app_argv[0], &app_argc, &app_argv);
+
+ free(pkt);
+ }
+
+ ecore_main_loop_quit();
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+void set_env()
+{
+ // set evas backend type
+ if (!getenv("ELM_ENGINE"))
+ {
+ if (!setenv("ELM_ENGINE", "gl", 1))
+ {
+ LogDebug("Enable backend");
+ }
+ }
+ else
+ {
+ LogDebug("ELM_ENGINE : " << getenv("ELM_ENGINE"));
+ }
+
+#ifndef TIZEN_PUBLIC
+ setenv("COREGL_FASTPATH", "1", 1);
+#endif
+ setenv("CAIRO_GL_COMPOSITOR", "msaa", 1);
+ setenv("CAIRO_GL_LAZY_FLUSHING", "yes", 1);
+ setenv("ELM_IMAGE_CACHE", "0", 1);
+}
+
+
int main(int argc,
char *argv[])
{
+ // process pool - store arg's value
+ app_argc = argc;
+ app_argv = argv;
+
UNHANDLED_EXCEPTION_HANDLER_BEGIN
{
ADD_PROFILING_POINT("main-entered", "point");
// Set log tagging
DPL::Log::LogSystemSingleton::Instance().SetTag("WRT");
- // set evas backend type
- if (!getenv("ELM_ENGINE")) {
- if (!setenv("ELM_ENGINE", "gl", 1)) {
- LogDebug("Enable backend");
- }
- } else {
- LogDebug("ELM_ENGINE : " << getenv("ELM_ENGINE"));
- }
-
- #ifndef TIZEN_PUBLIC
- setenv("COREGL_FASTPATH", "1", 1);
- #endif
- setenv("CAIRO_GL_COMPOSITOR", "msaa", 1);
- setenv("CAIRO_GL_LAZY_FLUSHING", "yes", 1);
- setenv("ELM_IMAGE_CACHE", "0", 1);
+ // Set environment variables
+ set_env();
- // This code is to fork a web process without exec.
- std::string tizenId = WrtClient::getTizenIdFromArgument(argc, argv);
+ if (argc > 1 && argv[1] != NULL && !strcmp(argv[1], "-d"))
+ {
+ LogInfo("Entered dummy process mode");
+ sprintf(argv[0], "%s ",
+ DUMMY_PROCESS_PATH);
- if (!tizenId.empty()) {
- LogDebug("Launching by fork mode");
- // Language env setup
+ LogInfo("Prepare ewk_context");
appcore_set_i18n("wrt-client", NULL);
ewk_init();
ewk_set_arguments(argc, argv);
setenv("WRT_LAUNCHING_PERFORMANCE", "1", 1);
- s_ewk_context = ewk_context_new_with_injected_bundle_path(
- BUNDLE_PATH);
+ s_preparedEwkContext = ewk_context_new_with_injected_bundle_path(BUNDLE_PATH);
+
+ int client_fd = __connect_process_pool_server();
+
+ if (client_fd == -1)
+ {
+ LogInfo("Connecting process_pool_server was failed!");
+ exit(-1);
+ }
+
+ LogInfo("Prepare window_data");
+ LogInfo("elm_init()");
+ elm_init(argc, argv);
+ LogInfo("WindowData()");
+ s_preparedWindowData = new WindowData(static_cast<unsigned long>(getpid()));
- // plugin init
- PluginModuleSupport::init(s_ewk_context, tizenId);
+ ecore_main_fd_handler_add(client_fd, ECORE_FD_READ, proces_pool_fd_handler, NULL, NULL, NULL);
+ ecore_main_fd_handler_add(client_fd, ECORE_FD_ERROR, proces_pool_fd_handler, NULL, NULL, NULL);
+
+ setpriority(PRIO_PROCESS, 0, 0);
+
+ LogDebug("ecore_main_loop_begin()");
+ ecore_main_loop_begin();
+ LogDebug("ecore_main_loop_begin()_end");
+
+ std::string tizenId = WrtClient::getTizenIdFromArgument(argc, argv);
+ PluginModuleSupport::init(s_preparedEwkContext, tizenId);
+
+ }
+ else
+ {
+ // This code is to fork a web process without exec.
+ std::string tizenId = WrtClient::getTizenIdFromArgument(argc, argv);
+
+ if (!tizenId.empty())
+ {
+ LogDebug("Launching by fork mode");
+ // Language env setup
+ appcore_set_i18n("wrt-client", NULL);
+ ewk_init();
+ ewk_set_arguments(argc, argv);
+ setenv("WRT_LAUNCHING_PERFORMANCE", "1", 1);
+ s_preparedEwkContext = ewk_context_new_with_injected_bundle_path(
+ BUNDLE_PATH);
+
+ // plugin init
+ PluginModuleSupport::init(s_preparedEwkContext, tizenId);
+ }
}
// Output on stdout will be flushed after every newline character,
// the output may not be flushed).
setlinebuf(stdout);
- WrtClient app(argc, argv);
+ WrtClient app(app_argc, app_argv);
ADD_PROFILING_POINT("Before appExec", "point");
int ret = app.Exec();