2 * Copyright (C) 2010 Apple Inc. 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.
29 #include "CacheModel.h"
30 #include "ChildProcess.h"
31 #include "DrawingArea.h"
32 #include "EventDispatcher.h"
33 #include "PluginInfoStore.h"
34 #include "ResourceCachesToClear.h"
35 #include "SandboxExtension.h"
36 #include "SharedMemory.h"
37 #include "TextCheckerState.h"
38 #include "VisitedLinkTable.h"
39 #include "WebConnectionToUIProcess.h"
40 #include "WebGeolocationManager.h"
41 #include "WebIconDatabaseProxy.h"
42 #include "WebPageGroupProxy.h"
43 #include <WebCore/LinkHash.h>
44 #include <wtf/Forward.h>
45 #include <wtf/HashMap.h>
46 #include <wtf/HashSet.h>
49 #include "WebSoupRequestManager.h"
54 class QNetworkAccessManager;
59 #include <dispatch/dispatch.h>
62 #if ENABLE(BATTERY_STATUS)
63 #include "WebBatteryManager.h"
66 #if ENABLE(NETWORK_INFO)
67 #include "WebNetworkInfoManager.h"
70 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
71 #include "WebNotificationManager.h"
74 #if ENABLE(PLUGIN_PROCESS)
75 #include "PluginProcessConnectionManager.h"
81 class ResourceRequest;
82 class ResourceResponse;
90 struct WebPageCreationParameters;
91 struct WebPageGroupData;
92 struct WebPreferencesStore;
93 struct WebProcessCreationParameters;
95 #if USE(SECURITY_FRAMEWORK)
96 class SecItemResponseData;
97 class SecKeychainItemResponseData;
100 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
101 class PlatformSurfacePoolEfl;
104 class WebProcess : public ChildProcess, private CoreIPC::Connection::QueueClient {
106 static WebProcess& shared();
108 void initialize(CoreIPC::Connection::Identifier, WebCore::RunLoop*);
110 CoreIPC::Connection* connection() const { return m_connection->connection(); }
111 WebCore::RunLoop* runLoop() const { return m_runLoop; }
113 WebConnectionToUIProcess* webConnectionToUIProcess() const { return m_connection.get(); }
115 WebPage* webPage(uint64_t pageID) const;
116 void createWebPage(uint64_t pageID, const WebPageCreationParameters&);
117 void removeWebPage(uint64_t pageID);
118 WebPage* focusedWebPage() const;
120 InjectedBundle* injectedBundle() const { return m_injectedBundle.get(); }
122 bool isSeparateProcess() const;
125 void initializeShim();
127 #if USE(ACCELERATED_COMPOSITING)
128 mach_port_t compositingRenderServerPort() const { return m_compositingRenderServerPort; }
132 void setShouldTrackVisitedLinks(bool);
133 void addVisitedLink(WebCore::LinkHash);
134 bool isLinkVisited(WebCore::LinkHash) const;
136 bool fullKeyboardAccessEnabled() const { return m_fullKeyboardAccessEnabled; }
138 WebFrame* webFrame(uint64_t) const;
139 void addWebFrame(uint64_t, WebFrame*);
140 void removeWebFrame(uint64_t);
142 WebPageGroupProxy* webPageGroup(uint64_t pageGroupID);
143 WebPageGroupProxy* webPageGroup(const WebPageGroupData&);
145 pid_t presenterApplicationPid() const { return m_presenterApplicationPid; }
149 QNetworkAccessManager* networkAccessManager() { return m_networkAccessManager; }
152 bool shouldUseCustomRepresentationForResponse(const WebCore::ResourceResponse&) const;
155 const TextCheckerState& textCheckerState() const { return m_textCheckerState; }
158 WebGeolocationManager& geolocationManager() { return m_geolocationManager; }
160 #if ENABLE(BATTERY_STATUS)
161 WebBatteryManager& batteryManager() { return m_batteryManager; }
164 #if ENABLE(NETWORK_INFO)
165 WebNetworkInfoManager& networkInfoManager() { return m_networkInfoManager; }
168 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
169 WebNotificationManager& notificationManager() { return m_notificationManager; }
172 void clearResourceCaches(ResourceCachesToClear = AllResourceCaches);
173 #if ENABLE(TIZEN_CACHE_DUMP_SYNC)
174 void dumpResourceCaches();
175 void platformDumpResourceCaches();
178 const String& localStorageDirectory() const { return m_localStorageDirectory; }
180 #if ENABLE(PLUGIN_PROCESS)
181 PluginProcessConnectionManager& pluginProcessConnectionManager() { return m_pluginProcessConnectionManager; }
182 bool disablePluginProcessMessageTimeout() const { return m_disablePluginProcessMessageTimeout; }
185 EventDispatcher& eventDispatcher() { return m_eventDispatcher; }
188 WebSoupRequestManager& soupRequestManager() { return m_soupRequestManager; }
191 #if ENABLE(TIZEN_RECORDING_SURFACE_PAINT_THREAD)
192 WorkQueue* paintThreadWorkQueue() const { return m_paintThreadWorkQueue; }
195 #if ENABLE(TIZEN_WEBKIT2_PROXY)
196 void setProxy(const String& proxyAddress);
198 #if ENABLE(TIZEN_SESSION_REQUEST_CANCEL)
202 #if ENABLE(TIZEN_CERTIFICATE_HANDLING)
203 void setCertificateFile(const String&);
206 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
207 PlatformSurfacePoolEfl* platformSurfacePool() { return m_platformSurfacePool.get(); }
208 void removePlatformSurfaceFromPool(int platformSurfaceId);
211 #if ENABLE(TIZEN_INDEXED_DATABASE)
212 const String& indexedDatabaseDirectory() const { return m_indexedDatabaseDirectory; }
215 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
216 class WaitForJavaScriptPopupFinished {
218 WaitForJavaScriptPopupFinished();
219 ~WaitForJavaScriptPopupFinished();
221 bool isWaitingForJavaScriptPopupFinished();
224 #if ENABLE(TIZEN_WEBKIT2_MEMORY_SAVING_MODE)
225 void setMemorySavingMode(bool);
226 bool memorySavingModeEnabled() { return m_memorySavingModeEnabled; }
229 #if ENABLE(TIZEN_WEBKIT2_CONTEXT_X_WINDOW)
230 void setXWindow(unsigned);
233 #if ENABLE(TIZEN_EXTENSIBLE_API)
234 void setTizenExtensibleAPI(int extensibleAPI, bool enable);
237 #if ENABLE(TIZEN_RESET_PATH)
238 void resetStoragePath();
244 void initializeWebProcess(const WebProcessCreationParameters&, CoreIPC::ArgumentDecoder*);
245 void platformInitializeWebProcess(const WebProcessCreationParameters&, CoreIPC::ArgumentDecoder*);
246 void platformTerminate();
247 void registerURLSchemeAsEmptyDocument(const String&);
248 void registerURLSchemeAsSecure(const String&) const;
249 void setDomainRelaxationForbiddenForURLScheme(const String&) const;
250 void setDefaultRequestTimeoutInterval(double);
251 void setAlwaysUsesComplexTextCodePath(bool);
252 void setShouldUseFontSmoothing(bool);
253 void userPreferredLanguagesChanged(const Vector<String>&) const;
254 void fullKeyboardAccessModeChanged(bool fullKeyboardAccessEnabled);
256 void setShouldPaintNativeControls(bool);
259 void setVisitedLinkTable(const SharedMemory::Handle&);
260 void visitedLinkStateChanged(const Vector<WebCore::LinkHash>& linkHashes);
261 void allVisitedLinkStateChanged();
263 void setCacheModel(uint32_t);
264 void platformSetCacheModel(CacheModel);
265 #if ENABLE(TIZEN_CACHE_CONTROL)
266 void setCacheDisabled(bool);
267 void platformSetCacheDisabled(bool);
269 static void calculateCacheSizes(CacheModel cacheModel, uint64_t memorySize, uint64_t diskFreeSize,
270 unsigned& cacheTotalCapacity, unsigned& cacheMinDeadCapacity, unsigned& cacheMaxDeadCapacity, double& deadDecodedDataDeletionInterval,
271 unsigned& pageCacheCapacity, unsigned long& urlCacheMemoryCapacity, unsigned long& urlCacheDiskCapacity);
272 void platformClearResourceCaches(ResourceCachesToClear);
273 void clearApplicationCache();
275 void setEnhancedAccessibility(bool);
277 #if !ENABLE(PLUGIN_PROCESS)
278 void getSitesWithPluginData(const Vector<String>& pluginPaths, uint64_t callbackID);
279 void clearPluginSiteData(const Vector<String>& pluginPaths, const Vector<String>& sites, uint64_t flags, uint64_t maxAgeInSeconds, uint64_t callbackID);
282 #if ENABLE(PLUGIN_PROCESS)
283 void pluginProcessCrashed(CoreIPC::Connection*, const String& pluginPath);
286 void startMemorySampler(const SandboxExtension::Handle&, const String&, const double);
287 void stopMemorySampler();
289 void downloadRequest(uint64_t downloadID, uint64_t initiatingPageID, const WebCore::ResourceRequest&);
290 void cancelDownload(uint64_t downloadID);
292 void startTransfer(uint64_t downloadID, const String& destination);
295 void setTextCheckerState(const TextCheckerState&);
297 void getWebCoreStatistics(uint64_t callbackID);
298 void garbageCollectJavaScriptObjects();
299 void setJavaScriptGarbageCollectorTimerEnabled(bool flag);
301 #if USE(SECURITY_FRAMEWORK)
302 void secItemResponse(CoreIPC::Connection*, uint64_t requestID, const SecItemResponseData&);
303 void secKeychainItemResponse(CoreIPC::Connection*, uint64_t requestID, const SecKeychainItemResponseData&);
307 virtual bool shouldTerminate();
308 virtual void terminate();
310 // CoreIPC::Connection::Client
311 friend class WebConnectionToUIProcess;
312 virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
313 virtual void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&);
314 virtual void didClose(CoreIPC::Connection*);
315 virtual void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID);
316 virtual void syncMessageSendTimedOut(CoreIPC::Connection*);
318 virtual Vector<HWND> windowsToReceiveSentMessagesWhileWaitingForSyncReply();
321 // CoreIPC::Connection::QueueClient
322 virtual void didReceiveMessageOnConnectionWorkQueue(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, bool& didHandleMessage) OVERRIDE;
324 // Implemented in generated WebProcessMessageReceiver.cpp
325 void didReceiveWebProcessMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
326 void didReceiveWebProcessMessageOnConnectionWorkQueue(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, bool& didHandleMessage);
328 void didGetPlugins(CoreIPC::Connection*, uint64_t requestID, const Vector<WebCore::PluginInfo>&);
330 RefPtr<WebConnectionToUIProcess> m_connection;
332 HashMap<uint64_t, RefPtr<WebPage> > m_pageMap;
333 HashMap<uint64_t, RefPtr<WebPageGroupProxy> > m_pageGroupMap;
334 RefPtr<InjectedBundle> m_injectedBundle;
336 EventDispatcher m_eventDispatcher;
340 WebCore::RunLoop* m_runLoop;
342 // FIXME: The visited link table should not be per process.
343 VisitedLinkTable m_visitedLinkTable;
344 bool m_shouldTrackVisitedLinks;
346 bool m_hasSetCacheModel;
347 CacheModel m_cacheModel;
349 #if USE(ACCELERATED_COMPOSITING) && PLATFORM(MAC)
350 mach_port_t m_compositingRenderServerPort;
353 pid_t m_presenterApplicationPid;
354 dispatch_group_t m_clearResourceCachesDispatchGroup;
357 bool m_fullKeyboardAccessEnabled;
360 QNetworkAccessManager* m_networkAccessManager;
363 #if ENABLE(TIZEN_RECORDING_SURFACE_PAINT_THREAD)
364 WorkQueue* m_paintThreadWorkQueue;
366 HashMap<uint64_t, WebFrame*> m_frameMap;
368 HashSet<String, CaseFoldingHash> m_mimeTypesWithCustomRepresentations;
370 TextCheckerState m_textCheckerState;
371 WebGeolocationManager m_geolocationManager;
372 #if ENABLE(BATTERY_STATUS)
373 WebBatteryManager m_batteryManager;
375 #if ENABLE(NETWORK_INFO)
376 WebNetworkInfoManager m_networkInfoManager;
378 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
379 WebNotificationManager m_notificationManager;
381 WebIconDatabaseProxy m_iconDatabaseProxy;
383 String m_localStorageDirectory;
385 RefPtr<SandboxExtension> m_applicationCachePathExtension;
387 #if ENABLE(PLUGIN_PROCESS)
388 PluginProcessConnectionManager m_pluginProcessConnectionManager;
389 bool m_disablePluginProcessMessageTimeout;
391 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
392 OwnPtr<PlatformSurfacePoolEfl> m_platformSurfacePool;
395 #if ENABLE(TIZEN_INDEXED_DATABASE)
396 String m_indexedDatabaseDirectory;
400 WebSoupRequestManager m_soupRequestManager;
403 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
404 int m_isWaitingForJavaScriptPopupCount;
407 #if ENABLE(TIZEN_WEBKIT2_MEMORY_SAVING_MODE)
408 bool m_memorySavingModeEnabled;
412 } // namespace WebKit
414 #endif // WebProcess_h