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 #if ENABLE(TIZEN_PROCESS_PERMISSION_CONTROL)
57 #include "ProcessSmackLabel.h"
60 using namespace WebCore;
64 #if ENABLE(TIZEN_NATIVE_MEMORY_SNAPSHOT)
65 void webkit_memory_dump_cb(void* data, Ecore_File_Monitor* monitor, Ecore_File_Event event, const char* path)
67 if (event == ECORE_FILE_EVENT_MODIFIED)
72 WK_EXPORT int WebProcessMainEfl(int argc, char* argv[])
74 // WebProcess should be launched with an option.
78 #if ENABLE(TIZEN_PROCESS_PERMISSION_CONTROL)
79 // change process smack label
80 if (!changeProcessSmackLabel("/usr/bin/WebProcess", argv[0])) {
81 TIZEN_LOGI("failed to change smack label");
84 // drop CAP_MAC_ADMIN capability
85 if (!dropProcessCapability()) {
86 TIZEN_LOGI("failed to drop CAP_MAC_ADMIN");
95 // Could not init ecore.
100 if (!ecore_x_init(0)) {
101 // Could not init ecore_x.
102 // PlatformScreenEfl and systemBeep() functions
103 // depend on ecore_x functionality.
109 if (!ecore_file_init()) {
116 #if ENABLE(TIZEN_USE_STACKPOINTER_AT_WEBPROCESS_STARTUP)
118 wtfThreadData().setJsStackOrigin(&dummy);
121 #if ENABLE(GLIB_SUPPORT)
124 if (!ecore_main_loop_glib_integrate())
128 JSC::initializeThreading();
129 WTF::initializeMainThread();
131 RunLoop::initializeMainRunLoop();
133 SoupSession* session = WebCore::ResourceHandle::defaultSession();
134 const char* httpProxy = getenv("http_proxy");
136 const char* noProxy = getenv("no_proxy");
137 SoupProxyURIResolver* resolverEfl = soupProxyResolverWkNew(httpProxy, noProxy);
138 soup_session_add_feature(session, SOUP_SESSION_FEATURE(resolverEfl));
139 g_object_unref(resolverEfl);
142 #if ENABLE(TIZEN_NATIVE_MEMORY_SNAPSHOT)
143 const char* isMemorySnapshot = getenv("TIZEN_MEMORY_SNAPSHOT");
144 if (isMemorySnapshot && isMemorySnapshot[0] != '0')
145 ecore_file_monitor_add("/tmp/webkit_memory_dump", webkit_memory_dump_cb, NULL);
148 #if USE(ACCELERATED_COMPOSITING)
149 WebCore::WebGraphicsLayer::initFactory();
152 int socket = atoi(argv[1]);
153 WebProcess::shared().initialize(socket, RunLoop::main());
156 ecore_file_shutdown();
165 } // namespace WebKit