Source/WebCore/ChangeLog

 12017-08-13 Youenn Fablet <youenn@apple.com>
 2
 3 [Cache API] Adding generic support for CacheStorage and Cache methods
 4 https://bugs.webkit.org/show_bug.cgi?id=175455
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Covered by existing tests.
 9
 10 Adding a CacheStorageProvider abstraction that creates a CacheStorageConnection.
 11 The CacheStorageProvider is accessed from the page for Document calls.
 12 The CacheStorageConnection is responsible to implement the read/write operations on the cache database.
 13 At the moment, it does nothing but return not implemented errors.
 14
 15 Implementing CacheStorage APIs and Cache APIs based on the CacheStorageConnection except for Cache add and addAll which will be implemented later on.
 16 CacheStoragConnection is responsible to read/write CacheStorage list of caches and each individual cache.
 17 The CacheStorageConnection is a generic connection and not tied to any document/context.
 18 CacheStorage objects are manipulated by providing to the connection the origin of the context.
 19 CacheStorage are global to all contexts with the same origin.
 20 Cache objects are manipulated by an ID that is given initially by the CacheStorageEngine when opening the Cache object.
 21
 22 Adding various accessors and constructors for Fetch constructs as needed by the Cache API implementation.
 23
 24 * Modules/cache/Cache.cpp:
 25 (WebCore::Cache::Cache):
 26 (WebCore::Cache::~Cache):
 27 The CacheStorageConnection is a generic connection and not tied to any document/context.
 28 (WebCore::Cache::match): Implementation of https://www.w3.org/TR/service-workers-1/#cache-match.
 29 Redirect to matchAll as per spec.
 30 (WebCore::Cache::matchAll): Implementation of https://www.w3.org/TR/service-workers-1/#cache-matchAll.
 31 Checks for request as per spec. Then either refresh the request to response map and return all responses.
 32 Or call the query cache algorithm and return copies of the responses (using clone).
 33 (WebCore::Cache::put):
 34 Check the request and response as per spec.
 35 Add temporary rejection cases (being loaded responses, responses with ReadableStream) as there is no support for them right now.
 36 Call the batch put operation.
 37 (WebCore::Cache::remove):
 38 Check the request and response as per spec.
 39 Call the batch delete operation.
 40 (WebCore::Cache::keys):
 41 Refresh the request to response map and return corresponding requests.
 42 Making sure to reuse the same request objects as per spec.
 43 As per spec, the request to response map is ordered. We implement it as a Vector.
 44 (WebCore::Cache::refreshRequestToResponseMap):
 45 Use the cache storage connection to get an up-to-date list of cached records.
 46 (WebCore::Cache::queryCacheMatch):
 47 Implements the match algorithm defined in https://www.w3.org/TR/service-workers-1/#query-cache-algorithm.
 48 This is split for queryCache as cache storage engine will need to use it when implementing the delete operation.
 49 (WebCore::Cache::queryCache):
 50 Full implementation of https://www.w3.org/TR/service-workers-1/#query-cache-algorithm with no targetStorage argument.
 51 (WebCore::Cache::queryCacheWithTargetStorage):
 52 Full implementation of https://www.w3.org/TR/service-workers-1/#query-cache-algorithm with a provided targetStorage argument.
 53 (WebCore::Cache::batchDeleteOperation):
 54 Implementation of https://www.w3.org/TR/service-workers-1/#batch-cache-operations-algorithm but dedicated to a delete operation.
 55 Delete operation are always done one at a time.
 56 (WebCore::Cache::batchPutOperation):
 57 Implementation of https://www.w3.org/TR/service-workers-1/#batch-cache-operations-algorithm dedicated to a put operation.
 58 Put operation takes one record for put but can take several records in the case of addAll, hence the current design.
 59 (WebCore::Cache::updateRequestToResponseMap):
 60 Update the cache request to response map based on the records retrieved from the cache storage connection.
 61 * Modules/cache/Cache.h:
 62 (WebCore::Cache::create):
 63 (WebCore::Cache::name const):
 64 * Modules/cache/Cache.idl:
 65 * Modules/cache/CacheStorage.cpp:
 66 (WebCore::CacheStorage::origin const):
 67 Computing the cache origin that is passed to the CacheStorageConnection.
 68 (WebCore::CacheStorage::has):
 69 Implementation of https://www.w3.org/TR/service-workers-1/#cache-storage-has.
 70 Call the cache storage connection to refresh its cache map.
 71 Then use it to check whether a cache exists.
 72 (WebCore::CacheStorage::refreshCacheMap):
 73 Use the cache storage connection to get the list of existing caches.
 74 (WebCore::CacheStorage::open):
 75 Implementation of https://www.w3.org/TR/service-workers-1/#cache-storage-open.
 76 Refreshing the cache map so as to return a pre-existing cache if any.
 77 (WebCore::CacheStorage::remove):
 78 Implementation of https://www.w3.org/TR/service-workers-1/#cache-storage-delete-method.
 79 Refreshing the cache map so as to do nothing if there is no cache to remove.
 80 (WebCore::CacheStorage::keys):
 81 Implementation of https://www.w3.org/TR/service-workers-1/#cache-storage-keys-method.
 82 Refreshing the cache map and returnin its keys.
 83 As per spec, the cache map is ordered. We implement it as a Vector.
 84 (WebCore::CacheStorage::cacheMap):
 85 Get the list of cache objects, used as a private accessor for JS built-ins.
 86 * Modules/cache/CacheStorage.h:
 87 (WebCore::CacheStorage::create):
 88 (WebCore::CacheStorage::CacheStorage):
 89 * Modules/cache/CacheStorageConnection.cpp: Added.
 90 (WebCore::CacheStorageConnection::exceptionFromError):
 91 * Modules/cache/CacheStorageConnection.h: Added.
 92 Makes the link between Web facing Cache API and the cache storage engine.
 93 Envisioned implementation are:
 94 - One main thread connection used by all documents in the given process.
 95 - One connection per worker that forwards the calls to the main thread and use the main thread connection afterwards.
 96 (WebCore::CacheStorageConnection::create):
 97 (WebCore::CacheStorageConnection::open):
 98 (WebCore::CacheStorageConnection::remove):
 99 (WebCore::CacheStorageConnection::refreshCacheMap):
 100 (WebCore::CacheStorageConnection::refreshRequestToResponseMap):
 101 (WebCore::CacheStorageConnection::batchDeleteOperation):
 102 (WebCore::CacheStorageConnection::batchPutOperation):
 103 * Modules/cache/CacheStorageRecord.h: Added. A fetch record from the Web facing cache API perspective.
 104 * Modules/cache/DOMWindowCaches.cpp:
 105 (WebCore::DOMWindowCaches::caches const):
 106 * Modules/cache/WorkerGlobalScopeCaches.cpp:
 107 (WebCore::WorkerGlobalScopeCaches::from):
 108 (WebCore::WorkerGlobalScopeCaches::caches const):
 109 * Modules/cache/WorkerGlobalScopeCaches.h:
 110 (WebCore::WorkerGlobalScopeCaches::WorkerGlobalScopeCaches):
 111 * Modules/fetch/FetchBodyOwner.h:
 112 (WebCore::FetchBodyOwner::isReadableStreamBody const): Added getter as it is used by cache API.
 113 * Modules/fetch/FetchHeaders.h:
 114 (WebCore::FetchHeaders::create): Add another create as used by the cache API.
 115 (WebCore::FetchHeaders::guard const): Added getter and IPC serializer as this is something that will be stored by the cache engine.
 116 * Modules/fetch/FetchLoader.cpp:
 117 (WebCore::FetchLoader::start):
 118 * Modules/fetch/FetchRequest.cpp:
 119 (WebCore::buildOptions): In case FetchRequest::create is called from C++, there is no need to set init.window to a null value.
 120 Add a check so that no value at all is the same as a null/undefined value.
 121 (WebCore::FetchRequest::resourceRequest const):
 122 * Modules/fetch/FetchRequest.h:
 123 * Modules/fetch/FetchResponse.h:
 124 * WebCore.xcodeproj/project.pbxproj:
 125 * inspector/InspectorOverlay.cpp:
 126 (WebCore::InspectorOverlay::overlayPage):
 127 * page/CacheStorageProvider.h: Added.
 128 Interface to create main thread cache storage connection for the given page.
 129 There will be one provider for each process.
 130 Passing a sessionID so that we will create a connection per session.
 131 * page/Page.cpp:
 132 (WebCore::Page::Page):
 133 * page/Page.h:
 134 (WebCore::Page::cacheStorageProvider):
 135 * page/PageConfiguration.cpp:
 136 (WebCore::PageConfiguration::PageConfiguration):
 137 * page/PageConfiguration.h:
 138 * svg/graphics/SVGImage.cpp:
 139 (WebCore::SVGImage::dataChanged):
 140
11412017-08-13 Chris Dumez <cdumez@apple.com>
2142
3143 Drop non-const getter for CachedResource::resourceRequest()

Source/WebKit/ChangeLog

 12017-08-13 Youenn Fablet <youenn@apple.com>
 2
 3 [Cache API] Adding generic support for CacheStorage and Cache methods
 4 https://bugs.webkit.org/show_bug.cgi?id=175455
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * WebKit.xcodeproj/project.pbxproj:
 9 * WebProcess/Cache/WebCacheStorageProvider.h: Added.
 10 * WebProcess/WebPage/WebPage.cpp:
 11 (WebKit::m_cpuLimit):
 12 * WebProcess/WebProcess.cpp:
 13 (WebKit::WebProcess::WebProcess):
 14 * WebProcess/WebProcess.h:
 15 (WebKit::WebProcess::cacheStorageProvider):
 16
1172017-08-13 Adrian Perez de Castro <aperez@igalia.com>
218
319 [WPE] Implement WebCore::standardUserAgent()

Source/WebKitLegacy/mac/ChangeLog

 12017-08-13 Youenn Fablet <youenn@apple.com>
 2
 3 [Cache API] Adding generic support for CacheStorage and Cache methods
 4 https://bugs.webkit.org/show_bug.cgi?id=175455
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * WebView/WebView.mm:
 9 (-[WebView _commonInitializationWithFrameName:groupName:]):
 10
1112017-08-11 Ryosuke Niwa <rniwa@webkit.org>
212
313 Replace DATA_TRANSFER_ITEMS by a runtime flag and add a stub implementation

Source/WebKitLegacy/win/ChangeLog

 12017-08-13 Youenn Fablet <youenn@apple.com>
 2
 3 [Cache API] Adding generic support for CacheStorage and Cache methods
 4 https://bugs.webkit.org/show_bug.cgi?id=175455
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * WebView.cpp:
 9 (WebView::initWithFrame):
 10
1112017-08-09 Daniel Bates <dabates@apple.com>
212
313 REGRESSION (r219013): OAuth flows are broken when redirecting back to application after authentication

Source/WebCore/CMakeLists.txt

