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 PlatformSurfacePoolTizen;
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_SOUP_CACHE_DIRECTORY_SET)
192 void setSoupDataDirectory(const String& soupDataDirectory);
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 PlatformSurfacePoolTizen* 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();
241 #if ENABLE(TIZEN_INDEXED_DATABASE)
242 void deleteIndexedDatabaseAll();
248 void initializeWebProcess(const WebProcessCreationParameters&, CoreIPC::ArgumentDecoder*);
249 void platformInitializeWebProcess(const WebProcessCreationParameters&, CoreIPC::ArgumentDecoder*);
250 void platformTerminate();
251 void registerURLSchemeAsEmptyDocument(const String&);
252 void registerURLSchemeAsSecure(const String&) const;
253 void setDomainRelaxationForbiddenForURLScheme(const String&) const;
254 void setDefaultRequestTimeoutInterval(double);
255 void setAlwaysUsesComplexTextCodePath(bool);
256 void setShouldUseFontSmoothing(bool);
257 void userPreferredLanguagesChanged(const Vector<String>&) const;
258 void fullKeyboardAccessModeChanged(bool fullKeyboardAccessEnabled);
260 void setShouldPaintNativeControls(bool);
263 void setVisitedLinkTable(const SharedMemory::Handle&);
264 void visitedLinkStateChanged(const Vector<WebCore::LinkHash>& linkHashes);
265 void allVisitedLinkStateChanged();
267 void setCacheModel(uint32_t);
268 void platformSetCacheModel(CacheModel);
269 #if ENABLE(TIZEN_CACHE_CONTROL)
270 void setCacheDisabled(bool);
271 void platformSetCacheDisabled(bool);
273 static void calculateCacheSizes(CacheModel cacheModel, uint64_t memorySize, uint64_t diskFreeSize,
274 unsigned& cacheTotalCapacity, unsigned& cacheMinDeadCapacity, unsigned& cacheMaxDeadCapacity, double& deadDecodedDataDeletionInterval,
275 unsigned& pageCacheCapacity, unsigned long& urlCacheMemoryCapacity, unsigned long& urlCacheDiskCapacity);
276 void platformClearResourceCaches(ResourceCachesToClear);
277 void clearApplicationCache();
279 void setEnhancedAccessibility(bool);
281 #if !ENABLE(PLUGIN_PROCESS)
282 void getSitesWithPluginData(const Vector<String>& pluginPaths, uint64_t callbackID);
283 void clearPluginSiteData(const Vector<String>& pluginPaths, const Vector<String>& sites, uint64_t flags, uint64_t maxAgeInSeconds, uint64_t callbackID);
286 #if ENABLE(PLUGIN_PROCESS)
287 void pluginProcessCrashed(CoreIPC::Connection*, const String& pluginPath);
290 void startMemorySampler(const SandboxExtension::Handle&, const String&, const double);
291 void stopMemorySampler();
293 void downloadRequest(uint64_t downloadID, uint64_t initiatingPageID, const WebCore::ResourceRequest&);
294 void cancelDownload(uint64_t downloadID);
296 void startTransfer(uint64_t downloadID, const String& destination);
299 void setTextCheckerState(const TextCheckerState&);
301 void getWebCoreStatistics(uint64_t callbackID);
302 void garbageCollectJavaScriptObjects();
303 void setJavaScriptGarbageCollectorTimerEnabled(bool flag);
305 #if USE(SECURITY_FRAMEWORK)
306 void secItemResponse(CoreIPC::Connection*, uint64_t requestID, const SecItemResponseData&);
307 void secKeychainItemResponse(CoreIPC::Connection*, uint64_t requestID, const SecKeychainItemResponseData&);
311 virtual bool shouldTerminate();
312 virtual void terminate();
314 // CoreIPC::Connection::Client
315 friend class WebConnectionToUIProcess;
316 virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
317 virtual void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&);
318 virtual void didClose(CoreIPC::Connection*);
319 virtual void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID);
320 virtual void syncMessageSendTimedOut(CoreIPC::Connection*);
322 virtual Vector<HWND> windowsToReceiveSentMessagesWhileWaitingForSyncReply();
325 // CoreIPC::Connection::QueueClient
326 virtual void didReceiveMessageOnConnectionWorkQueue(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, bool& didHandleMessage) OVERRIDE;
328 // Implemented in generated WebProcessMessageReceiver.cpp
329 void didReceiveWebProcessMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
330 void didReceiveWebProcessMessageOnConnectionWorkQueue(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, bool& didHandleMessage);
332 void didGetPlugins(CoreIPC::Connection*, uint64_t requestID, const Vector<WebCore::PluginInfo>&);
334 RefPtr<WebConnectionToUIProcess> m_connection;
336 HashMap<uint64_t, RefPtr<WebPage> > m_pageMap;
337 HashMap<uint64_t, RefPtr<WebPageGroupProxy> > m_pageGroupMap;
338 RefPtr<InjectedBundle> m_injectedBundle;
340 EventDispatcher m_eventDispatcher;
344 WebCore::RunLoop* m_runLoop;
346 // FIXME: The visited link table should not be per process.
347 VisitedLinkTable m_visitedLinkTable;
348 bool m_shouldTrackVisitedLinks;
350 bool m_hasSetCacheModel;
351 CacheModel m_cacheModel;
353 #if USE(ACCELERATED_COMPOSITING) && PLATFORM(MAC)
354 mach_port_t m_compositingRenderServerPort;
357 pid_t m_presenterApplicationPid;
358 dispatch_group_t m_clearResourceCachesDispatchGroup;
361 bool m_fullKeyboardAccessEnabled;
364 QNetworkAccessManager* m_networkAccessManager;
367 HashMap<uint64_t, WebFrame*> m_frameMap;
369 HashSet<String, CaseFoldingHash> m_mimeTypesWithCustomRepresentations;
371 TextCheckerState m_textCheckerState;
372 WebGeolocationManager m_geolocationManager;
373 #if ENABLE(BATTERY_STATUS)
374 WebBatteryManager m_batteryManager;
376 #if ENABLE(NETWORK_INFO)
377 WebNetworkInfoManager m_networkInfoManager;
379 #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
380 WebNotificationManager m_notificationManager;
382 WebIconDatabaseProxy m_iconDatabaseProxy;
384 String m_localStorageDirectory;
386 RefPtr<SandboxExtension> m_applicationCachePathExtension;
388 #if ENABLE(PLUGIN_PROCESS)
389 PluginProcessConnectionManager m_pluginProcessConnectionManager;
390 bool m_disablePluginProcessMessageTimeout;
392 #if ENABLE(TIZEN_WEBKIT2_TILED_AC_SHARED_PLATFORM_SURFACE)
393 OwnPtr<PlatformSurfacePoolTizen> m_platformSurfacePool;
396 #if ENABLE(TIZEN_INDEXED_DATABASE)
397 String m_indexedDatabaseDirectory;
401 WebSoupRequestManager m_soupRequestManager;
404 #if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP)
405 int m_isWaitingForJavaScriptPopupCount;
408 #if ENABLE(TIZEN_WEBKIT2_MEMORY_SAVING_MODE)
409 bool m_memorySavingModeEnabled;
413 } // namespace WebKit
415 #endif // WebProcess_h