1/*
2 * Copyright (C) 2010 Apple Inc. All rights reserved.
3 * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY MOTOROLA INC. AND ITS CONTRIBUTORS ``AS IS''
15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MOTOROLA INC. OR ITS CONTRIBUTORS
18 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24 * THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include "config.h"
28#include "WebProcess.h"
29
30#include "WebProcessCreationParameters.h"
31
32#if USE(GSTREAMER)
33#include <WebCore/GStreamerCommon.h>
34#endif
35
36#include <WebCore/MemoryCache.h>
37
38#if PLATFORM(WAYLAND)
39#include "WaylandCompositorDisplay.h"
40#endif
41
42#if USE(WPE_RENDERER)
43#include <WebCore/PlatformDisplayLibWPE.h>
44#include <wpe/wpe.h>
45#endif
46
47namespace WebKit {
48
49using namespace WebCore;
50
51void WebProcess::platformSetCacheModel(CacheModel cacheModel)
52{
53 WebCore::MemoryCache::singleton().setDisabled(cacheModel == CacheModel::DocumentViewer);
54}
55
56void WebProcess::platformInitializeWebProcess(WebProcessCreationParameters& parameters)
57{
58#if PLATFORM(WPE)
59 if (!parameters.isServiceWorkerProcess) {
60 auto& implementationLibraryName = parameters.implementationLibraryName;
61 if (!implementationLibraryName.isNull() && implementationLibraryName.data()[0] != '\0')
62 wpe_loader_init(parameters.implementationLibraryName.data());
63
64 RELEASE_ASSERT(is<PlatformDisplayLibWPE>(PlatformDisplay::sharedDisplay()));
65 downcast<PlatformDisplayLibWPE>(PlatformDisplay::sharedDisplay()).initialize(parameters.hostClientFileDescriptor.releaseFileDescriptor());
66 }
67#endif
68
69#if PLATFORM(WAYLAND)
70 if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::Wayland) {
71#if USE(WPE_RENDERER)
72 if (!parameters.isServiceWorkerProcess) {
73 auto hostClientFileDescriptor = parameters.hostClientFileDescriptor.releaseFileDescriptor();
74 if (hostClientFileDescriptor != -1) {
75 wpe_loader_init(parameters.implementationLibraryName.data());
76 m_wpeDisplay = WebCore::PlatformDisplayLibWPE::create();
77 m_wpeDisplay->initialize(hostClientFileDescriptor);
78 }
79 }
80#else
81 m_waylandCompositorDisplay = WaylandCompositorDisplay::create(parameters.waylandCompositorDisplayName);
82#endif
83 }
84#endif
85
86#if USE(GSTREAMER)
87 WebCore::initializeGStreamer(WTFMove(parameters.gstreamerOptions));
88#endif
89}
90
91void WebProcess::platformSetWebsiteDataStoreParameters(WebProcessDataStoreParameters&&)
92{
93}
94
95void WebProcess::platformTerminate()
96{
97}
98
99} // namespace WebKit
100