@@set(WebCore_SOURCES
900900
901901 Modules/cache/Cache.cpp
902902 Modules/cache/CacheStorage.cpp
 903 Modules/cache/CacheStorageConnection.cpp
903904 Modules/cache/DOMWindowCaches.cpp
904905 Modules/cache/WorkerGlobalScopeCaches.cpp
905906

Source/WebCore/Modules/cache/Cache.cpp

2626#include "config.h"
2727#include "Cache.h"
2828
 29#include "CacheQueryOptions.h"
 30#include "FetchResponse.h"
 31#include "JSFetchRequest.h"
 32#include "JSFetchResponse.h"
 33#include "ScriptExecutionContext.h"
 34#include "URL.h"
 35
2936namespace WebCore {
3037
31 void Cache::match(RequestInfo&&, std::optional<CacheQueryOptions>&&, Ref<DeferredPromise>&& promise)
 38Cache::Cache(ScriptExecutionContext& context, String&& name, uint64_t identifier, Ref<CacheStorageConnection>&& connection)
 39 : ActiveDOMObject(&context)
 40 , m_name(WTFMove(name))
 41 , m_identifier(identifier)
 42 , m_connection(WTFMove(connection))
 43{
 44 suspendIfNeeded();
 45}
 46
 47Cache::~Cache()
3248{
33  promise->reject(Exception { TypeError, ASCIILiteral("Not implemented")});
3449}
3550
36 void Cache::matchAll(std::optional<RequestInfo>&&, std::optional<CacheQueryOptions>&&, MatchAllPromise&& promise)
 51void Cache::match(RequestInfo&& info, CacheQueryOptions&& options, Ref<DeferredPromise>&& promise)
3752{
38  promise.reject(Exception { TypeError, ASCIILiteral("Not implemented")});
 53 matchAll(WTFMove(info), WTFMove(options), WTFMove(promise), MatchType::OnlyFirst);
 54}
 55
 56void Cache::matchAll(std::optional<RequestInfo>&& info, CacheQueryOptions&& options, Ref<DeferredPromise>&& promise, MatchType matchType)
 57{
 58 RefPtr<FetchRequest> request;
 59 if (info) {
 60 if (WTF::holds_alternative<RefPtr<FetchRequest>>(info.value())) {
 61 request = WTF::get<RefPtr<FetchRequest>>(info.value()).releaseNonNull();
 62 if (request->method() != "GET" && !options.ignoreMethod) {
 63 if (matchType == MatchType::OnlyFirst) {
 64 promise->resolve();
 65 return;
 66 }
 67 promise->resolve<IDLSequence<IDLInterface<FetchResponse>>>(Vector<Ref<FetchResponse>> { });
 68 return;
 69 }
 70 } else {
 71 if (UNLIKELY(!scriptExecutionContext()))
 72 return;
 73 request = FetchRequest::create(*scriptExecutionContext(), WTFMove(info.value()), { }).releaseReturnValue();
 74 }
 75 }
 76
 77 if (!request) {
 78 ASSERT(matchType == MatchType::All);
 79 refreshRequestToResponseMap([this, promise = WTFMove(promise)]() {
 80 Vector<Ref<FetchResponse>> responses;
 81 responses.reserveInitialCapacity(m_requestToResponseMap.size());
 82 for (auto& record : m_requestToResponseMap)
 83 responses.uncheckedAppend(record.response->cloneForJS());
 84 promise->resolve<IDLSequence<IDLInterface<FetchResponse>>>(responses);
 85 });
 86 return;
 87 }
 88 queryCache(request.releaseNonNull(), WTFMove(options), [matchType, promise = WTFMove(promise)](const Vector<CacheStorageRecord>& records) mutable {
 89 if (matchType == MatchType::OnlyFirst) {
 90 if (records.size()) {
 91 promise->resolve<IDLInterface<FetchResponse>>(records[0].response->cloneForJS());
 92 return;
 93 }
 94 promise->resolve();
 95 return;
 96 }
 97
 98 Vector<Ref<FetchResponse>> responses;
 99 responses.reserveInitialCapacity(records.size());
 100 for (auto& record : records)
 101 responses.uncheckedAppend(record.response->cloneForJS());
 102 promise->resolve<IDLSequence<IDLInterface<FetchResponse>>>(responses);
 103 });
39104}
40105
41106void Cache::add(RequestInfo&&, DOMPromiseDeferred<void>&& promise)
42107{
43  promise.reject(Exception { TypeError, ASCIILiteral("Not implemented")});
 108 promise.reject(Exception { NotSupportedError, ASCIILiteral("Not implemented")});
44109}
45110
46111void Cache::addAll(Vector<RequestInfo>&&, DOMPromiseDeferred<void>&& promise)
47112{
48  promise.reject(Exception { TypeError, ASCIILiteral("Not implemented")});
 113 promise.reject(Exception { NotSupportedError, ASCIILiteral("Not implemented")});
 114}
 115
 116void Cache::put(RequestInfo&& info, Ref<FetchResponse>&& response, DOMPromiseDeferred<void>&& promise)
 117{
 118 RefPtr<FetchRequest> request;
 119 if (WTF::holds_alternative<RefPtr<FetchRequest>>(info)) {
 120 request = WTF::get<RefPtr<FetchRequest>>(info).releaseNonNull();
 121 if (request->method() != "GET") {
 122 promise.reject(Exception { TypeError, ASCIILiteral("Request method is not GET") });
 123 return;
 124 }
 125 } else {
 126 if (UNLIKELY(!scriptExecutionContext()))
 127 return;
 128 request = FetchRequest::create(*scriptExecutionContext(), WTFMove(info), { }).releaseReturnValue();
 129 }
 130
 131 if (!protocolIsInHTTPFamily(request->url())) {
 132 promise.reject(Exception { TypeError, ASCIILiteral("Request url is not HTTP/HTTPS") });
 133 return;
 134 }
 135
 136 auto varyValue = response->headers().internalHeaders().get(WebCore::HTTPHeaderName::Vary);
 137 Vector<String> varyingHeaderNames;
 138 bool hasVaryHeaderStar = false;
 139 varyValue.split(',', false, [&](const StringView& view) {
 140 if (!hasVaryHeaderStar && view == "*")
 141 hasVaryHeaderStar = true;
 142 });
 143
 144 if (hasVaryHeaderStar) {
 145 promise.reject(Exception { TypeError, ASCIILiteral("Response has a '*' Vary header value") });
 146 return;
 147 }
 148
 149 if (response->isDisturbed()) {
 150 promise.reject(Exception { TypeError, ASCIILiteral("Response is disturbed or locked") });
 151 return;
 152 }
 153
 154 if (response->status() == 206) {
 155 promise.reject(Exception { TypeError, ASCIILiteral("Response is a 206 partial") });
 156 return;
 157 }
 158
 159 // FIXME: Add support for being loaded responses.
 160 if (response->isLoading()) {
 161 promise.reject(Exception { NotSupportedError, ASCIILiteral("Caching a loading Response is not yet supported") });
 162 return;
 163 }
 164
 165 // FIXME: Add support for ReadableStream.
 166 if (response->isReadableStreamBody()) {
 167 promise.reject(Exception { NotSupportedError, ASCIILiteral("Caching a Response with data stored in a ReadableStream is not yet supported") });
 168 return;
 169 }
 170
 171 batchPutOperation(*request, response.get(), [promise = WTFMove(promise)](CacheStorageConnection::Error error) mutable {
 172 if (error != CacheStorageConnection::Error::None) {
 173 promise.reject(CacheStorageConnection::exceptionFromError(error));
 174 return;
 175 }
 176 promise.resolve();
 177 });
 178}
 179
 180void Cache::remove(RequestInfo&& info, CacheQueryOptions&& options, DOMPromiseDeferred<IDLBoolean>&& promise)
 181{
 182 RefPtr<FetchRequest> request;
 183 if (WTF::holds_alternative<RefPtr<FetchRequest>>(info)) {
 184 request = WTF::get<RefPtr<FetchRequest>>(info).releaseNonNull();
 185 if (request->method() != "GET" && !options.ignoreMethod) {
 186 promise.resolve(false);
 187 return;
 188 }
 189 } else {
 190 if (UNLIKELY(!scriptExecutionContext()))
 191 return;
 192 request = FetchRequest::create(*scriptExecutionContext(), WTFMove(info), { }).releaseReturnValue();
 193 }
 194
 195 batchDeleteOperation(*request, WTFMove(options), [promise = WTFMove(promise)](bool didDelete, CacheStorageConnection::Error error) mutable {
 196 if (error != CacheStorageConnection::Error::None) {
 197 promise.reject(CacheStorageConnection::exceptionFromError(error));
 198 return;
 199 }
 200 promise.resolve(didDelete);
 201 });
 202}
 203
 204void Cache::keys(std::optional<RequestInfo>&& info, CacheQueryOptions&& options, KeysPromise&& promise)
 205{
 206 RefPtr<FetchRequest> request;
 207 if (info) {
 208 if (WTF::holds_alternative<RefPtr<FetchRequest>>(info.value())) {
 209 request = WTF::get<RefPtr<FetchRequest>>(info.value()).releaseNonNull();
 210 if (request->method() != "GET" && !options.ignoreMethod) {
 211 promise.resolve(Vector<Ref<FetchRequest>> { });
 212 return;
 213 }
 214 } else {
 215 if (UNLIKELY(!scriptExecutionContext()))
 216 return;
 217 request = FetchRequest::create(*scriptExecutionContext(), WTFMove(info.value()), { }).releaseReturnValue();
 218 }
 219 }
 220
 221 if (!request) {
 222 refreshRequestToResponseMap([this, promise = WTFMove(promise)]() mutable {
 223 Vector<Ref<FetchRequest>> requests;
 224 requests.reserveInitialCapacity(m_requestToResponseMap.size());
 225 for (auto& record : m_requestToResponseMap)
 226 requests.uncheckedAppend(record.request.copyRef());
 227 promise.resolve(requests);
 228 });
 229 return;
 230 }
 231
 232 queryCache(request.releaseNonNull(), WTFMove(options), [promise = WTFMove(promise)](const Vector<CacheStorageRecord>& records) mutable {
 233 Vector<Ref<FetchRequest>> requests;
 234 requests.reserveInitialCapacity(records.size());
 235 for (auto& record : records)
 236 requests.uncheckedAppend(record.request.copyRef());
 237 promise.resolve(requests);
 238 });
 239}
 240
 241void Cache::refreshRequestToResponseMap(WTF::Function<void()>&& callback)
 242{
 243 setPendingActivity(this);
 244 m_connection->refreshRecords(m_identifier, [this, callback = WTFMove(callback)](Vector<CacheStorageConnection::Record>&& records) {
 245 if (!m_isStopped) {
 246 updateRequestToResponseMap(WTFMove(records));
 247 callback();
 248 }
 249 unsetPendingActivity(this);
 250 });
 251}
 252
 253void Cache::queryCache(Ref<FetchRequest>&& request, CacheQueryOptions&& options, WTF::Function<void(const Vector<CacheStorageRecord>&)>&& callback)
 254{
 255 refreshRequestToResponseMap([this, request = WTFMove(request), options = WTFMove(options), callback = WTFMove(callback)]() mutable {
 256 callback(queryCacheWithTargetStorage(request.get(), options, m_requestToResponseMap));
 257 });
 258}
 259
 260static inline bool queryCacheMatch(const FetchRequest& request, const FetchRequest& cachedRequest, const ResourceResponse& cachedResponse, const CacheQueryOptions& options)
 261{
 262 // We need to pass the resource request with all correct headers hence why we call resourceRequest().
 263 return CacheStorageConnection::queryCacheMatch(request.resourceRequest(), cachedRequest.resourceRequest(), cachedResponse, options);
 264}
 265
 266Vector<CacheStorageRecord> Cache::queryCacheWithTargetStorage(const FetchRequest& request, const CacheQueryOptions& options, const Vector<CacheStorageRecord>& targetStorage)
 267{
 268 if (!options.ignoreMethod && request.method() != "GET")
 269 return { };
 270
 271 Vector<CacheStorageRecord> records;
 272 for (auto& record : targetStorage) {
 273 if (queryCacheMatch(request, record.request.get(), record.response->response(), options))
 274 records.append({ record.identifier, record.request.copyRef(), record.response.copyRef() });
 275 }
 276 return records;
 277}
 278
 279void Cache::batchDeleteOperation(const FetchRequest& request, CacheQueryOptions&& options, WTF::Function<void(bool didRemoval, CacheStorageConnection::Error error)>&& callback)
 280{
 281 setPendingActivity(this);
 282 m_connection->batchDeleteOperation(m_identifier, request.internalRequest().request, WTFMove(options), [this, callback = WTFMove(callback)](Vector<uint64_t>&& records, CacheStorageConnection::Error error) {
 283 if (!m_isStopped) {
 284 if (error == CacheStorageConnection::Error::None)
 285 m_requestToResponseMap.removeAllMatching([&](const auto& item) { return records.contains(item.identifier); });
 286
 287 callback(!!records.size(), error);
 288 }
 289 unsetPendingActivity(this);
 290 });
 291}
 292
 293static inline CacheStorageConnection::Record toConnectionRecord(const FetchRequest& request, FetchResponse& response)
 294{
 295 // FIXME: Add a setHTTPHeaderFields on ResourceResponseBase.
 296 ResourceResponse cachedResponse = response.response();
 297 for (auto& header : response.headers().internalHeaders())
 298 cachedResponse.setHTTPHeaderField(header.key, header.value);
 299
 300 ResourceRequest cachedRequest = request.internalRequest().request;
 301 cachedRequest.setHTTPHeaderFields(request.headers().internalHeaders());
 302
 303 return { 0,
 304 request.headers().guard(), WTFMove(cachedRequest), request.internalRequest().options, request.internalRequest().referrer,
 305 response.headers().guard(), WTFMove(cachedResponse)
 306 };
 307}
 308
 309void Cache::batchPutOperation(const FetchRequest& request, FetchResponse& response, WTF::Function<void(CacheStorageConnection::Error)>&& callback)
 310{
 311 Vector<CacheStorageConnection::Record> records;
 312 records.append(toConnectionRecord(request, response));
 313
 314 setPendingActivity(this);
 315 m_connection->batchPutOperation(m_identifier, WTFMove(records), [this, callback = WTFMove(callback)](Vector<uint64_t>&&, CacheStorageConnection::Error error) {
 316 if (!m_isStopped)
 317 callback(error);
 318
 319 unsetPendingActivity(this);
 320 });
 321}
 322
 323void Cache::updateRequestToResponseMap(Vector<CacheStorageConnection::Record>&& records)
 324{
 325 ASSERT(scriptExecutionContext());
 326 Vector<CacheStorageRecord> newMap;
 327
 328 for (auto& record : records) {
 329 size_t index = m_requestToResponseMap.findMatching([&](const auto& item) { return item.identifier == record.identifier; });
 330 if (index != notFound)
 331 newMap.append(WTFMove(m_requestToResponseMap[index]));
 332 else {
 333 auto requestHeaders = FetchHeaders::create(record.requestHeadersGuard, HTTPHeaderMap { record.request.httpHeaderFields() });
 334 FetchRequest::InternalRequest internalRequest = { WTFMove(record.request), WTFMove(record.options), WTFMove(record.referrer) };
 335 auto request = FetchRequest::create(*scriptExecutionContext(), std::nullopt, WTFMove(requestHeaders), WTFMove(internalRequest));
 336
 337 auto responseHeaders = FetchHeaders::create(record.responseHeadersGuard, HTTPHeaderMap { record.response.httpHeaderFields() });
 338 auto response = FetchResponse::create(*scriptExecutionContext(), std::nullopt, WTFMove(responseHeaders), WTFMove(record.response));
 339
 340 newMap.append(CacheStorageRecord { record.identifier, WTFMove(request), WTFMove(response) });
 341 }
 342 }
 343 m_requestToResponseMap = WTFMove(newMap);
49344}
50345
51 void Cache::put(RequestInfo&&, Ref<FetchResponse>&&, DOMPromiseDeferred<void>&& promise)
 346void Cache::stop()
52347{
53  promise.reject(Exception { TypeError, ASCIILiteral("Not implemented")});
 348 m_isStopped = true;
54349}
55350
56 void Cache::remove(RequestInfo&&, std::optional<CacheQueryOptions>&&, DOMPromiseDeferred<IDLBoolean>&& promise)
 351const char* Cache::activeDOMObjectName() const
57352{
58  promise.reject(Exception { TypeError, ASCIILiteral("Not implemented")});
 353 return "Cache";
59354}
60355
61 void Cache::keys(std::optional<RequestInfo>&&, std::optional<CacheQueryOptions>&&, KeysPromise&& promise)
 356bool Cache::canSuspendForDocumentSuspension() const
62357{
63  promise.reject(Exception { TypeError, ASCIILiteral("Not implemented")});
 358 return !m_requestToResponseMap.size() && !hasPendingActivity();
64359}
65360
66361

Source/WebCore/Modules/cache/Cache.h

2525
2626#pragma once
2727
28 #include "FetchRequest.h"
 28#include "ActiveDOMObject.h"
 29#include "CacheStorageConnection.h"
 30#include "CacheStorageRecord.h"
2931
3032namespace WebCore {
3133
32 class FetchResponse;
 34class CacheQueryOptions;
 35class ScriptExecutionContext;
3336
34 struct CacheQueryOptions;
35 
36 class Cache : public RefCounted<Cache> {
 37class Cache final : public RefCounted<Cache>, public ActiveDOMObject {
3738public:
38  static Ref<Cache> create(String&& name) { return adoptRef(*new Cache(WTFMove(name))); }
 39 static Ref<Cache> create(ScriptExecutionContext& context, String&& name, uint64_t identifier, Ref<CacheStorageConnection>&& connection) { return adoptRef(*new Cache(context, WTFMove(name), identifier, WTFMove(connection))); }
 40 ~Cache();
3941
4042 using RequestInfo = FetchRequest::Info;
4143
42  using MatchAllPromise = DOMPromiseDeferred<IDLSequence<IDLInterface<FetchResponse>>>;
4344 using KeysPromise = DOMPromiseDeferred<IDLSequence<IDLInterface<FetchRequest>>>;
4445
45  void match(RequestInfo&&, std::optional<CacheQueryOptions>&&, Ref<DeferredPromise>&&);
46  void matchAll(std::optional<RequestInfo>&&, std::optional<CacheQueryOptions>&&, MatchAllPromise&&);
 46 enum class MatchType { All, OnlyFirst };
 47 void match(RequestInfo&&, CacheQueryOptions&&, Ref<DeferredPromise>&&);
 48 void matchAll(std::optional<RequestInfo>&&, CacheQueryOptions&&, Ref<DeferredPromise>&&, MatchType = MatchType::All);
4749 void add(RequestInfo&&, DOMPromiseDeferred<void>&&);
4850
4951 void addAll(Vector<RequestInfo>&&, DOMPromiseDeferred<void>&&);
5052 void put(RequestInfo&&, Ref<FetchResponse>&&, DOMPromiseDeferred<void>&&);
51  void remove(RequestInfo&&, std::optional<CacheQueryOptions>&&, DOMPromiseDeferred<IDLBoolean>&&);
52  void keys(std::optional<RequestInfo>&&, std::optional<CacheQueryOptions>&&, KeysPromise&&);
 53 void remove(RequestInfo&&, CacheQueryOptions&&, DOMPromiseDeferred<IDLBoolean>&&);
 54 void keys(std::optional<RequestInfo>&&, CacheQueryOptions&&, KeysPromise&&);
 55
 56 const String& name() const { return m_name; }
 57 uint64_t identifier() const { return m_identifier; }
5358
5459private:
55  explicit Cache(String&& name) : m_name(WTFMove(name)) { }
 60 Cache(ScriptExecutionContext&, String&& name, uint64_t identifier, Ref<CacheStorageConnection>&&);
 61
 62 // ActiveDOMObject
 63 void stop() final;
 64 const char* activeDOMObjectName() const final;
 65 bool canSuspendForDocumentSuspension() const final;
 66
 67 void refreshRequestToResponseMap(WTF::Function<void()>&&);
 68 Vector<CacheStorageRecord> queryCacheWithTargetStorage(const FetchRequest&, const CacheQueryOptions&, const Vector<CacheStorageRecord>&);
 69 void queryCache(Ref<FetchRequest>&&, CacheQueryOptions&&, WTF::Function<void(const Vector<CacheStorageRecord>&)>&&);
 70 void batchDeleteOperation(const FetchRequest&, CacheQueryOptions&&, WTF::Function<void(bool didRemoval, CacheStorageConnection::Error)>&&);
 71 void batchPutOperation(const FetchRequest&, FetchResponse&, WTF::Function<void(CacheStorageConnection::Error)>&&);
 72
 73 void updateRequestToResponseMap(Vector<CacheStorageConnection::Record>&&);
5674
5775 String m_name;
 76 uint64_t m_identifier;
 77 Ref<CacheStorageConnection> m_connection;
 78
 79 Vector<CacheStorageRecord> m_requestToResponseMap;
 80 bool m_isStopped { false };
5881};
5982
6083} // namespace WebCore

Source/WebCore/Modules/cache/Cache.idl

@@typedef (FetchRequest or USVString) RequestInfo;
2929 SecureContext,
3030 Exposed=(Window,Worker),
3131 EnabledAtRuntime=CacheAPI,
32  ImplementationLacksVTable,
3332] interface Cache {
3433 [NewObject] Promise<any> match(RequestInfo request, optional CacheQueryOptions options);
3534 [NewObject] Promise<sequence<FetchResponse>> matchAll(optional RequestInfo request, optional CacheQueryOptions options);

Source/WebCore/Modules/cache/CacheQueryOptions.h

2929
3030namespace WebCore {
3131
32 struct CacheQueryOptions {
 32class CacheQueryOptions {
 33public:
3334 bool ignoreSearch { false };
3435 bool ignoreMethod { false };
3536 bool ignoreVary { false };

Source/WebCore/Modules/cache/CacheStorage.cpp

2626#include "config.h"
2727#include "CacheStorage.h"
2828
 29#include "CacheQueryOptions.h"
 30#include "JSCache.h"
 31#include "ScriptExecutionContext.h"
 32
2933namespace WebCore {
3034
31 void CacheStorage::match(RequestInfo&&, std::optional<CacheQueryOptions>&&, Ref<DeferredPromise>&& promise)
 35CacheStorage::CacheStorage(ScriptExecutionContext& context, Ref<CacheStorageConnection>&& connection)
 36 : ActiveDOMObject(&context)
 37 , m_connection(WTFMove(connection))
 38{
 39 suspendIfNeeded();
 40}
 41
 42String CacheStorage::origin() const
 43{
 44 // FIXME: Do we really need to check for origin being null?
 45 auto* origin = scriptExecutionContext() ? scriptExecutionContext()->securityOrigin() : nullptr;
 46 return origin ? origin->toString() : String();
 47}
 48
 49void CacheStorage::match(Cache::RequestInfo&&, CacheQueryOptions&&, Ref<DeferredPromise>&& promise)
3250{
33  promise->reject(Exception { TypeError, ASCIILiteral("Not implemented")});
 51 promise->reject(Exception { NotSupportedError, ASCIILiteral("Not implemented")});
3452}
3553
36 void CacheStorage::has(const String&, DOMPromiseDeferred<IDLBoolean>&& promise)
 54void CacheStorage::has(const String& name, DOMPromiseDeferred<IDLBoolean>&& promise)
3755{
38  promise.reject(Exception { TypeError, ASCIILiteral("Not implemented")});
 56 refreshCacheMap([this, name, promise = WTFMove(promise)]() mutable {
 57 promise.resolve(m_cacheMap.findMatching([&](auto& item) { return item->name() == name; }) != notFound);
 58 });
 59}
 60
 61void CacheStorage::refreshCacheMap(WTF::Function<void()>&& callback)
 62{
 63 String origin = this->origin();
 64 if (origin.isNull())
 65 return;
 66
 67 setPendingActivity(this);
 68 m_connection->refreshCacheMap(origin, [this, callback = WTFMove(callback)](Vector<CacheStorageConnection::CacheInfo>&& cachesInfo) {
 69 if (!m_isStopped) {
 70 ASSERT(scriptExecutionContext());
 71 m_cacheMap.removeAllMatching([&](auto& cache) {
 72 return cachesInfo.findMatching([&](const auto& info) { return info.identifier == cache->identifier(); }) == notFound;
 73 });
 74 for (auto& info : cachesInfo) {
 75 if (m_cacheMap.findMatching([&](const auto& cache) { return info.identifier == cache->identifier(); }) == notFound)
 76 m_cacheMap.append(Cache::create(*scriptExecutionContext(), WTFMove(info.name), info.identifier, m_connection.copyRef()));
 77 }
 78
 79 std::sort(m_cacheMap.begin(), m_cacheMap.end(), [&](auto& a, auto& b) {
 80 return a->identifier() < b->identifier();
 81 });
 82
 83 callback();
 84 }
 85 unsetPendingActivity(this);
 86 });
3987}
4088
41 void CacheStorage::open(const String&, DOMPromiseDeferred<IDLInterface<Cache>>&& promise)
 89void CacheStorage::open(const String& name, DOMPromiseDeferred<IDLInterface<Cache>>&& promise)
4290{
43  promise.reject(Exception { TypeError, ASCIILiteral("Not implemented")});
 91 refreshCacheMap([this, name, promise = WTFMove(promise)]() mutable {
 92 auto position = m_cacheMap.findMatching([&](auto& item) { return item->name() == name; });
 93 if (position != notFound) {
 94 auto& cache = m_cacheMap[position];
 95 promise.resolve(Cache::create(*scriptExecutionContext(), String { cache->name() }, cache->identifier(), m_connection.copyRef()));
 96 return;
 97 }
 98
 99 String origin = this->origin();
 100 if (origin.isNull())
 101 return;
 102
 103 setPendingActivity(this);
 104 m_connection->open(origin, name, [this, name, promise = WTFMove(promise)](uint64_t cacheIdentifier, CacheStorageConnection::Error error) mutable {
 105 if (!m_isStopped) {
 106 if (error != CacheStorageConnection::Error::None)
 107 promise.reject(CacheStorageConnection::exceptionFromError(error));
 108 else {
 109 auto cache = Cache::create(*scriptExecutionContext(), String { name }, cacheIdentifier, m_connection.copyRef());
 110 promise.resolve(cache);
 111 m_cacheMap.append(WTFMove(cache));
 112 }
 113 }
 114 unsetPendingActivity(this);
 115 });
 116 });
44117}
45118
46 void CacheStorage::remove(const String&, DOMPromiseDeferred<IDLBoolean>&& promise)
 119void CacheStorage::remove(const String& name, DOMPromiseDeferred<IDLBoolean>&& promise)
47120{
48  promise.reject(Exception { TypeError, ASCIILiteral("Not implemented")});
 121 refreshCacheMap([this, name, promise = WTFMove(promise)]() mutable {
 122 auto position = m_cacheMap.findMatching([&](auto& item) { return item->name() == name; });
 123 if (position == notFound) {
 124 promise.resolve(false);
 125 return;
 126 }
 127
 128 String origin = this->origin();
 129 if (origin.isNull())
 130 return;
 131
 132 setPendingActivity(this);
 133 m_connection->remove(m_cacheMap[position]->identifier(), [this, name, promise = WTFMove(promise)](uint64_t cacheIdentifier, CacheStorageConnection::Error error) mutable {
 134 UNUSED_PARAM(cacheIdentifier);
 135 if (!m_isStopped) {
 136 if (error != CacheStorageConnection::Error::None)
 137 promise.reject(CacheStorageConnection::exceptionFromError(error));
 138 else
 139 promise.resolve(true);
 140 }
 141 unsetPendingActivity(this);
 142 });
 143 m_cacheMap.remove(position);
 144 });
49145}
50146
51147void CacheStorage::keys(KeysPromise&& promise)
52148{
53  promise.reject(Exception { TypeError, ASCIILiteral("Not implemented")});
 149 refreshCacheMap([this, promise = WTFMove(promise)]() mutable {
 150 Vector<String> keys;
 151 keys.reserveInitialCapacity(m_cacheMap.size());
 152 for (auto& cache : m_cacheMap)
 153 keys.uncheckedAppend(cache->name());
 154 promise.resolve(keys);
 155 });
 156}
 157
 158void CacheStorage::stop()
 159{
 160 m_isStopped = true;
 161}
 162
 163const char* CacheStorage::activeDOMObjectName() const
 164{
 165 return "CacheStorage";
 166}
 167
 168bool CacheStorage::canSuspendForDocumentSuspension() const
 169{
 170 return !m_cacheMap.size() && !hasPendingActivity();
54171}
55172
56173} // namespace WebCore

Source/WebCore/Modules/cache/CacheStorage.h

2525
2626#pragma once
2727
 28#include "Cache.h"
 29#include "CacheStorageConnection.h"
2830#include "FetchRequest.h"
 31#include <wtf/Forward.h>
2932
3033namespace WebCore {
3134
32 class Cache;
 35class CacheQueryOptions;
 36class ScriptExecutionContext;
3337
34 struct CacheQueryOptions;
35 
36 class CacheStorage : public RefCounted<CacheStorage> {
 38class CacheStorage : public RefCounted<CacheStorage>, public ActiveDOMObject {
3739public:
38  static Ref<CacheStorage> create() { return adoptRef(*new CacheStorage()); }
 40 static Ref<CacheStorage> create(ScriptExecutionContext& context, Ref<CacheStorageConnection>&& connection) { return adoptRef(*new CacheStorage(context, WTFMove(connection))); }
3941
40  using RequestInfo = FetchRequest::Info;
4142 using KeysPromise = DOMPromiseDeferred<IDLSequence<IDLDOMString>>;
4243
43  void match(RequestInfo&&, std::optional<CacheQueryOptions>&&, Ref<DeferredPromise>&&);
 44 void match(Cache::RequestInfo&&, CacheQueryOptions&&, Ref<DeferredPromise>&&);
4445 void has(const String&, DOMPromiseDeferred<IDLBoolean>&&);
4546 void open(const String&, DOMPromiseDeferred<IDLInterface<Cache>>&&);
4647 void remove(const String&, DOMPromiseDeferred<IDLBoolean>&&);
4748 void keys(KeysPromise&&);
4849
4950private:
50  CacheStorage() = default;
 51 CacheStorage(ScriptExecutionContext&, Ref<CacheStorageConnection>&&);
 52
 53 // ActiveDOMObject
 54 void stop() final;
 55 const char* activeDOMObjectName() const final;
 56 bool canSuspendForDocumentSuspension() const final;
 57
 58 void refreshCacheMap(WTF::Function<void()>&&);
 59 String origin() const;
 60
 61 Vector<Ref<Cache>> m_cacheMap;
 62 Ref<CacheStorageConnection> m_connection;
 63 bool m_isStopped { false };
5164};
5265
5366} // namespace WebCore

Source/WebCore/Modules/cache/CacheStorage.idl

@@typedef (FetchRequest or USVString) RequestInfo;
2929 SecureContext,
3030 Exposed=(Window,Worker),
3131 EnabledAtRuntime=CacheAPI,
32  ImplementationLacksVTable,
3332] interface CacheStorage {
3433 [NewObject] Promise<any> match(RequestInfo request, optional CacheQueryOptions options);
3534 [NewObject] Promise<boolean> has(DOMString cacheName);

Source/WebCore/Modules/cache/CacheStorageConnection.cpp

 1
 2/*
 3 * Copyright (C) 2017 Apple 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 APPLE 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 APPLE 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 "CacheStorageConnection.h"
 29
 30#include "CacheQueryOptions.h"
 31#include "Exception.h"
 32
 33namespace WebCore {
 34
 35Exception CacheStorageConnection::exceptionFromError(Error error)
 36{
 37 ASSERT(error != Error::None);
 38
 39 switch (error) {
 40 case Error::NotImplemented:
 41 return Exception { TypeError, ASCIILiteral("Not implemented") };
 42 default:
 43 return Exception { TypeError, ASCIILiteral("Unknown error") };
 44 };
 45}
 46
 47bool CacheStorageConnection::queryCacheMatch(const ResourceRequest& request, const ResourceRequest& cachedRequest, const ResourceResponse& cachedResponse, const CacheQueryOptions& options)
 48{
 49 ASSERT(options.ignoreMethod || request.httpMethod() == "GET");
 50
 51 URL requestURL = request.url();
 52 URL cachedRequestURL = cachedRequest.url();
 53
 54 if (options.ignoreSearch) {
 55 requestURL.setQuery({ });
 56 cachedRequestURL.setQuery({ });
 57 }
 58 if (!equalIgnoringFragmentIdentifier(requestURL, cachedRequestURL))
 59 return false;
 60
 61 if (options.ignoreVary)
 62 return true;
 63
 64 String varyValue = cachedResponse.httpHeaderField(WebCore::HTTPHeaderName::Vary);
 65 if (varyValue.isNull())
 66 return true;
 67
 68 Vector<String> varyingHeaderNames;
 69 varyValue.split(',', varyingHeaderNames);
 70 if (varyingHeaderNames.contains("*"))
 71 return false;
 72
 73 for (auto& name : varyingHeaderNames) {
 74 if (cachedRequest.httpHeaderField(name) != request.httpHeaderField(name))
 75 return false;
 76 }
 77 return true;
 78}
 79
 80} // namespace WebCore
 81

Source/WebCore/Modules/cache/CacheStorageConnection.h

 1
 2/*
 3 * Copyright (C) 2017 Apple 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 APPLE 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 APPLE 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#pragma once
 28
 29#include "FetchHeaders.h"
 30#include "FetchOptions.h"
 31#include "ResourceRequest.h"
 32#include "ResourceResponse.h"
 33#include <wtf/ThreadSafeRefCounted.h>
 34
 35namespace WebCore {
 36
 37class CacheQueryOptions;
 38
 39class CacheStorageConnection : public ThreadSafeRefCounted<CacheStorageConnection> {
 40public:
 41 enum class Error {
 42 None,
 43 NotImplemented,
 44 };
 45
 46 WEBCORE_EXPORT static bool queryCacheMatch(const ResourceRequest& request, const ResourceRequest& cachedRequest, const ResourceResponse&, const CacheQueryOptions&);
 47
 48 static Exception exceptionFromError(Error);
 49
 50 struct Record {
 51 uint64_t identifier;
 52
 53 FetchHeaders::Guard requestHeadersGuard;
 54 ResourceRequest request;
 55 FetchOptions options;
 56 String referrer;
 57
 58 FetchHeaders::Guard responseHeadersGuard;
 59 ResourceResponse response;
 60 };
 61
 62 struct CacheInfo {
 63 uint64_t identifier;
 64 String name;
 65 };
 66
 67 static Ref<CacheStorageConnection> create() { return adoptRef(*new CacheStorageConnection()); }
 68 virtual ~CacheStorageConnection() = default;
 69
 70 using OpenRemoveCallback = WTF::Function<void(uint64_t, Error)>;
 71 using CacheMapCallback = WTF::Function<void(Vector<CacheInfo>&&)>;
 72 using RecordsCallback = WTF::Function<void(Vector<Record>&&)>;
 73 using BatchOperationCallback = WTF::Function<void(Vector<uint64_t>&&, Error)>;
 74
 75 virtual void open(const String& /* origin */, const String& /* cacheName */, OpenRemoveCallback&& callback) { callback(0, Error::NotImplemented); }
 76 virtual void remove(uint64_t /* cacheIdentifier */, OpenRemoveCallback&& callback) { callback(0, Error::NotImplemented); }
 77 virtual void refreshCacheMap(const String& /* origin */, CacheMapCallback&& callback) { callback({ }); }
 78
 79 virtual void refreshRecords(uint64_t /* cacheIdentifier */, RecordsCallback&& callback) { callback({ }); }
 80 virtual void batchDeleteOperation(uint64_t /* cacheIdentifier */, const ResourceRequest&, CacheQueryOptions&&, BatchOperationCallback&& callback) { callback({ }, Error::NotImplemented); }
 81 virtual void batchPutOperation(uint64_t /* cacheIdentifier */, Vector<Record>&&, BatchOperationCallback&& callback) { callback({ }, Error::NotImplemented); }
 82};
 83
 84} // namespace WebCore
 85

Source/WebCore/Modules/cache/CacheStorageRecord.h

 1/*
 2 * Copyright (C) 2017 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#pragma once
 27
 28#include "FetchRequest.h"
 29#include "FetchResponse.h"
 30
 31namespace WebCore {
 32
 33struct CacheStorageRecord {
 34 uint64_t identifier;
 35
 36 Ref<FetchRequest> request;
 37 Ref<FetchResponse> response;
 38};
 39
 40} // namespace WebCore

Source/WebCore/Modules/cache/DOMWindowCaches.cpp

2727#include "DOMWindowCaches.h"
2828
2929#include "CacheStorage.h"
 30#include "CacheStorageProvider.h"
3031#include "DOMWindow.h"
 32#include "Document.h"
 33#include "Frame.h"
 34#include "Page.h"
3135
3236namespace WebCore {
3337

@@CacheStorage* DOMWindowCaches::caches(DOMWindow& window)
5963
6064CacheStorage* DOMWindowCaches::caches() const
6165{
62  if (!m_caches && frame())
63  m_caches = CacheStorage::create();
 66 if (!m_caches && frame() && frame()->page() && frame()->document())
 67 m_caches = CacheStorage::create(*frame()->document(), frame()->page()->cacheStorageProvider().createCacheStorageConnection(frame()->page()->sessionID()));
6468 return m_caches.get();
6569}
6670

Source/WebCore/Modules/cache/WorkerGlobalScopeCaches.cpp

@@WorkerGlobalScopeCaches* WorkerGlobalScopeCaches::from(WorkerGlobalScope& scope)
4040{
4141 auto* supplement = static_cast<WorkerGlobalScopeCaches*>(Supplement<WorkerGlobalScope>::from(&scope, supplementName()));
4242 if (!supplement) {
43  auto newSupplement = std::make_unique<WorkerGlobalScopeCaches>();
 43 auto newSupplement = std::make_unique<WorkerGlobalScopeCaches>(scope);
4444 supplement = newSupplement.get();
4545 provideTo(&scope, supplementName(), WTFMove(newSupplement));
4646 }

@@CacheStorage* WorkerGlobalScopeCaches::caches(WorkerGlobalScope& scope)
5555CacheStorage* WorkerGlobalScopeCaches::caches() const
5656{
5757 if (!m_caches)
58  m_caches = CacheStorage::create();
 58 m_caches = CacheStorage::create(m_scope, CacheStorageConnection::create());
5959 return m_caches.get();
6060}
6161

Source/WebCore/Modules/cache/WorkerGlobalScopeCaches.h

@@class WorkerGlobalScope;
3434
3535class WorkerGlobalScopeCaches : public Supplement<WorkerGlobalScope> {
3636public:
37  WorkerGlobalScopeCaches() = default;
 37 WorkerGlobalScopeCaches(WorkerGlobalScope& scope) : m_scope(scope) { };
3838
3939 static CacheStorage* caches(WorkerGlobalScope&);
4040

@@private:
4343 static const char* supplementName();
4444 CacheStorage* caches() const;
4545
 46 WorkerGlobalScope& m_scope;
4647 mutable RefPtr<CacheStorage> m_caches;
4748};
4849

Source/WebCore/Modules/fetch/FetchBodyOwner.h

@@public:
5757
5858 bool isActive() const { return !!m_blobLoader; }
5959
 60 bool isReadableStreamBody() const { return m_body && m_body->isReadableStream(); }
 61
6062protected:
6163 const FetchBody& body() const { return *m_body; }
6264 FetchBody& body() { return *m_body; }

Source/WebCore/Modules/fetch/FetchHeaders.h

3030
3131#include "ExceptionOr.h"
3232#include "HTTPHeaderMap.h"
 33#include <wtf/EnumTraits.h>
3334#include <wtf/HashTraits.h>
3435#include <wtf/Variant.h>
3536#include <wtf/Vector.h>

@@public:
4950 using Init = Variant<Vector<Vector<String>>, Vector<WTF::KeyValuePair<String, String>>>;
5051 static ExceptionOr<Ref<FetchHeaders>> create(std::optional<Init>&&);
5152
52  static Ref<FetchHeaders> create(Guard guard = Guard::None) { return adoptRef(*new FetchHeaders { guard }); }
 53 static Ref<FetchHeaders> create(Guard guard = Guard::None, HTTPHeaderMap&& headers = { }) { return adoptRef(*new FetchHeaders { guard, WTFMove(headers) }); }
5354 static Ref<FetchHeaders> create(const FetchHeaders& headers) { return adoptRef(*new FetchHeaders { headers }); }
5455
5556 ExceptionOr<void> append(const String& name, const String& value);

@@public:
8283 const HTTPHeaderMap& internalHeaders() const { return m_headers; }
8384
8485 void setGuard(Guard);
 86 Guard guard() const { return m_guard; }
8587
8688private:
87  explicit FetchHeaders(Guard guard, HTTPHeaderMap&& headers = { });
 89 FetchHeaders(Guard, HTTPHeaderMap&&);
8890 FetchHeaders(const FetchHeaders&);
8991
9092 Guard m_guard;

@@inline void FetchHeaders::setGuard(Guard guard)
111113}
112114
113115} // namespace WebCore
 116
 117namespace WTF {
 118
 119template<> struct EnumTraits<WebCore::FetchHeaders::Guard> {
 120 using values = EnumValues<
 121 WebCore::FetchHeaders::Guard,
 122 WebCore::FetchHeaders::Guard::None,
 123 WebCore::FetchHeaders::Guard::Immutable,
 124 WebCore::FetchHeaders::Guard::Request,
 125 WebCore::FetchHeaders::Guard::RequestNoCors,
 126 WebCore::FetchHeaders::Guard::Response
 127 >;
 128};
 129
 130}

Source/WebCore/Modules/fetch/FetchLoader.cpp

@@void FetchLoader::start(ScriptExecutionContext& context, const FetchRequest& req
8181 options.dataBufferingPolicy = DoNotBufferData;
8282 options.sameOriginDataURLFlag = SameOriginDataURLFlag::Set;
8383
84  ResourceRequest fetchRequest = request.internalRequest();
 84 ResourceRequest fetchRequest = request.resourceRequest();
8585
8686 ASSERT(context.contentSecurityPolicy());
8787 auto& contentSecurityPolicy = *context.contentSecurityPolicy();

Source/WebCore/Modules/fetch/FetchRequest.cpp

@@static std::optional<Exception> setReferrer(FetchRequest::InternalRequest& reque
7474
7575static std::optional<Exception> buildOptions(FetchRequest::InternalRequest& request, ScriptExecutionContext& context, const FetchRequest::Init& init)
7676{
77  if (!init.window.isUndefinedOrNull())
 77 if (!init.window.isUndefinedOrNull() && !init.window.isEmpty())
7878 return Exception { TypeError, ASCIILiteral("Window can only be null.") };
7979
8080 if (!init.referrer.isNull()) {

@@const String& FetchRequest::url() const
264264 return m_requestURL;
265265}
266266
267 ResourceRequest FetchRequest::internalRequest() const
 267ResourceRequest FetchRequest::resourceRequest() const
268268{
269269 ASSERT(scriptExecutionContext());
270270

Source/WebCore/Modules/fetch/FetchRequest.h

@@public:
5353 using Redirect = FetchOptions::Redirect;
5454 using Type = FetchOptions::Type;
5555
 56 struct InternalRequest {
 57 ResourceRequest request;
 58 FetchOptions options;
 59 String referrer;
 60 };
 61
5662 static ExceptionOr<Ref<FetchRequest>> create(ScriptExecutionContext&, Info&&, Init&&);
 63 static Ref<FetchRequest> create(ScriptExecutionContext& context, std::optional<FetchBody>&& body, Ref<FetchHeaders>&& headers, InternalRequest&& request) { return adoptRef(*new FetchRequest(context, WTFMove(body), WTFMove(headers), WTFMove(request))); }
5764
5865 const String& method() const { return m_internalRequest.request.httpMethod(); }
5966 const String& url() const;
6067 FetchHeaders& headers() { return m_headers.get(); }
 68 const FetchHeaders& headers() const { return m_headers.get(); }
6169
6270 Type type() const;
6371 Destination destination() const;

@@public:
7381
7482 ExceptionOr<Ref<FetchRequest>> clone(ScriptExecutionContext&);
7583
76  struct InternalRequest {
77  ResourceRequest request;
78  FetchOptions options;
79  String referrer;
80  };
 84 const InternalRequest& internalRequest() const { return m_internalRequest; }
8185
8286 const FetchOptions& fetchOptions() const { return m_internalRequest.options; }
83  ResourceRequest internalRequest() const;
 87 ResourceRequest resourceRequest() const;
8488 bool isBodyReadableStream() const { return !isBodyNull() && body().isReadableStream(); }
8589
8690 const String& internalRequestReferrer() const { return m_internalRequest.referrer; }
 91 const URL& internalRequestURL() const { return m_internalRequest.request.url(); }
8792
8893private:
8994 FetchRequest(ScriptExecutionContext&, std::optional<FetchBody>&&, Ref<FetchHeaders>&&, InternalRequest&&);

Source/WebCore/Modules/fetch/FetchResponse.h

@@public:
5757 static Ref<FetchResponse> error(ScriptExecutionContext&);
5858 static ExceptionOr<Ref<FetchResponse>> redirect(ScriptExecutionContext&, const String& url, int status);
5959
 60 static Ref<FetchResponse> create(ScriptExecutionContext& context, std::optional<FetchBody>&& body, Ref<FetchHeaders>&& headers, ResourceResponse&& response) { return adoptRef(*new FetchResponse(context, WTFMove(body), WTFMove(headers), WTFMove(response))); }
 61
6062 using FetchPromise = DOMPromiseDeferred<IDLInterface<FetchResponse>>;
6163 static void fetch(ScriptExecutionContext&, FetchRequest&, FetchPromise&&);
6264

@@public:
7880 bool ok() const { return m_response.isSuccessful(); }
7981 const String& statusText() const { return m_response.httpStatusText(); }
8082
 83 const FetchHeaders& headers() const { return m_headers; }
8184 FetchHeaders& headers() { return m_headers; }
8285 Ref<FetchResponse> cloneForJS();
8386

@@public:
9093
9194 bool isLoading() const { return !!m_bodyLoader; }
9295
 96 const ResourceResponse& response() const { return m_response; }
 97
9398private:
9499 FetchResponse(ScriptExecutionContext&, std::optional<FetchBody>&&, Ref<FetchHeaders>&&, ResourceResponse&&);
95100

Source/WebCore/WebCore.xcodeproj/project.pbxproj

17841784 41CF8BE71D46226700707DC9 /* FetchBodyConsumer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41CF8BE41D46222000707DC9 /* FetchBodyConsumer.cpp */; };
17851785 41D015CA0F4B5C71004A662F /* ContentType.h in Headers */ = {isa = PBXBuildFile; fileRef = 41D015C80F4B5C71004A662F /* ContentType.h */; settings = {ATTRIBUTES = (Private, ); }; };
17861786 41D015CB0F4B5C71004A662F /* ContentType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41D015C90F4B5C71004A662F /* ContentType.cpp */; };
 1787 41D129CE1F3D0EF600D15E47 /* WorkerGlobalScopeCaches.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FB278D1F34C28200795487 /* WorkerGlobalScopeCaches.h */; };
 1788 41D129CF1F3D0EFE00D15E47 /* CacheStorageConnection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41D129C91F3D0EE300D15E47 /* CacheStorageConnection.cpp */; };
 1789 41D129D01F3D0F0500D15E47 /* CacheQueryOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FB279B1F34CEF000795487 /* CacheQueryOptions.h */; };
 1790 41D129D11F3D0F0E00D15E47 /* DOMWindowCaches.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FB278C1F34C28200795487 /* DOMWindowCaches.h */; };
 1791 41D129D21F3D0F1200D15E47 /* CacheStorageRecord.h in Headers */ = {isa = PBXBuildFile; fileRef = 41D129CA1F3D0EE300D15E47 /* CacheStorageRecord.h */; };
 1792 41D129D31F3D0F1600D15E47 /* CacheStorageConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 41D129CC1F3D0EE300D15E47 /* CacheStorageConnection.h */; settings = {ATTRIBUTES = (Private, ); }; };
 1793 41D129D51F3D0F6900D15E47 /* CacheStorageProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 41D129D41F3D0F6600D15E47 /* CacheStorageProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
 1794 41D129DB1F3D143800D15E47 /* FetchHeaders.h in Headers */ = {isa = PBXBuildFile; fileRef = 41F54F831C50C4F600338488 /* FetchHeaders.h */; settings = {ATTRIBUTES = (Private, ); }; };
