|
Lines 28-42
a/Source/WebKit2/NetworkProcess/soup/NetworkProcessSoup.cpp_sec1
|
| 28 |
#if ENABLE(NETWORK_PROCESS) |
28 |
#if ENABLE(NETWORK_PROCESS) |
| 29 |
#include "NetworkProcess.h" |
29 |
#include "NetworkProcess.h" |
| 30 |
|
30 |
|
| 31 |
#include "CertificateInfo.h" |
|
|
| 32 |
#include "NetworkProcessCreationParameters.h" |
31 |
#include "NetworkProcessCreationParameters.h" |
| 33 |
#include "ResourceCachesToClear.h" |
32 |
#include "ResourceCachesToClear.h" |
|
|
33 |
#include <WebCore/CertificateInfo.h> |
| 34 |
#include <WebCore/FileSystem.h> |
34 |
#include <WebCore/FileSystem.h> |
| 35 |
#include <WebCore/NotImplemented.h> |
35 |
#include <WebCore/NotImplemented.h> |
| 36 |
#include <WebCore/ResourceHandle.h> |
36 |
#include <WebCore/ResourceHandle.h> |
| 37 |
#include <libsoup/soup.h> |
37 |
#include <libsoup/soup.h> |
| 38 |
#include <wtf/gobject/GOwnPtr.h> |
38 |
#include <wtf/gobject/GOwnPtr.h> |
| 39 |
#include <wtf/gobject/GRefPtr.h> |
39 |
#include <wtf/gobject/GRefPtr.h> |
|
|
40 |
#include <wtf/text/CString.h> |
| 41 |
#include <wtf/text/StringBuilder.h> |
| 40 |
|
42 |
|
| 41 |
using namespace WebCore; |
43 |
using namespace WebCore; |
| 42 |
|
44 |
|
|
Lines 73-85
static uint64_t getMemorySize()
a/Source/WebKit2/NetworkProcess/soup/NetworkProcessSoup.cpp_sec2
|
| 73 |
#endif |
75 |
#endif |
| 74 |
} |
76 |
} |
| 75 |
|
77 |
|
|
|
78 |
// This function is based on Epiphany code in ephy-embed-prefs.c. |
| 79 |
static CString buildAcceptLanguages(Vector<String> languages) |
| 80 |
{ |
| 81 |
// Ignore "C" locale. |
| 82 |
size_t position = languages.find("c"); |
| 83 |
if (position != notFound) |
| 84 |
languages.remove(position); |
| 85 |
|
| 86 |
// Fallback to "en" if the list is empty. |
| 87 |
if (languages.isEmpty()) |
| 88 |
return "en"; |
| 89 |
|
| 90 |
// Calculate deltas for the quality values. |
| 91 |
int delta; |
| 92 |
if (languages.size() < 10) |
| 93 |
delta = 10; |
| 94 |
else if (languages.size() < 20) |
| 95 |
delta = 5; |
| 96 |
else |
| 97 |
delta = 1; |
| 98 |
|
| 99 |
// Set quality values for each language. |
| 100 |
StringBuilder builder; |
| 101 |
for (size_t i = 0; i < languages.size(); ++i) { |
| 102 |
if (i) |
| 103 |
builder.append(", "); |
| 104 |
|
| 105 |
builder.append(languages[i]); |
| 106 |
|
| 107 |
int quality = 100 - i * delta; |
| 108 |
if (quality > 0 && quality < 100) { |
| 109 |
char buffer[8]; |
| 110 |
g_ascii_formatd(buffer, 8, "%.2f", quality / 100.0); |
| 111 |
builder.append(String::format(";q=%s", buffer)); |
| 112 |
} |
| 113 |
} |
| 114 |
|
| 115 |
return builder.toString().utf8(); |
| 116 |
} |
| 117 |
|
| 118 |
void NetworkProcess::userPreferredLanguagesChanged(Vector<String> languages) |
| 119 |
{ |
| 120 |
g_object_set(ResourceHandle::defaultSession(), "accept-language", buildAcceptLanguages(languages).data(), nullptr); |
| 121 |
} |
| 122 |
|
| 76 |
void NetworkProcess::platformInitializeNetworkProcess(const NetworkProcessCreationParameters& parameters) |
123 |
void NetworkProcess::platformInitializeNetworkProcess(const NetworkProcessCreationParameters& parameters) |
| 77 |
{ |
124 |
{ |
| 78 |
ASSERT(!parameters.diskCacheDirectory.isEmpty()); |
125 |
ASSERT(!parameters.diskCacheDirectory.isEmpty()); |
| 79 |
GRefPtr<SoupCache> soupCache = adoptGRef(soup_cache_new(parameters.diskCacheDirectory.utf8().data(), SOUP_CACHE_SINGLE_USER)); |
126 |
GRefPtr<SoupCache> soupCache = adoptGRef(soup_cache_new(parameters.diskCacheDirectory.utf8().data(), SOUP_CACHE_SINGLE_USER)); |
| 80 |
soup_session_add_feature(WebCore::ResourceHandle::defaultSession(), SOUP_SESSION_FEATURE(soupCache.get())); |
127 |
soup_session_add_feature(ResourceHandle::defaultSession(), SOUP_SESSION_FEATURE(soupCache.get())); |
| 81 |
soup_cache_load(soupCache.get()); |
128 |
soup_cache_load(soupCache.get()); |
| 82 |
|
129 |
|
|
|
130 |
if (!parameters.languages.isEmpty()) |
| 131 |
userPreferredLanguagesChanged(parameters.languages); |
| 132 |
|
| 83 |
setIgnoreTLSErrors(parameters.ignoreTLSErrors); |
133 |
setIgnoreTLSErrors(parameters.ignoreTLSErrors); |
| 84 |
} |
134 |
} |
| 85 |
|
135 |
|
|
Lines 114-120
void NetworkProcess::setIgnoreTLSErrors(bool ignoreTLSErrors)
a/Source/WebKit2/NetworkProcess/soup/NetworkProcessSoup.cpp_sec3
|
| 114 |
|
164 |
|
| 115 |
void NetworkProcess::allowSpecificHTTPSCertificateForHost(const CertificateInfo& certificateInfo, const String& host) |
165 |
void NetworkProcess::allowSpecificHTTPSCertificateForHost(const CertificateInfo& certificateInfo, const String& host) |
| 116 |
{ |
166 |
{ |
| 117 |
WebCore::ResourceHandle::setClientCertificate(host, certificateInfo.certificate()); |
167 |
ResourceHandle::setClientCertificate(host, certificateInfo.certificate()); |
| 118 |
} |
168 |
} |
| 119 |
|
169 |
|
| 120 |
void NetworkProcess::clearCacheForAllOrigins(uint32_t cachesToClear) |
170 |
void NetworkProcess::clearCacheForAllOrigins(uint32_t cachesToClear) |
|
Lines 122-129
void NetworkProcess::clearCacheForAllOrigins(uint32_t cachesToClear)
a/Source/WebKit2/NetworkProcess/soup/NetworkProcessSoup.cpp_sec4
|
| 122 |
if (cachesToClear == InMemoryResourceCachesOnly) |
172 |
if (cachesToClear == InMemoryResourceCachesOnly) |
| 123 |
return; |
173 |
return; |
| 124 |
|
174 |
|
| 125 |
SoupSession* session = ResourceHandle::defaultSession(); |
175 |
soup_cache_clear(SOUP_CACHE(soup_session_get_feature(ResourceHandle::defaultSession(), SOUP_TYPE_CACHE))); |
| 126 |
soup_cache_clear(SOUP_CACHE(soup_session_get_feature(session, SOUP_TYPE_CACHE))); |
|
|
| 127 |
} |
176 |
} |
| 128 |
|
177 |
|
| 129 |
void NetworkProcess::platformTerminate() |
178 |
void NetworkProcess::platformTerminate() |