Skip to content

Commit badb154

Browse files
[GTK] Allow to build with ENABLE_NETWORK_CACHE
https://bugs.webkit.org/show_bug.cgi?id=139728 Reviewed by Antti Koivisto. Just make it build for now. * CMakeLists.txt: Add new files to compilation. * NetworkProcess/NetworkResourceLoader.cpp: (WebKit::NetworkResourceLoader::didRetrieveCacheEntry): Use ENABLE(SHAREABLE_RESOURCE) when ShareableResource is used. * NetworkProcess/cache/NetworkCache.cpp: (WebKit::decodeStorageEntry): Ditto. (WebKit::makeCacheKey): Use ENABLE(CACHE_PARTITIONING) for ResourceRequest::cachePartition(). * NetworkProcess/cache/NetworkCache.h: * NetworkProcess/cache/NetworkCacheStorage.h: (WebKit::NetworkCacheStorage::Data::isNull): Move implementation to platform specific files. * NetworkProcess/cache/NetworkCacheStorageCocoa.mm: (WebKit::NetworkCacheStorage::Data::isNull): Moved from the header. * NetworkProcess/cache/NetworkCacheStorageSoup.cpp: Added. (WebKit::NetworkCacheStorage::Data::Data): (WebKit::NetworkCacheStorage::Data::data): (WebKit::NetworkCacheStorage::Data::isNull): (WebKit::NetworkCacheStorage::open): (WebKit::NetworkCacheStorage::NetworkCacheStorage): (WebKit::NetworkCacheStorage::initializeKeyFilter): (WebKit::NetworkCacheStorage::removeEntry): (WebKit::NetworkCacheStorage::dispatchRetrieveOperation): (WebKit::NetworkCacheStorage::dispatchPendingRetrieveOperations): (WebKit::NetworkCacheStorage::retrieve): (WebKit::NetworkCacheStorage::store): (WebKit::NetworkCacheStorage::setMaximumSize): (WebKit::NetworkCacheStorage::clear): * PlatformGTK.cmake: Add NetworkCacheStorageSoup.cpp. * config.h: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@177495 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 0d20d95 commit badb154

10 files changed

+206
-3
lines changed