17871795 41DEFCB51E56C1BD000D9E5F /* JSDOMMapLike.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41DEFCB31E56C1B9000D9E5F /* JSDOMMapLike.cpp */; };
17881796 41DEFCB61E56C1BD000D9E5F /* JSDOMMapLike.h in Headers */ = {isa = PBXBuildFile; fileRef = 41DEFCB41E56C1B9000D9E5F /* JSDOMMapLike.h */; };
17891797 41E1B1D00FF5986900576B3B /* AbstractWorker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41E1B1CA0FF5986900576B3B /* AbstractWorker.cpp */; };

94659473 41CF8BE61D46222C00707DC9 /* FetchInternals.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = FetchInternals.js; sourceTree = "<group>"; };
94669474 41D015C80F4B5C71004A662F /* ContentType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContentType.h; sourceTree = "<group>"; };
94679475 41D015C90F4B5C71004A662F /* ContentType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContentType.cpp; sourceTree = "<group>"; };
 9476 41D129C91F3D0EE300D15E47 /* CacheStorageConnection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CacheStorageConnection.cpp; sourceTree = "<group>"; };
 9477 41D129CA1F3D0EE300D15E47 /* CacheStorageRecord.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CacheStorageRecord.h; sourceTree = "<group>"; };
 9478 41D129CC1F3D0EE300D15E47 /* CacheStorageConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CacheStorageConnection.h; sourceTree = "<group>"; };
 9479 41D129D41F3D0F6600D15E47 /* CacheStorageProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CacheStorageProvider.h; sourceTree = "<group>"; };
94689480 41D51BB21E4E2E8100131A5B /* LibWebRTCAudioFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LibWebRTCAudioFormat.h; path = libwebrtc/LibWebRTCAudioFormat.h; sourceTree = "<group>"; };
94699481 41DEFCB21E56C1B9000D9E5F /* JSDOMBindingInternals.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = JSDOMBindingInternals.js; sourceTree = "<group>"; };
94709482 41DEFCB31E56C1B9000D9E5F /* JSDOMMapLike.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMMapLike.cpp; sourceTree = "<group>"; };

1767417686 41380C211F34368D00155FDA /* CacheStorage.cpp */,
1767517687 41380C221F34369000155FDA /* CacheStorage.h */,
1767617688 41380C241F34369700155FDA /* CacheStorage.idl */,
 17689 41D129C91F3D0EE300D15E47 /* CacheStorageConnection.cpp */,
 17690 41D129CC1F3D0EE300D15E47 /* CacheStorageConnection.h */,
 17691 41D129CA1F3D0EE300D15E47 /* CacheStorageRecord.h */,
