2 * Copyright (C) 2011 Samsung Electronics. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
27 #include "WebProcessMainEfl.h"
29 #include "ProxyResolverSoup.h"
32 #include <Ecore_File.h>
33 #include <WebCore/ResourceHandle.h>
34 #include <WebCore/RunLoop.h>
35 #include <WebKit2/WebProcess.h>
36 #include <runtime/InitializeThreading.h>
38 #include <wtf/MainThread.h>
44 #if USE(ACCELERATED_COMPOSITING)
45 #include "WebGraphicsLayer.h"
48 #if ENABLE(TIZEN_NATIVE_MEMORY_SNAPSHOT)
52 #if ENABLE(TIZEN_USE_STACKPOINTER_AT_WEBPROCESS_STARTUP)
53 #include "wtf/WTFThreadData.h"
56 using namespace WebCore;
60 #if ENABLE(TIZEN_NATIVE_MEMORY_SNAPSHOT)
61 void webkit_memory_dump_cb(void* data, Ecore_File_Monitor* monitor, Ecore_File_Event event, const char* path)
63 if (event == ECORE_FILE_EVENT_MODIFIED)
68 WK_EXPORT int WebProcessMainEfl(int argc, char* argv[])
70 // WebProcess should be launched with an option.
78 // Could not init ecore.
83 if (!ecore_x_init(0)) {
84 // Could not init ecore_x.
85 // PlatformScreenEfl and systemBeep() functions
86 // depend on ecore_x functionality.
92 if (!ecore_file_init()) {
99 #if ENABLE(TIZEN_USE_STACKPOINTER_AT_WEBPROCESS_STARTUP)
101 wtfThreadData().setJsStackOrigin(&dummy);
104 #if ENABLE(GLIB_SUPPORT)
107 if (!ecore_main_loop_glib_integrate())
111 JSC::initializeThreading();
112 WTF::initializeMainThread();
114 RunLoop::initializeMainRunLoop();
116 SoupSession* session = WebCore::ResourceHandle::defaultSession();
117 const char* httpProxy = getenv("http_proxy");
119 const char* noProxy = getenv("no_proxy");
120 SoupProxyURIResolver* resolverEfl = soupProxyResolverWkNew(httpProxy, noProxy);
121 soup_session_add_feature(session, SOUP_SESSION_FEATURE(resolverEfl));
122 g_object_unref(resolverEfl);
125 #if ENABLE(TIZEN_NATIVE_MEMORY_SNAPSHOT)
126 const char* isMemorySnapshot = getenv("TIZEN_MEMORY_SNAPSHOT");
127 if (isMemorySnapshot && isMemorySnapshot[0] != '0')
128 ecore_file_monitor_add("/tmp/webkit_memory_dump", webkit_memory_dump_cb, NULL);
131 #if USE(ACCELERATED_COMPOSITING)
132 WebCore::WebGraphicsLayer::initFactory();
135 int socket = atoi(argv[1]);
136 WebProcess::shared().initialize(socket, RunLoop::main());
139 ecore_file_shutdown();
148 } // namespace WebKit