Source/WebKit2/CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ set(WebKit2_SOURCES
157157

158158
NetworkProcess/FileAPI/NetworkBlobRegistry.cpp
159159

160+
NetworkProcess/cache/NetworkCache.cpp
161+
NetworkProcess/cache/NetworkCacheCoders.cpp
162+
NetworkProcess/cache/NetworkCacheEncoder.cpp
163+
NetworkProcess/cache/NetworkCacheDecoder.cpp
164+
NetworkProcess/cache/NetworkCacheKey.cpp
165+
160166
Platform/Logging.cpp
161167
Platform/Module.cpp
162168
Platform/WorkQueue.cpp

Source/WebKit2/ChangeLog

+39
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,42 @@
1+
2014-12-18 Carlos Garcia Campos <[email protected]>
2+
3+
[GTK] Allow to build with ENABLE_NETWORK_CACHE
4+
https://bugs.webkit.org/show_bug.cgi?id=139728
5+
6+
Reviewed by Antti Koivisto.
7+
8+
Just make it build for now.
9+
10+
* CMakeLists.txt: Add new files to compilation.
11+
* NetworkProcess/NetworkResourceLoader.cpp:
12+
(WebKit::NetworkResourceLoader::didRetrieveCacheEntry): Use
13+
ENABLE(SHAREABLE_RESOURCE) when ShareableResource is used.
14+
* NetworkProcess/cache/NetworkCache.cpp:
15+
(WebKit::decodeStorageEntry): Ditto.
16+
(WebKit::makeCacheKey): Use ENABLE(CACHE_PARTITIONING) for ResourceRequest::cachePartition().
17+
* NetworkProcess/cache/NetworkCache.h:
18+
* NetworkProcess/cache/NetworkCacheStorage.h:
19+
(WebKit::NetworkCacheStorage::Data::isNull): Move implementation
20+
to platform specific files.
21+
* NetworkProcess/cache/NetworkCacheStorageCocoa.mm:
22+
(WebKit::NetworkCacheStorage::Data::isNull): Moved from the header.
23+
* NetworkProcess/cache/NetworkCacheStorageSoup.cpp: Added.
24+
(WebKit::NetworkCacheStorage::Data::Data):
25+
(WebKit::NetworkCacheStorage::Data::data):
26+
(WebKit::NetworkCacheStorage::Data::isNull):
27+
(WebKit::NetworkCacheStorage::open):
28+
(WebKit::NetworkCacheStorage::NetworkCacheStorage):
29+
(WebKit::NetworkCacheStorage::initializeKeyFilter):
30+
(WebKit::NetworkCacheStorage::removeEntry):
31+
(WebKit::NetworkCacheStorage::dispatchRetrieveOperation):
32+
(WebKit::NetworkCacheStorage::dispatchPendingRetrieveOperations):
33+
(WebKit::NetworkCacheStorage::retrieve):
34+
(WebKit::NetworkCacheStorage::store):
35+
(WebKit::NetworkCacheStorage::setMaximumSize):
36+
(WebKit::NetworkCacheStorage::clear):
37+
* PlatformGTK.cmake: Add NetworkCacheStorageSoup.cpp.
38+
* config.h:
39+
140
2014-12-17 Dan Bernstein <[email protected]>
241

342
<rdar://problem/19282508> WebKitLegacy is unusable due to bad dylib identifier

Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -545,14 +545,18 @@ void NetworkResourceLoader::didRetrieveCacheEntry(std::unique_ptr<NetworkCache::
545545
} else {
546546
sendAbortingOnFailure(Messages::WebResourceLoader::DidReceiveResponse(entry->response, m_parameters.isMainResource));
547547

548+
#if ENABLE(SHAREABLE_RESOURCE)
548549
if (!entry->shareableResourceHandle.isNull())
549550
send(Messages::WebResourceLoader::DidReceiveResource(entry->shareableResourceHandle, currentTime()));
550551
else {
552+
#endif
551553
bool shouldContinue = sendBufferMaybeAborting(*entry->buffer, entry->buffer->size());
552554
if (!shouldContinue)
553555
return;
554556
send(Messages::WebResourceLoader::DidFinishResourceLoad(currentTime()));
557+
#if ENABLE(SHAREABLE_RESOURCE)
555558
}
559+
#endif
556560
}
557561

558562
cleanup();

Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,14 @@ static std::unique_ptr<NetworkCache::Entry> decodeStorageEntry(const NetworkCach
176176
cachedResponse.setSource(needsRevalidation ? WebCore::ResourceResponse::Source::DiskCacheAfterValidation : WebCore::ResourceResponse::Source::DiskCache);
177177
entry->response = cachedResponse;
178178

179+
#if ENABLE(SHAREABLE_RESOURCE)
179180
RefPtr<SharedMemory> sharedMemory = storageEntry.body.size() ? SharedMemory::createFromVMBuffer(const_cast<uint8_t*>(storageEntry.body.data()), storageEntry.body.size()) : nullptr;
180181
RefPtr<ShareableResource> shareableResource = sharedMemory ? ShareableResource::create(sharedMemory.release(), 0, storageEntry.body.size()) : nullptr;
181182

182183
if (shareableResource && shareableResource->createHandle(entry->shareableResourceHandle))
183184
entry->buffer = entry->shareableResourceHandle.tryWrapInSharedBuffer();
184185
else
186+
#endif
185187
entry->buffer = WebCore::SharedBuffer::create(storageEntry.body.data(), storageEntry.body.size());
186188

187189
return entry;
@@ -205,7 +207,11 @@ static bool canRetrieve(const WebCore::ResourceRequest& request)
205207

206208
static NetworkCacheKey makeCacheKey(const WebCore::ResourceRequest& request)
207209
{
210+
#if ENABLE(CACHE_PARTITIONING)
208211
String partition = request.cachePartition();
212+
#else
213+
String partition;
214+
#endif
209215
if (partition.isEmpty())
210216
partition = ASCIILiteral("No partition");
211217
return NetworkCacheKey(request.httpMethod(), partition, request.url().string());

Source/WebKit2/NetworkProcess/cache/NetworkCache.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
#include "NetworkCacheStorage.h"
3232
#include "ShareableResource.h"
33-
#include <Webcore/ResourceResponse.h>
33+
#include <WebCore/ResourceResponse.h>
3434
#include <wtf/text/WTFString.h>
3535

3636
namespace WebCore {
@@ -56,7 +56,9 @@ class NetworkCache {
5656
struct Entry {
5757
WebCore::ResourceResponse response;
5858
RefPtr<WebCore::SharedBuffer> buffer;
59+
#if ENABLE(SHAREABLE_RESOURCE)
5960
ShareableResource::Handle shareableResourceHandle;
61+
#endif
6062
bool needsRevalidation;
6163
};
6264
// Completion handler may get called back synchronously on failure.

Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class NetworkCacheStorage {
6363
#if PLATFORM(COCOA)
6464
explicit Data(OSObjectPtr<dispatch_data_t>);
6565
#endif
66-
bool isNull() const { return !m_dispatchData; }
66+
bool isNull() const;
6767

6868
const uint8_t* data() const;
6969
size_t size() const { return m_size; }

Source/WebKit2/NetworkProcess/cache/NetworkCacheStorageCocoa.mm

+5
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ static void traverseCacheFiles(const String& cachePath, std::function<void (cons
105105
return m_data;
106106
}
107107

108+
bool NetworkCacheStorage::Data::isNull() const
109+
{
110+
return !m_dispatchData;
111+
}
112+
108113
std::unique_ptr<NetworkCacheStorage> NetworkCacheStorage::open(const String& cachePath)
109114
{
110115
ASSERT(RunLoop::isMain());
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
/*
2+
* Copyright (C) 2014 Igalia S.L.
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 "NetworkCacheStorage.h"
28+
29+
#if ENABLE(NETWORK_CACHE)
30+
31+
#include "Logging.h"
32+
#include "NetworkCacheCoders.h"
33+
#include <WebCore/FileSystem.h>
34+
#include <WebCore/NotImplemented.h>
35+
#include <wtf/RunLoop.h>
36+
37+
namespace WebKit {
38+
39+
static const char* networkCacheSubdirectory = "WebKitCache";
40+
41+
NetworkCacheStorage::Data::Data()
42+
: m_data(nullptr)
43+
, m_size(0)
44+
{
45+
notImplemented();
46+
}
47+
48+
NetworkCacheStorage::Data::Data(const uint8_t* data, size_t size)
49+
: m_data(data)
50+
, m_size(size)
51+
{
52+
notImplemented();
53+
}
54+
55+
const uint8_t* NetworkCacheStorage::Data::data() const
56+
{
57+
notImplemented();
58+
return nullptr;
59+
}
60+
61+
bool NetworkCacheStorage::Data::isNull() const
62+
{
63+
notImplemented();
64+
return true;
65+
}
66+
67+
std::unique_ptr<NetworkCacheStorage> NetworkCacheStorage::open(const String& applicationCachePath)
68+
{
69+
ASSERT(RunLoop::isMain());
70+
String networkCachePath = WebCore::pathByAppendingComponent(applicationCachePath, networkCacheSubdirectory);
71+
if (!WebCore::makeAllDirectories(networkCachePath))
72+
return nullptr;
73+
return std::unique_ptr<NetworkCacheStorage>(new NetworkCacheStorage(networkCachePath));
74+
}
75+
76+
NetworkCacheStorage::NetworkCacheStorage(const String& directoryPath)
77+
: m_directoryPath(directoryPath)
78+
, m_maximumSize(std::numeric_limits<size_t>::max())
79+
, m_activeRetrieveOperationCount(0)
80+
{
81+
initializeKeyFilter();
82+
}
83+
84+
void NetworkCacheStorage::initializeKeyFilter()
85+
{
86+
ASSERT(RunLoop::isMain());
87+
notImplemented();
88+
}
89+
90+
void NetworkCacheStorage::removeEntry(const NetworkCacheKey&)
91+
{
92+
ASSERT(RunLoop::isMain());
93+
notImplemented();
94+
}
95+
96+
void NetworkCacheStorage::dispatchRetrieveOperation(const RetrieveOperation&)
97+
{
98+
ASSERT(RunLoop::isMain());
99+
notImplemented();
100+
}
101+
102+
void NetworkCacheStorage::dispatchPendingRetrieveOperations()
103+
{
104+
ASSERT(RunLoop::isMain());
105+
notImplemented();
106+
}
107+
108+
void NetworkCacheStorage::retrieve(const NetworkCacheKey&, unsigned /* priority */, std::function<bool (std::unique_ptr<Entry>)> completionHandler)
109+
{
110+
ASSERT(RunLoop::isMain());
111+
notImplemented();
112+
completionHandler(nullptr);
113+
}
114+
115+
void NetworkCacheStorage::store(const NetworkCacheKey&, const Entry&, std::function<void (bool success)> completionHandler)
116+
{
117+
ASSERT(RunLoop::isMain());
118+
notImplemented();
119+
completionHandler(false);
120+
}
121+
122+
void NetworkCacheStorage::setMaximumSize(size_t size)
123+
{
124+
ASSERT(RunLoop::isMain());
125+
notImplemented();
126+
m_maximumSize = size;
127+
}
128+
129+
void NetworkCacheStorage::clear()
130+
{
131+
ASSERT(RunLoop::isMain());
132+
LOG(NetworkCacheStorage, "(NetworkProcess) clearing cache");
133+
notImplemented();
134+
m_keyFilter.clear();
135+
}
136+
137+
} // namespace WebKit
138+
139+
#endif // ENABLE(NETWORK_CACHE)

Source/WebKit2/PlatformGTK.cmake

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ add_definitions(-DLIBDIR="${LIB_INSTALL_DIR}")
1515
set(WebKit2_USE_PREFIX_HEADER ON)
1616

1717
list(APPEND WebKit2_SOURCES
18+
NetworkProcess/cache/NetworkCacheStorageSoup.cpp
19+
1820
NetworkProcess/gtk/NetworkProcessMainGtk.cpp
1921

2022
NetworkProcess/soup/NetworkProcessSoup.cpp

Source/WebKit2/config.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
#endif
9595

9696
#ifndef ENABLE_NETWORK_CACHE
97-
#if PLATFORM(MAC) && ENABLE(NETWORK_PROCESS)
97+
#if (PLATFORM(MAC) || PLATFORM(GTK)) && ENABLE(NETWORK_PROCESS)
9898
#define ENABLE_NETWORK_CACHE 0
9999
#endif
100100
#endif

0 commit comments

Comments
 (0)