1767717692 41FB278E1F34C28200795487 /* DOMWindowCaches.cpp */,
1767817693 41FB278C1F34C28200795487 /* DOMWindowCaches.h */,
1767917694 41380C2B1F343E2F00155FDA /* DOMWindowCaches.idl */,

1927219287 BC124EE60C2641CD009E2349 /* BarProp.idl */,
1927319288 460BB6131D0A1BEC00221812 /* Base64Utilities.cpp */,
1927419289 460BB6141D0A1BEC00221812 /* Base64Utilities.h */,
 19290 41D129D41F3D0F6600D15E47 /* CacheStorageProvider.h */,
1927519291 072CA86016CB4DC3008AE131 /* CaptionUserPreferences.cpp */,
1927619292 079D0867162F20E800DB8658 /* CaptionUserPreferences.h */,
1927719293 079D086A162F21F900DB8658 /* CaptionUserPreferencesMediaAF.cpp */,

2656326579 29ACB212143E7128006BCA5F /* AccessibilityMockObject.h in Headers */,
2656426580 29A812360FBB9C1D00510293 /* AccessibilityObject.h in Headers */,
2656526581 A409C985116D0DDD007197BD /* AccessibilityProgressIndicator.h in Headers */,
26566  51F175641F3EBC8300C74950 /* ServiceWorkerJobClient.h in Headers */,
2656726582 29A812390FBB9C1D00510293 /* AccessibilityRenderObject.h in Headers */,
2656826583 93C4F6EB1108F9A50099D0DB /* AccessibilityScrollbar.h in Headers */,
2656926584 29489FC712C00F0300D83F0F /* AccessibilityScrollView.h in Headers */,

