2011-03-03 Maciej Stachowiak <mjs@apple.com>
[WebKit.git] / Source / WebKit2 / Shared / WebProcessCreationParameters.cpp
1 /*
2  * Copyright (C) 2010 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
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.
12  *
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.
24  */
25
26 #include "config.h"
27 #include "WebProcessCreationParameters.h"
28
29 #include "ArgumentCoders.h"
30
31 namespace WebKit {
32
33 WebProcessCreationParameters::WebProcessCreationParameters()
34     : shouldTrackVisitedLinks(false)
35     , clearResourceCaches(false)
36     , clearApplicationCache(false)
37     , shouldAlwaysUseComplexTextCodePath(false)
38     , defaultRequestTimeoutInterval(INT_MAX)
39 #if PLATFORM(MAC)
40     , nsURLCacheMemoryCapacity(0)
41     , nsURLCacheDiskCapacity(0)
42 #elif PLATFORM(WIN)
43     , shouldPaintNativeControls(false)
44 #endif
45 {
46 }
47
48 void WebProcessCreationParameters::encode(CoreIPC::ArgumentEncoder* encoder) const
49 {
50     encoder->encode(injectedBundlePath);
51     encoder->encode(injectedBundlePathExtensionHandle);
52     encoder->encode(applicationCacheDirectory);
53     encoder->encode(databaseDirectory);
54     encoder->encode(urlSchemesRegistererdAsEmptyDocument);
55     encoder->encode(urlSchemesRegisteredAsSecure);
56     encoder->encode(urlSchemesForWhichDomainRelaxationIsForbidden);
57     encoder->encode(mimeTypesWithCustomRepresentation);
58     encoder->encodeEnum(cacheModel);
59     encoder->encode(shouldTrackVisitedLinks);
60     encoder->encode(clearResourceCaches);
61     encoder->encode(clearApplicationCache);
62     encoder->encode(shouldAlwaysUseComplexTextCodePath);
63     encoder->encode(languageCode);
64     encoder->encode(textCheckerState);
65     encoder->encode(defaultRequestTimeoutInterval);
66 #if USE(CFURLSTORAGESESSIONS)
67     encoder->encode(uiProcessBundleIdentifier);
68 #endif
69 #if PLATFORM(MAC)
70     encoder->encode(parentProcessName);
71     encoder->encode(presenterApplicationPid);
72     encoder->encode(nsURLCachePath);
73     encoder->encode(nsURLCacheMemoryCapacity);
74     encoder->encode(nsURLCacheDiskCapacity);
75     encoder->encode(acceleratedCompositingPort);
76     encoder->encode(uiProcessBundleResourcePath);
77 #elif PLATFORM(WIN)
78     encoder->encode(shouldPaintNativeControls);
79     encoder->encode(cfURLCachePath);
80     encoder->encode(cfURLCacheDiskCapacity);
81     encoder->encode(cfURLCacheMemoryCapacity);
82 #endif
83 }
84
85 bool WebProcessCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, WebProcessCreationParameters& parameters)
86 {
87     if (!decoder->decode(parameters.injectedBundlePath))
88         return false;
89     if (!decoder->decode(parameters.injectedBundlePathExtensionHandle))
90         return false;
91     if (!decoder->decode(parameters.applicationCacheDirectory))
92         return false;
93     if (!decoder->decode(parameters.databaseDirectory))
94         return false;
95     if (!decoder->decode(parameters.urlSchemesRegistererdAsEmptyDocument))
96         return false;
97     if (!decoder->decode(parameters.urlSchemesRegisteredAsSecure))
98         return false;
99     if (!decoder->decode(parameters.urlSchemesForWhichDomainRelaxationIsForbidden))
100         return false;
101     if (!decoder->decode(parameters.mimeTypesWithCustomRepresentation))
102         return false;
103     if (!decoder->decodeEnum(parameters.cacheModel))
104         return false;
105     if (!decoder->decode(parameters.shouldTrackVisitedLinks))
106         return false;
107     if (!decoder->decode(parameters.clearResourceCaches))
108         return false;
109     if (!decoder->decode(parameters.clearApplicationCache))
110         return false;
111     if (!decoder->decode(parameters.shouldAlwaysUseComplexTextCodePath))
112         return false;
113     if (!decoder->decode(parameters.languageCode))
114         return false;
115     if (!decoder->decode(parameters.textCheckerState))
116         return false;
117     if (!decoder->decode(parameters.defaultRequestTimeoutInterval))
118         return false;
119 #if USE(CFURLSTORAGESESSIONS)
120     if (!decoder->decode(parameters.uiProcessBundleIdentifier))
121         return false;
122 #endif
123
124 #if PLATFORM(MAC)
125     if (!decoder->decode(parameters.parentProcessName))
126         return false;
127     if (!decoder->decode(parameters.presenterApplicationPid))
128         return false;
129     if (!decoder->decode(parameters.nsURLCachePath))
130         return false;
131     if (!decoder->decode(parameters.nsURLCacheMemoryCapacity))
132         return false;
133     if (!decoder->decode(parameters.nsURLCacheDiskCapacity))
134         return false;
135     if (!decoder->decode(parameters.acceleratedCompositingPort))
136         return false;
137     if (!decoder->decode(parameters.uiProcessBundleResourcePath))
138         return false;
139 #elif PLATFORM(WIN)
140     if (!decoder->decode(parameters.shouldPaintNativeControls))
141         return false;
142     if (!decoder->decode(parameters.cfURLCachePath))
143         return false;
144     if (!decoder->decode(parameters.cfURLCacheDiskCapacity))
145         return false;
146     if (!decoder->decode(parameters.cfURLCacheMemoryCapacity))
147         return false;
148 #endif
149
150     return true;
151 }
152
153 } // namespace WebKit