2678926804 0753860314489E9800B78452 /* CachedTextTrack.h in Headers */,
2679026805 BCB16C280979C3BD00467741 /* CachedXSLStyleSheet.h in Headers */,
2679126806 93F1995008245E59001E9ABC /* CachePolicy.h in Headers */,
 26807 41D129D01F3D0F0500D15E47 /* CacheQueryOptions.h in Headers */,
2679226808 41380C291F3436AC00155FDA /* CacheStorage.h in Headers */,
 26809 41D129D31F3D0F1600D15E47 /* CacheStorageConnection.h in Headers */,
 26810 41D129D51F3D0F6900D15E47 /* CacheStorageProvider.h in Headers */,
 26811 41D129D21F3D0F1200D15E47 /* CacheStorageRecord.h in Headers */,
2679326812 E43AF8E71AC5B7EC00CA717E /* CacheValidation.h in Headers */,
2679426813 49AE2D97134EE5F90072920A /* CalculationValue.h in Headers */,
2679526814 7C1E8D011ED0C2DA00B1D983 /* CallbackResult.h in Headers */,

2685026869 BCDD454E1236C95C009A7985 /* ColumnInfo.h in Headers */,
2685126870 43EDD67F1B485DBF00640E75 /* CombinedFiltersAlphabet.h in Headers */,
2685226871 26E944D91AC4B2DD007B85B5 /* CombinedURLFilters.h in Headers */,
26853  51F175691F3EBC8300C74950 /* ServiceWorkerRegistrationOptions.h in Headers */,
2685426872 A584FE351864D5AF00843B10 /* CommandLineAPIHost.h in Headers */,
2685526873 A584FE2C1863870F00843B10 /* CommandLineAPIModule.h in Headers */,
2685626874 A584FE2618637DAB00843B10 /* CommandLineAPIModuleSource.h in Headers */,

2719227210 8372DB311A6780A800C697C5 /* DiagnosticLoggingResultType.h in Headers */,
2719327211 CECADFC7153778FF00E37068 /* DictationAlternative.h in Headers */,
2719427212 CECADFC9153778FF00E37068 /* DictationCommand.h in Headers */,
27195  51F175631F3EBC8300C74950 /* ServiceWorkerJob.h in Headers */,
2719627213 D0BD4F5D1408850F006839B6 /* DictationCommandIOS.h in Headers */,
2719727214 937FF3D51A1012D6008EBA31 /* DictionaryLookup.h in Headers */,
2719827215 2D5646B01B8F8493003C4994 /* DictionaryPopupInfo.h in Headers */,

2724627263 A9C6E4E80D745E18006442E9 /* DOMMimeTypeArray.h in Headers */,
2724727264 52B6C9C315E3F4DF00690B05 /* DOMNamedFlowCollection.h in Headers */,
2724827265 1ACE53E80A8D18E70022947D /* DOMParser.h in Headers */,
27249  51F1755F1F3EBC8300C74950 /* ServiceWorkerContainer.h in Headers */,
2725027266 7A54881714E432A1006AE05A /* DOMPatchSupport.h in Headers */,
2725127267 FB91392416AE4C17001FE682 /* DOMPath.h in Headers */,
2725227268 A9C6E4EC0D745E2B006442E9 /* DOMPlugin.h in Headers */,

2727027286 2E37DFDB12DBAFB800A6B233 /* DOMURL.h in Headers */,
2727127287 CD9DE18217AAD6A400EA386D /* DOMURLMediaSource.h in Headers */,
2727227288 1403B99709EB13AF00797C7F /* DOMWindow.h in Headers */,
 27289 41D129D11F3D0F0E00D15E47 /* DOMWindowCaches.h in Headers */,
2727327290 51FA2D78152132B300C1BA0B /* DOMWindowExtension.h in Headers */,
2727427291 5185FC751BB4C4E80012898F /* DOMWindowIndexedDatabase.h in Headers */,
2727527292 97D2AD0414B823A60093DF32 /* DOMWindowProperty.h in Headers */,

2736527382 84730D851248F0B300D3A9C9 /* FEMorphology.h in Headers */,
2736627383 84730D871248F0B300D3A9C9 /* FEOffset.h in Headers */,
2736727384 84730D891248F0B300D3A9C9 /* FESpecularLighting.h in Headers */,
 27385 41D129DB1F3D143800D15E47 /* FetchHeaders.h in Headers */,
2736827386 416E6FE81BBD12DF000A6023 /* FetchInternalsBuiltins.h in Headers */,
2736927387 41AD753A1CEF6BD100A31486 /* FetchOptions.h in Headers */,
2737027388 7CE1914D1F2A9AFB00272F78 /* FetchReferrerPolicy.h in Headers */,

2832528343 5E2C43741BCF0D750001E2BC /* JSRTCRtpSender.h in Headers */,
2832628344 5E2C43721BCF0D750001E2BD /* JSRTCRtpTransceiver.h in Headers */,
2832728345 316DCB221E78CA55001B5F87 /* JSRTCRtpTransceiverDirection.h in Headers */,
28328  51F1756C1F3EBC8300C74950 /* ServiceWorkerUpdateViaCache.h in Headers */,
2832928346 07969DBC17D14151007FF842 /* JSRTCSessionDescription.h in Headers */,
2833028347 316DCB501E7910A6001B5F87 /* JSRTCSignalingState.h in Headers */,
2833128348 07969DC217D14151007FF842 /* JSRTCStatsReport.h in Headers */,

2841128428 B2FA3D810AB75A6F000E5AC4 /* JSSVGFEFuncRElement.h in Headers */,
2841228429 B2FA3D830AB75A6F000E5AC4 /* JSSVGFEGaussianBlurElement.h in Headers */,
2841328430 B2FA3D850AB75A6F000E5AC4 /* JSSVGFEImageElement.h in Headers */,
28414  51F175681F3EBC8300C74950 /* ServiceWorkerRegistration.h in Headers */,
2841528431 B2FA3D870AB75A6F000E5AC4 /* JSSVGFEMergeElement.h in Headers */,
2841628432 B2FA3D890AB75A6F000E5AC4 /* JSSVGFEMergeNodeElement.h in Headers */,
2841728433 84224184107E77F400766A87 /* JSSVGFEMorphologyElement.h in Headers */,

2868528701 A516E8B7136E04DB0076C3C0 /* LocalizedDateCache.h in Headers */,
2868628702 935207BE09BD410A00F2038D /* LocalizedStrings.h in Headers */,
2868728703 BCE1C41B0D982980003B02F2 /* Location.h in Headers */,
28688  51F175611F3EBC8300C74950 /* ServiceWorkerGlobalScope.h in Headers */,
2868928704 A8239E0109B3CF8A00B60641 /* Logging.h in Headers */,
2869028705 9BA273F4172206BB0097CE47 /* LogicalSelectionOffsetCaches.h in Headers */,
2869128706 0FDCD7F31D47E655009F08BC /* LogInitialization.h in Headers */,

2905329068 935C476809AC4D4300A6AAB4 /* PlatformKeyboardEvent.h in Headers */,
2905429069 0562F9611573F88F0031CA16 /* PlatformLayer.h in Headers */,
2905529070 F544F78915CFB2A800AF33A8 /* PlatformLocale.h in Headers */,
29056  51F1755D1F3EBC8300C74950 /* ServiceWorker.h in Headers */,
2905729071 CEEFCD7C19DB33DC003876D7 /* PlatformMediaResourceLoader.h in Headers */,
2905829072 070E09191875EEFC003A1D3C /* PlatformMediaSession.h in Headers */,
2905929073 07F944161864D046005D31CB /* PlatformMediaSessionManager.h in Headers */,

2942829442 CA3BF67E10D99BAE00E6CE53 /* ScrollAnimator.h in Headers */,
2942929443 0F1774801378B772009DA76A /* ScrollAnimatorIOS.h in Headers */,
2943029444 BCAE1FA712939DB7004CB026 /* ScrollAnimatorMac.h in Headers */,
29431  51F1756B1F3EBC8300C74950 /* ServiceWorkerRegistrationParameters.h in Headers */,
2943229445 5CB37FFF1C62D2A100F20188 /* ScrollAnimatorMock.h in Headers */,
2943329446 93F199B808245E59001E9ABC /* Scrollbar.h in Headers */,
2943429447 BC8B854B0E7C7F5600AB6984 /* ScrollbarTheme.h in Headers */,

2949629509 A75E497610752ACB00C9B896 /* SerializedScriptValue.h in Headers */,
2949729510 516F7F6D1C31E39A00F111DC /* ServerOpenDBRequest.h in Headers */,
2949829511 2D93AEE319DF5641002A86C3 /* ServicesOverlayController.h in Headers */,
 29512 51F1755D1F3EBC8300C74950 /* ServiceWorker.h in Headers */,
 29513 51F1755F1F3EBC8300C74950 /* ServiceWorkerContainer.h in Headers */,
 29514 51F175611F3EBC8300C74950 /* ServiceWorkerGlobalScope.h in Headers */,
 29515 51F175631F3EBC8300C74950 /* ServiceWorkerJob.h in Headers */,
 29516 51F175641F3EBC8300C74950 /* ServiceWorkerJobClient.h in Headers */,
 29517 51F175661F3EBC8300C74950 /* ServiceWorkerProvider.h in Headers */,
 29518 51F175681F3EBC8300C74950 /* ServiceWorkerRegistration.h in Headers */,
 29519 51F175691F3EBC8300C74950 /* ServiceWorkerRegistrationOptions.h in Headers */,
 29520 51F1756B1F3EBC8300C74950 /* ServiceWorkerRegistrationParameters.h in Headers */,
 29521 51F1756C1F3EBC8300C74950 /* ServiceWorkerUpdateViaCache.h in Headers */,
2949929522 756B2CE118B7101600FECFAA /* SessionID.h in Headers */,
2950029523 93309E10099E64920056E581 /* SetNodeAttributeCommand.h in Headers */,
2950129524 B8DBDB4C130B0F8A00F5CDB1 /* SetSelectionCommand.h in Headers */,

3000830031 2D7ED0AB1BAE99170043B3E5 /* TimerEventBasedMock.h in Headers */,
3000930032 49E912AE0EFAC906009D0CAF /* TimingFunction.h in Headers */,
3001030033 0F54DD081881D5F5003EEDBB /* Touch.h in Headers */,
30011  51F175661F3EBC8300C74950 /* ServiceWorkerProvider.h in Headers */,
3001230034 0F54DD091881D5F5003EEDBB /* TouchEvent.h in Headers */,
3001330035 0F54DD0A1881D5F5003EEDBB /* TouchList.h in Headers */,
3001430036 070334D71459FFD5008D8D45 /* TrackBase.h in Headers */,

3028030302 A52A68661DBD4B5D0083373F /* WorkerDebuggerAgent.h in Headers */,
3028130303 A3E2643114748991005A8588 /* WorkerEventQueue.h in Headers */,
3028230304 2E4346490F546A8200B0F1BA /* WorkerGlobalScope.h in Headers */,
 30305 41D129CE1F3D0EF600D15E47 /* WorkerGlobalScopeCaches.h in Headers */,
3028330306 5185FCB41BB4C4E80012898F /* WorkerGlobalScopeIndexedDatabase.h in Headers */,
3028430307 2E43464B0F546A8200B0F1BA /* WorkerGlobalScopeProxy.h in Headers */,
3028530308 A54A0C621DB7F8C10017A90B /* WorkerInspectorController.h in Headers */,

3089230915 0753860214489E9800B78452 /* CachedTextTrack.cpp in Sources */,
3089330916 BCB16C270979C3BD00467741 /* CachedXSLStyleSheet.cpp in Sources */,
3089430917 41380C281F3436AC00155FDA /* CacheStorage.cpp in Sources */,
 30918 41D129CF1F3D0EFE00D15E47 /* CacheStorageConnection.cpp in Sources */,
3089530919 E43AF8E61AC5B7E800CA717E /* CacheValidation.cpp in Sources */,
3089630920 49AE2D96134EE5F90072920A /* CalculationValue.cpp in Sources */,
3089730921 952076041F2675FE007D2AAB /* CallTracer.cpp in Sources */,

3121831242 CECADFC6153778FF00E37068 /* DictationAlternative.cpp in Sources */,
3121931243 CECADFC8153778FF00E37068 /* DictationCommand.cpp in Sources */,
3122031244 D0BD4F5C1408850F006839B6 /* DictationCommandIOS.cpp in Sources */,
31221  51F1756A1F3EBC8300C74950 /* ServiceWorkerRegistrationParameters.cpp in Sources */,
3122231245 937FF3D71A10131B008EBA31 /* DictionaryLookup.mm in Sources */,
3122331246 FDAF19981513D131008DB0C3 /* DirectConvolver.cpp in Sources */,
3122431247 7E4DE10D198B10B60051CB02 /* DiskCacheMonitorCocoa.mm in Sources */,

3173031753 A77979190D6B9D0C003851B9 /* ImageData.cpp in Sources */,
3173131754 555B87EC1CAAF0AB00349425 /* ImageDecoderCG.cpp in Sources */,
3173231755 97205AB51239291000B17380 /* ImageDocument.cpp in Sources */,
31733  51F1755C1F3EBC8300C74950 /* ServiceWorker.cpp in Sources */,
3173431756 5576A5641D88A70800CCC04C /* ImageFrame.cpp in Sources */,
3173531757 5597F8261D91C3130066BC21 /* ImageFrameCache.cpp in Sources */,
3173631758 F55B3DC11251F12D003EF269 /* ImageInputType.cpp in Sources */,

3210532127 1AE2AA2E0A1CDAB400B42B25 /* JSHTMLHeadingElement.cpp in Sources */,
3210632128 1AE2AA300A1CDAB400B42B25 /* JSHTMLHRElement.cpp in Sources */,
3210732129 1A85B18F0A1B18A200D8C87C /* JSHTMLHtmlElement.cpp in Sources */,
32108  51F175621F3EBC8300C74950 /* ServiceWorkerJob.cpp in Sources */,
3210932130 BC4918C80BFEA050009D6316 /* JSHTMLIFrameElement.cpp in Sources */,
3211032131 1AE2AA970A1CDD2D00B42B25 /* JSHTMLImageElement.cpp in Sources */,
3211132132 A80E7E980A1A83E3007FB8C5 /* JSHTMLInputElement.cpp in Sources */,

3310433125 0FD308D5117D168500A791F7 /* RenderIFrame.cpp in Sources */,
3310533126 BCEA4875097D93020094C9E4 /* RenderImage.cpp in Sources */,
3310633127 08F2F0091213E61700DCEC48 /* RenderImageResource.cpp in Sources */,
33107  51F175671F3EBC8300C74950 /* ServiceWorkerRegistration.cpp in Sources */,
3310833128 08641D4712142F7D008DE9F6 /* RenderImageResourceStyleImage.cpp in Sources */,
3310933129 BCEA4877097D93020094C9E4 /* RenderInline.cpp in Sources */,
3311033130 BCEA4879097D93020094C9E4 /* RenderLayer.cpp in Sources */,

3314933169 BCE93F471517C6D5008CCF74 /* RenderRegionSet.cpp in Sources */,
3315033170 A871DFE20A15376B00B12A68 /* RenderReplaced.cpp in Sources */,
3315133171 BCA846D60DC67A350026C309 /* RenderReplica.cpp in Sources */,
33152  51F1755E1F3EBC8300C74950 /* ServiceWorkerContainer.cpp in Sources */,
3315333172 1479FAED109AE37500DED655 /* RenderRuby.cpp in Sources */,
3315433173 1479FAEF109AE37500DED655 /* RenderRubyBase.cpp in Sources */,
3315533174 1479FAF1109AE37500DED655 /* RenderRubyRun.cpp in Sources */,

3335233371 A75E497710752ACB00C9B896 /* SerializedScriptValue.cpp in Sources */,
3335333372 516F7F6E1C31E39C00F111DC /* ServerOpenDBRequest.cpp in Sources */,
3335433373 2D93AEE419DF5641002A86C3 /* ServicesOverlayController.mm in Sources */,
 33374 51F1755C1F3EBC8300C74950 /* ServiceWorker.cpp in Sources */,
 33375 51F1755E1F3EBC8300C74950 /* ServiceWorkerContainer.cpp in Sources */,
 33376 51F175601F3EBC8300C74950 /* ServiceWorkerGlobalScope.cpp in Sources */,
 33377 51F175621F3EBC8300C74950 /* ServiceWorkerJob.cpp in Sources */,
 33378 51F175651F3EBC8300C74950 /* ServiceWorkerProvider.cpp in Sources */,
 33379 51F175671F3EBC8300C74950 /* ServiceWorkerRegistration.cpp in Sources */,
 33380 51F1756A1F3EBC8300C74950 /* ServiceWorkerRegistrationParameters.cpp in Sources */,
3335533381 511F7D441EB1C39100E47B83 /* SessionID.cpp in Sources */,
3335633382 93309E0F099E64920056E581 /* SetNodeAttributeCommand.cpp in Sources */,
3335733383 B8DBDB4B130B0F8A00F5CDB1 /* SetSelectionCommand.cpp in Sources */,

3362933655 BC22747A0E8366E200E7F975 /* SVGRenderStyleDefs.cpp in Sources */,
3363033656 B2227AA20D00BF220071B782 /* SVGScriptElement.cpp in Sources */,
3363133657 B2227AA50D00BF220071B782 /* SVGSetElement.cpp in Sources */,
33632  51F175601F3EBC8300C74950 /* ServiceWorkerGlobalScope.cpp in Sources */,
3363333658 E4AFD00F0DAF335500F5F55C /* SVGSMILElement.cpp in Sources */,
3363433659 B2227AA80D00BF220071B782 /* SVGStopElement.cpp in Sources */,
3363533660 7C39C3761DDBB90D00FEFB29 /* SVGStringListValues.cpp in Sources */,

3373133756 7AA3A699194A64E7001CBD24 /* TileController.cpp in Sources */,
3373233757 1F72BF0A187FD4490009BCB3 /* TileControllerMemoryHandlerIOS.cpp in Sources */,
3373333758 7AA3A6A3194B5C22001CBD24 /* TileCoverageMap.cpp in Sources */,
33734  51F175651F3EBC8300C74950 /* ServiceWorkerProvider.cpp in Sources */,
3373533759 7AA3A69B194A64E7001CBD24 /* TileGrid.cpp in Sources */,
3373633760 498770F21242C535002226BA /* TilingData.cpp in Sources */,
3373733761 F55B3DDB1251F12D003EF269 /* TimeInputType.cpp in Sources */,

Source/WebCore/inspector/InspectorOverlay.cpp

2929#include "config.h"
3030#include "InspectorOverlay.h"
3131
 32#include "CacheStorageProvider.h"
3233#include "DocumentLoader.h"
3334#include "EditorClient.h"
3435#include "Element.h"

@@Page* InspectorOverlay::overlayPage()
865866 PageConfiguration pageConfiguration(
866867 createEmptyEditorClient(),
867868 SocketProvider::create(),
868  makeUniqueRef<LibWebRTCProvider>()
 869 makeUniqueRef<LibWebRTCProvider>(),
 870 CacheStorageProvider::create()
869871 );
870872 fillWithEmptyClients(pageConfiguration);
871873 m_overlayPage = std::make_unique<Page>(WTFMove(pageConfiguration));

Source/WebCore/page/CacheStorageProvider.h

 1/*
 2 * Copyright (C) 2017 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#pragma once
 27
 28#include "CacheStorageConnection.h"
 29#include "SessionID.h"
 30#include <wtf/RefCounted.h>
 31
 32namespace WebCore {
 33
 34class WEBCORE_EXPORT CacheStorageProvider : public RefCounted<CacheStorageProvider> {
 35public:
 36 static Ref<CacheStorageProvider> create() { return adoptRef(*new CacheStorageProvider); }
 37 virtual Ref<CacheStorageConnection> createCacheStorageConnection(SessionID) { return CacheStorageConnection::create(); }
 38 virtual ~CacheStorageProvider() { };
 39};
 40
 41}

Source/WebCore/page/Page.cpp

2626#include "BackForwardClient.h"
2727#include "BackForwardController.h"
2828#include "CSSAnimationController.h"
 29#include "CacheStorageProvider.h"
2930#include "Chrome.h"
3031#include "ChromeClient.h"
3132#include "ConstantPropertyMap.h"

@@Page::Page(PageConfiguration&& pageConfiguration)
222223#endif
223224 , m_socketProvider(WTFMove(pageConfiguration.socketProvider))
224225 , m_applicationCacheStorage(*WTFMove(pageConfiguration.applicationCacheStorage))
 226 , m_cacheStorageProvider(WTFMove(pageConfiguration.cacheStorageProvider))
225227 , m_databaseProvider(*WTFMove(pageConfiguration.databaseProvider))
226228 , m_pluginInfoProvider(*WTFMove(pageConfiguration.pluginInfoProvider))
227229 , m_storageNamespaceProvider(*WTFMove(pageConfiguration.storageNamespaceProvider))

Source/WebCore/page/Page.h

@@class AlternativeTextClient;
7777class ApplicationCacheStorage;
7878class BackForwardController;
7979class BackForwardClient;
 80class CacheStorageProvider;
8081class Chrome;
8182class ChromeClient;
8283class Color;

@@public:
510511
511512 ApplicationCacheStorage& applicationCacheStorage() { return m_applicationCacheStorage; }
512513 DatabaseProvider& databaseProvider() { return m_databaseProvider; }
 514 CacheStorageProvider& cacheStorageProvider() { return m_cacheStorageProvider; }
513515 SocketProvider& socketProvider() { return m_socketProvider; }
514516
515517 StorageNamespaceProvider& storageNamespaceProvider() { return m_storageNamespaceProvider.get(); }

@@private:
784786
785787 Ref<SocketProvider> m_socketProvider;
786788 Ref<ApplicationCacheStorage> m_applicationCacheStorage;
 789 Ref<CacheStorageProvider> m_cacheStorageProvider;
787790 Ref<DatabaseProvider> m_databaseProvider;
788791 Ref<PluginInfoProvider> m_pluginInfoProvider;
789792 Ref<StorageNamespaceProvider> m_storageNamespaceProvider;

Source/WebCore/page/PageConfiguration.cpp

2828
2929#include "ApplicationCacheStorage.h"
3030#include "BackForwardClient.h"
 31#include "CacheStorageProvider.h"
3132#include "DatabaseProvider.h"
3233#include "DiagnosticLoggingClient.h"
3334#include "EditorClient.h"

4344
4445namespace WebCore {
4546
46 PageConfiguration::PageConfiguration(UniqueRef<EditorClient>&& editorClient, Ref<SocketProvider>&& socketProvider, UniqueRef<LibWebRTCProvider>&& libWebRTCProvider)
 47PageConfiguration::PageConfiguration(UniqueRef<EditorClient>&& editorClient, Ref<SocketProvider>&& socketProvider, UniqueRef<LibWebRTCProvider>&& libWebRTCProvider, Ref<CacheStorageProvider>&& cacheStorageProvider)
4748 : editorClient(WTFMove(editorClient))
4849 , socketProvider(WTFMove(socketProvider))
4950 , libWebRTCProvider(WTFMove(libWebRTCProvider))
 51 , cacheStorageProvider(WTFMove(cacheStorageProvider))
5052{
5153}
5254

Source/WebCore/page/PageConfiguration.h

@@namespace WebCore {
3434class AlternativeTextClient;
3535class ApplicationCacheStorage;
3636class BackForwardClient;
 37class CacheStorageProvider;
3738class ChromeClient;
3839class ContextMenuClient;
3940class DatabaseProvider;

@@class WebGLStateTracker;
5859class PageConfiguration {
5960 WTF_MAKE_NONCOPYABLE(PageConfiguration); WTF_MAKE_FAST_ALLOCATED;
6061public:
61  WEBCORE_EXPORT PageConfiguration(UniqueRef<EditorClient>&&, Ref<SocketProvider>&&, UniqueRef<LibWebRTCProvider>&&);
 62 WEBCORE_EXPORT PageConfiguration(UniqueRef<EditorClient>&&, Ref<SocketProvider>&&, UniqueRef<LibWebRTCProvider>&&, Ref<CacheStorageProvider>&&);
6263 WEBCORE_EXPORT ~PageConfiguration();
6364
6465 AlternativeTextClient* alternativeTextClient { nullptr };

@@public:
8788
8889 RefPtr<ApplicationCacheStorage> applicationCacheStorage;
8990 RefPtr<DatabaseProvider> databaseProvider;
 91 Ref<CacheStorageProvider> cacheStorageProvider;
9092 RefPtr<PluginInfoProvider> pluginInfoProvider;
9193 RefPtr<StorageNamespaceProvider> storageNamespaceProvider;
9294 RefPtr<UserContentProvider> userContentProvider;

Source/WebCore/svg/graphics/SVGImage.cpp

2828#include "config.h"
2929#include "SVGImage.h"
3030
 31#include "CacheStorageProvider.h"
3132#include "Chrome.h"
3233#include "CommonVM.h"
3334#include "DOMWindow.h"

@@EncodedDataStatus SVGImage::dataChanged(bool allDataReceived)
429430 PageConfiguration pageConfiguration(
430431 createEmptyEditorClient(),
431432 SocketProvider::create(),
432  makeUniqueRef<LibWebRTCProvider>()
 433 makeUniqueRef<LibWebRTCProvider>(),
 434 CacheStorageProvider::create()
433435 );
434436 fillWithEmptyClients(pageConfiguration);
435437 m_chromeClient = std::make_unique<SVGImageChromeClient>(this);

Source/WebKit/CMakeLists.txt

@@set(WebKit2_INCLUDE_DIRECTORIES
5252 "${WEBKIT2_DIR}/WebProcess/ApplePay"
5353 "${WEBKIT2_DIR}/WebProcess/ApplicationCache"
5454 "${WEBKIT2_DIR}/WebProcess/Automation"
 55 "${WEBKIT2_DIR}/WebProcess/Cache"
5556 "${WEBKIT2_DIR}/WebProcess/Cookies"
5657 "${WEBKIT2_DIR}/WebProcess/Databases"
5758 "${WEBKIT2_DIR}/WebProcess/Databases/IndexedDB"

Source/WebKit/WebKit.xcodeproj/project.pbxproj

891891 413075B21DE85F580039EC69 /* LibWebRTCSocketFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 413075A61DE85EE70039EC69 /* LibWebRTCSocketFactory.h */; };
892892 413075B31DE85F580039EC69 /* LibWebRTCProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 413075A71DE85EE70039EC69 /* LibWebRTCProvider.cpp */; };
893893 413075B41DE85F580039EC69 /* LibWebRTCProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 413075A81DE85EE70039EC69 /* LibWebRTCProvider.h */; };
 894 41D129DA1F3D101800D15E47 /* WebCacheStorageProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 41D129D91F3D101400D15E47 /* WebCacheStorageProvider.h */; };
894895 41DC45961E3D6E2200B11F51 /* NetworkRTCProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 41DC45941E3D6E1E00B11F51 /* NetworkRTCProvider.h */; };
895896 41DC45971E3D6E2200B11F51 /* NetworkRTCProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41DC45951E3D6E1E00B11F51 /* NetworkRTCProvider.cpp */; };
896897 41DC459B1E3DBB2800B11F51 /* LibWebRTCSocketClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41DC45991E3DBB2400B11F51 /* LibWebRTCSocketClient.cpp */; };

31423143 413075A71DE85EE70039EC69 /* LibWebRTCProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = LibWebRTCProvider.cpp; path = Network/webrtc/LibWebRTCProvider.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
31433144 413075A81DE85EE70039EC69 /* LibWebRTCProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = LibWebRTCProvider.h; path = Network/webrtc/LibWebRTCProvider.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
31443145 41AC86811E042E5300303074 /* WebRTCResolver.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; lineEnding = 0; name = WebRTCResolver.messages.in; path = Network/webrtc/WebRTCResolver.messages.in; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = "<none>"; };
 3146 41D129D91F3D101400D15E47 /* WebCacheStorageProvider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebCacheStorageProvider.h; sourceTree = "<group>"; };
31453147 41DC45941E3D6E1E00B11F51 /* NetworkRTCProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = NetworkRTCProvider.h; path = NetworkProcess/webrtc/NetworkRTCProvider.h; sourceTree = "<group>"; };
31463148 41DC45951E3D6E1E00B11F51 /* NetworkRTCProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NetworkRTCProvider.cpp; path = NetworkProcess/webrtc/NetworkRTCProvider.cpp; sourceTree = "<group>"; };
31473149 41DC45981E3D6ED600B11F51 /* NetworkRTCProvider.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = NetworkRTCProvider.messages.in; path = NetworkProcess/webrtc/NetworkRTCProvider.messages.in; sourceTree = "<group>"; };

59125914 name = webrtc;
59135915 sourceTree = "<group>";
59145916 };
 5917 41D129D81F3D101400D15E47 /* Cache */ = {
 5918 isa = PBXGroup;
 5919 children = (
 5920 41D129D91F3D101400D15E47 /* WebCacheStorageProvider.h */,
 5921 );
 5922 path = Cache;
 5923 sourceTree = "<group>";
 5924 };
59155925 4450AEBE1DC3FAAC009943F2 /* cocoa */ = {
59165926 isa = PBXGroup;
59175927 children = (

65926602 children = (
65936603 1AB1F7701D1B2F5D007C9BD1 /* ApplePay */,
65946604 1C0A19431C8FF1A800FE0EBB /* Automation */,
 6605 41D129D81F3D101400D15E47 /* Cache */,
65956606 7C6E70F818B2D47E00F24E2E /* cocoa */,
65966607 3309344B1315B93A0097A7BC /* Cookies */,
65976608 512A9754180DF9270039A149 /* Databases */,

86898700 BC72BA1E11E64907001EB4EA /* WebBackForwardList.h in Headers */,
86908701 518D2CAE12D5153B003BB93B /* WebBackForwardListItem.h in Headers */,
86918702 BC72B9FB11E6476B001EB4EA /* WebBackForwardListProxy.h in Headers */,
 8703 41D129DA1F3D101800D15E47 /* WebCacheStorageProvider.h in Headers */,
86928704 BCF50728124329AA005955AE /* WebCertificateInfo.h in Headers */,
86938705 BC032D7510F4378D0058C15A /* WebChromeClient.h in Headers */,
86948706 3F87B9BE158940190090FF62 /* WebColorChooser.h in Headers */,

88318843 BCE0E425168B7A280057E66A /* WebProcessSupplement.h in Headers */,
88328844 1A1E093418861D3800D2DC49 /* WebProgressTrackerClient.h in Headers */,
88338845 512F589D12A8838800629530 /* WebProtectionSpace.h in Headers */,
8834  51BEB62C1F3A5AD7005029B9 /* WebServiceWorkerProvider.h in Headers */,
88358846 37948404150C350600E52CE9 /* WebRenderLayer.h in Headers */,
88368847 3760881F150413E900FC82C7 /* WebRenderObject.h in Headers */,
88378848 510AFFBA16542048001BA05E /* WebResourceLoader.h in Headers */,

88438854 41DC459F1E3DBDA500B11F51 /* WebRTCSocket.h in Headers */,
88448855 7C361D731927FA360036A59D /* WebScriptMessageHandler.h in Headers */,
88458856 D3B9484911FF4B6500032B39 /* WebSearchPopupMenu.h in Headers */,
 8857 51BEB62C1F3A5AD7005029B9 /* WebServiceWorkerProvider.h in Headers */,
88468858 1A4832D71A9CDF96008B4DFE /* WebsiteData.h in Headers */,
88478859 1A4832D11A9BDC2F008B4DFE /* WebsiteDataRecord.h in Headers */,
88488860 1A53C2AA1A325730004E8C70 /* WebsiteDataStore.h in Headers */,

1037110383 2DA944A11884E4F000ED86DB /* WebIOSEventFactory.mm in Sources */,
1037210384 C0337DD3127A2A0E008FF4F4 /* WebKeyboardEvent.cpp in Sources */,
1037310385 1A6280F31919982A006AD9F9 /* WebKit.m in Sources */,
10374  51BEB62B1F3A5AD7005029B9 /* WebServiceWorkerProvider.cpp in Sources */,
1037510386 BC9BA5041697C45300E44616 /* WebKit2Initialize.cpp in Sources */,
1037610387 465250E61ECF52DC002025CB /* WebKit2InitializeCocoa.mm in Sources */,
1037710388 51FB08FF1639DE1A00EC324A /* WebLoaderStrategy.cpp in Sources */,

1046910480 51F060E11654318500F3281C /* WebRTCSocketMessageReceiver.cpp in Sources */,
1047010481 7C361D721927FA360036A59D /* WebScriptMessageHandler.cpp in Sources */,
1047110482 D3B9484811FF4B6500032B39 /* WebSearchPopupMenu.cpp in Sources */,
 10483 51BEB62B1F3A5AD7005029B9 /* WebServiceWorkerProvider.cpp in Sources */,
1047210484 1A4832D61A9CDF96008B4DFE /* WebsiteData.cpp in Sources */,
1047310485 1A4832D91A9D1FD2008B4DFE /* WebsiteDataRecord.cpp in Sources */,
1047410486 1A53C2A91A32572B004E8C70 /* WebsiteDataStore.cpp in Sources */,

Source/WebKit/WebProcess/Cache/WebCacheStorageProvider.h

 1/*
 2 * Copyright (C) 2016 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#pragma once
 27
 28#include <WebCore/CacheStorageProvider.h>
 29
 30namespace WebKit {
 31
 32class WebCacheStorageProvider final : public WebCore::CacheStorageProvider {
 33public:
 34 static Ref<WebCacheStorageProvider> create() { return adoptRef(*new WebCacheStorageProvider); }
 35};
 36
 37}

Source/WebKit/WebProcess/WebPage/WebPage.cpp

6868#include "WebAlternativeTextClient.h"
6969#include "WebBackForwardListItem.h"
7070#include "WebBackForwardListProxy.h"
 71#include "WebCacheStorageProvider.h"
7172#include "WebChromeClient.h"
7273#include "WebColorChooser.h"
7374#include "WebContextMenu.h"

@@WebPage::WebPage(uint64_t pageID, WebPageCreationParameters&& parameters)
371372 PageConfiguration pageConfiguration(
372373 makeUniqueRef<WebEditorClient>(this),
373374 WebSocketProvider::create(),
374  makeUniqueRef<WebKit::LibWebRTCProvider>()
 375 makeUniqueRef<WebKit::LibWebRTCProvider>(),
 376 WebProcess::singleton().cacheStorageProvider()
375377 );
376378 pageConfiguration.chromeClient = new WebChromeClient(*this);
377379#if ENABLE(CONTEXT_MENUS)

Source/WebKit/WebProcess/WebProcess.cpp

4444#include "StatisticsData.h"
4545#include "UserData.h"
4646#include "WebAutomationSessionProxy.h"
 47#include "WebCacheStorageProvider.h"
4748#include "WebConnectionToUIProcess.h"
4849#include "WebCookieManager.h"
4950#include "WebCoreArgumentCoders.h"

@@WebProcess::WebProcess()
160161#endif
161162 , m_webInspectorInterruptDispatcher(WebInspectorInterruptDispatcher::create())
162163 , m_webLoaderStrategy(*new WebLoaderStrategy)
 164 , m_cacheStorageProvider(WebCacheStorageProvider::create())
163165 , m_dnsPrefetchHystereris([this](HysteresisState state) { if (state == HysteresisState::Stopped) m_dnsPrefetchedHosts.clear(); })
164166#if ENABLE(NETSCAPE_PLUGIN_API)
165167 , m_pluginProcessConnectionManager(PluginProcessConnectionManager::create())

Source/WebKit/WebProcess/WebProcess.h

@@class ObjCObjectGraph;
8080class UserData;
8181class WaylandCompositorDisplay;
8282class WebAutomationSessionProxy;
 83class WebCacheStorageProvider;
8384class WebConnectionToUIProcess;
8485class WebFrame;
8586class WebLoaderStrategy;

@@public:
222223
223224 WebAutomationSessionProxy* automationSessionProxy() { return m_automationSessionProxy.get(); }
224225
 226 WebCacheStorageProvider& cacheStorageProvider() { return m_cacheStorageProvider.get(); }
 227
225228private:
226229 WebProcess();
227230 ~WebProcess();

@@private:
375378 RefPtr<NetworkProcessConnection> m_networkProcessConnection;
376379 WebLoaderStrategy& m_webLoaderStrategy;
377380
 381 Ref<WebCacheStorageProvider> m_cacheStorageProvider;
 382
378383#if USE(LIBWEBRTC)
379384 std::unique_ptr<LibWebRTCNetwork> m_libWebRTCNetwork;
380385#endif

Source/WebKitLegacy/mac/WebView/WebView.mm

124124#import <WebCore/ApplicationCacheStorage.h>
125125#import <WebCore/BackForwardController.h>
126126#import <WebCore/CSSAnimationController.h>
 127#import <WebCore/CacheStorageProvider.h>
127128#import <WebCore/Chrome.h>
128129#import <WebCore/ColorMac.h>
129130#import <WebCore/DatabaseManager.h>

@@static void WebKitInitializeGamepadProviderIfNecessary()
14131414 PageConfiguration pageConfiguration(
14141415 makeUniqueRef<WebEditorClient>(self),
14151416 SocketProvider::create(),
1416  makeUniqueRef<WebCore::LibWebRTCProvider>()
 1417 makeUniqueRef<WebCore::LibWebRTCProvider>(),
 1418 WebCore::CacheStorageProvider::create()
14171419 );
14181420#if !PLATFORM(IOS)
14191421 pageConfiguration.chromeClient = new WebChromeClient(self);

@@static void WebKitInitializeGamepadProviderIfNecessary()
16761678 PageConfiguration pageConfiguration(
16771679 makeUniqueRef<WebEditorClient>(self),
16781680 SocketProvider::create(),
1679  makeUniqueRef<WebCore::LibWebRTCProvider>()
 1681 makeUniqueRef<WebCore::LibWebRTCProvider>(),
 1682 WebCore::CacheStorageProvider::create()
16801683 );
16811684 pageConfiguration.chromeClient = new WebChromeClientIOS(self);
16821685#if ENABLE(DRAG_SUPPORT)

Source/WebKitLegacy/win/WebView.cpp

8484#include <WebCore/BString.h>
8585#include <WebCore/BackForwardController.h>
8686#include <WebCore/BitmapInfo.h>
 87#include <WebCore/CacheStorageProvider.h>
8788#include <WebCore/Chrome.h>
8889#include <WebCore/ContextMenu.h>
8990#include <WebCore/ContextMenuController.h>

@@HRESULT WebView::initWithFrame(RECT frame, _In_ BSTR frameName, _In_ BSTR groupN
31023103 PageConfiguration configuration(
31033104 makeUniqueRef<WebEditorClient>(this),
31043105 SocketProvider::create(),
3105  makeUniqueRef<LibWebRTCProvider>()
 3106 makeUniqueRef<LibWebRTCProvider>(),
 3107 WebCore::CacheStorageProvider::create()
31063108 );
31073109 configuration.backForwardClient = BackForwardList::create();
31083110 configuration.chromeClient = new WebChromeClient(this);

LayoutTests/ChangeLog

 12017-08-13 Youenn Fablet <youenn@apple.com>
 2
 3 [Cache API] Adding generic support for CacheStorage and Cache methods
 4 https://bugs.webkit.org/show_bug.cgi?id=175455
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * TestExpectations: Skipping a test that would timeout otherwise due to the current implementation limitations.
 9
1102017-08-11 Ryosuke Niwa <rniwa@webkit.org>
211
312 Replace DATA_TRANSFER_ITEMS by a runtime flag and add a stub implementation

LayoutTests/imported/w3c/ChangeLog

 12017-08-13 Youenn Fablet <youenn@apple.com>
 2
 3 [Cache API] Adding generic support for CacheStorage and Cache methods
 4 https://bugs.webkit.org/show_bug.cgi?id=175455
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * web-platform-tests/service-workers/cache-storage/serviceworker/credentials.https-expected.txt:
 9 * web-platform-tests/service-workers/cache-storage/window/cache-storage-match.https-expected.txt:
 10 * web-platform-tests/service-workers/cache-storage/window/cache-storage.https-expected.txt:
 11 * web-platform-tests/service-workers/cache-storage/worker/cache-storage-match.https-expected.txt:
 12 * web-platform-tests/service-workers/cache-storage/worker/cache-storage.https-expected.txt:
 13
1142017-08-12 Chris Dumez <cdumez@apple.com>
215
316 Address flakiness related to download tests

LayoutTests/TestExpectations

@@imported/w3c/web-platform-tests/service-workers/stub-4.6.2-cache.html [ Pass ]
121121imported/w3c/web-platform-tests/service-workers/stub-4.6.3-cache-storage.html [ Pass ]
122122imported/w3c/web-platform-tests/service-workers/cache-storage [ Pass ]
123123imported/w3c/web-platform-tests/service-workers/cache-storage/window [ Pass Failure ]
124 
 124imported/w3c/web-platform-tests/service-workers/cache-storage/common.https.html [ Skip ]
125125
126126# textarea.animate is not supported
127127imported/w3c/web-platform-tests/css/css-ui-3/caret-color-018.html [ Skip ]

LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/serviceworker/credentials.https-expected.txt

11
2 FAIL Cache API matching includes credentials promise_test: Unhandled rejection with value: object "TypeError: Not implemented"
 2FAIL Cache API matching includes credentials assert_unreached: unregister should not fail: serviceWorker.getRegistration() is not yet implemented Reached unreachable code
33

LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/window/cache-storage-match.https-expected.txt

@@FAIL CacheStorageMatch from one of many caches promise_test: Unhandled rejection
44FAIL CacheStorageMatch from one of many caches by name promise_test: Unhandled rejection with value: object "TypeError: Not implemented"
55FAIL CacheStorageMatch a string request promise_test: Unhandled rejection with value: object "TypeError: Not implemented"
66FAIL CacheStorageMatch a HEAD request promise_test: Unhandled rejection with value: object "TypeError: Not implemented"
7 FAIL CacheStorageMatch with no cached entry promise_test: Unhandled rejection with value: object "TypeError: Not implemented"
8 FAIL CacheStorageMatch with no caches available but name provided promise_test: Unhandled rejection with value: object "TypeError: Not implemented"
 7FAIL CacheStorageMatch with no cached entry promise_test: Unhandled rejection with value: object "NotSupportedError: Not implemented"
 8FAIL CacheStorageMatch with no caches available but name provided promise_test: Unhandled rejection with value: object "NotSupportedError: Not implemented"
99FAIL CacheStorageMatch with empty cache name provided promise_test: Unhandled rejection with value: object "TypeError: Not implemented"
1010FAIL CacheStorageMatch supports ignoreSearch promise_test: Unhandled rejection with value: object "TypeError: Not implemented"
1111FAIL Cache.match supports ignoreMethod promise_test: Unhandled rejection with value: object "TypeError: Not implemented"

LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/window/cache-storage.https-expected.txt

@@FAIL CacheStorage.delete dooms, but does not delete immediately promise_test: Un
44FAIL CacheStorage.open with an empty name promise_test: Unhandled rejection with value: object "TypeError: Not implemented"
55PASS CacheStorage.open with no arguments
66FAIL CacheStorage.has with existing cache promise_test: Unhandled rejection with value: object "TypeError: Not implemented"
7 FAIL CacheStorage.has with nonexistent cache promise_test: Unhandled rejection with value: object "TypeError: Not implemented"
 7PASS CacheStorage.has with nonexistent cache
88FAIL CacheStorage.open with existing cache promise_test: Unhandled rejection with value: object "TypeError: Not implemented"
99FAIL CacheStorage.delete with existing cache promise_test: Unhandled rejection with value: object "TypeError: Not implemented"
10 FAIL CacheStorage.delete with nonexistent cache promise_test: Unhandled rejection with value: object "TypeError: Not implemented"
 10PASS CacheStorage.delete with nonexistent cache
1111FAIL CacheStorage names are DOMStrings not USVStrings promise_test: Unhandled rejection with value: object "TypeError: Not implemented"
1212

LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/worker/cache-storage-match.https-expected.txt

@@FAIL CacheStorageMatch from one of many caches promise_test: Unhandled rejection
44FAIL CacheStorageMatch from one of many caches by name promise_test: Unhandled rejection with value: object "TypeError: Not implemented"
55FAIL CacheStorageMatch a string request promise_test: Unhandled rejection with value: object "TypeError: Not implemented"
66FAIL CacheStorageMatch a HEAD request promise_test: Unhandled rejection with value: object "TypeError: Not implemented"
7 FAIL CacheStorageMatch with no cached entry promise_test: Unhandled rejection with value: object "TypeError: Not implemented"
8 FAIL CacheStorageMatch with no caches available but name provided promise_test: Unhandled rejection with value: object "TypeError: Not implemented"
 7FAIL CacheStorageMatch with no cached entry promise_test: Unhandled rejection with value: object "NotSupportedError: Not implemented"
 8FAIL CacheStorageMatch with no caches available but name provided promise_test: Unhandled rejection with value: object "NotSupportedError: Not implemented"
99FAIL CacheStorageMatch with empty cache name provided promise_test: Unhandled rejection with value: object "TypeError: Not implemented"
1010FAIL CacheStorageMatch supports ignoreSearch promise_test: Unhandled rejection with value: object "TypeError: Not implemented"
1111FAIL Cache.match supports ignoreMethod promise_test: Unhandled rejection with value: object "TypeError: Not implemented"

LayoutTests/imported/w3c/web-platform-tests/service-workers/cache-storage/worker/cache-storage.https-expected.txt

@@FAIL CacheStorage.delete dooms, but does not delete immediately promise_test: Un
44FAIL CacheStorage.open with an empty name promise_test: Unhandled rejection with value: object "TypeError: Not implemented"
55PASS CacheStorage.open with no arguments
66FAIL CacheStorage.has with existing cache promise_test: Unhandled rejection with value: object "TypeError: Not implemented"
7 FAIL CacheStorage.has with nonexistent cache promise_test: Unhandled rejection with value: object "TypeError: Not implemented"
 7PASS CacheStorage.has with nonexistent cache
88FAIL CacheStorage.open with existing cache promise_test: Unhandled rejection with value: object "TypeError: Not implemented"
99FAIL CacheStorage.delete with existing cache promise_test: Unhandled rejection with value: object "TypeError: Not implemented"
10 FAIL CacheStorage.delete with nonexistent cache promise_test: Unhandled rejection with value: object "TypeError: Not implemented"
 10PASS CacheStorage.delete with nonexistent cache
1111FAIL CacheStorage names are DOMStrings not USVStrings promise_test: Unhandled rejection with value: object "TypeError: Not implemented"
1212