Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: third_party/WebKit/Source/modules/cachestorage/CacheStorage.cpp

Issue 2242883002: [CacheStorage] Use QueryCache everywhere (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/cachestorage/CacheStorage.h" 5 #include "modules/cachestorage/CacheStorage.h"
6 6
7 #include "bindings/core/v8/ScriptPromiseResolver.h" 7 #include "bindings/core/v8/ScriptPromiseResolver.h"
8 #include "bindings/core/v8/ScriptState.h" 8 #include "bindings/core/v8/ScriptState.h"
9 #include "core/dom/DOMException.h" 9 #include "core/dom/DOMException.h"
10 #include "core/dom/ExceptionCode.h" 10 #include "core/dom/ExceptionCode.h"
11 #include "core/inspector/ConsoleMessage.h" 11 #include "core/inspector/ConsoleMessage.h"
12 #include "modules/cachestorage/CacheStorageError.h" 12 #include "modules/cachestorage/CacheStorageError.h"
13 #include "modules/fetch/Request.h" 13 #include "modules/fetch/Request.h"
14 #include "modules/fetch/Response.h" 14 #include "modules/fetch/Response.h"
15 #include "platform/RuntimeEnabledFeatures.h" 15 #include "platform/RuntimeEnabledFeatures.h"
nhiroki 2016/08/18 00:05:43 Can you remove this inclusion?
jkarlin 2016/08/18 14:08:24 Done.
16 #include "public/platform/modules/serviceworker/WebServiceWorkerCacheError.h" 16 #include "public/platform/modules/serviceworker/WebServiceWorkerCacheError.h"
17 #include "public/platform/modules/serviceworker/WebServiceWorkerCacheStorage.h" 17 #include "public/platform/modules/serviceworker/WebServiceWorkerCacheStorage.h"
18 #include "wtf/PtrUtil.h" 18 #include "wtf/PtrUtil.h"
19 #include <memory> 19 #include <memory>
20 20
21 namespace blink { 21 namespace blink {
22 22
23 namespace { 23 namespace {
24 24
25 DOMException* createNoImplementationException() 25 DOMException* createNoImplementationException()
26 { 26 {
27 return DOMException::create(NotSupportedError, "No CacheStorage implementati on provided."); 27 return DOMException::create(NotSupportedError, "No CacheStorage implementati on provided.");
28 } 28 }
29 29
30 bool commonChecks(ScriptState* scriptState, ExceptionState& exceptionState) 30 bool commonChecks(ScriptState* scriptState, ExceptionState& exceptionState)
31 { 31 {
32 ExecutionContext* executionContext = scriptState->getExecutionContext(); 32 ExecutionContext* executionContext = scriptState->getExecutionContext();
33 // FIXME: May be null due to worker termination: http://crbug.com/413518. 33 // FIXME: May be null due to worker termination: http://crbug.com/413518.
34 if (!executionContext) 34 if (!executionContext)
35 return false; 35 return false;
36 36
37 String errorMessage; 37 String errorMessage;
38 if (!executionContext->isSecureContext(errorMessage)) { 38 if (!executionContext->isSecureContext(errorMessage)) {
39 exceptionState.throwSecurityError(errorMessage); 39 exceptionState.throwSecurityError(errorMessage);
40 return false; 40 return false;
41 } 41 }
42 return true; 42 return true;
43 } 43 }
44 44
45 void checkCacheQueryOptions(const CacheQueryOptions& options, ExecutionContext* context)
46 {
47 if (!RuntimeEnabledFeatures::cacheIgnoreSearchOptionEnabled() && options.ign oreSearch())
48 context->addConsoleMessage(ConsoleMessage::create(JSMessageSource, Warni ngMessageLevel, "Cache.match() does not support 'ignoreSearch' option yet. See h ttp://crbug.com/520784"));
49 if (options.ignoreMethod())
50 context->addConsoleMessage(ConsoleMessage::create(JSMessageSource, Warni ngMessageLevel, "Cache.match() does not support 'ignoreMethod' option yet. See h ttp://crbug.com/482256"));
51 if (options.ignoreVary())
52 context->addConsoleMessage(ConsoleMessage::create(JSMessageSource, Warni ngMessageLevel, "Cache.match() does not support 'ignoreVary' option yet. See htt p://crbug.com/499216"));
53 }
54
55 } // namespace 45 } // namespace
56 46
57 // FIXME: Consider using CallbackPromiseAdapter. 47 // FIXME: Consider using CallbackPromiseAdapter.
58 class CacheStorage::Callbacks final : public WebServiceWorkerCacheStorage::Cache StorageCallbacks { 48 class CacheStorage::Callbacks final : public WebServiceWorkerCacheStorage::Cache StorageCallbacks {
59 WTF_MAKE_NONCOPYABLE(Callbacks); 49 WTF_MAKE_NONCOPYABLE(Callbacks);
60 public: 50 public:
61 explicit Callbacks(ScriptPromiseResolver* resolver) 51 explicit Callbacks(ScriptPromiseResolver* resolver)
62 : m_resolver(resolver) { } 52 : m_resolver(resolver) { }
63 ~Callbacks() override { } 53 ~Callbacks() override { }
64 54
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 Request* newRequest = Request::create(scriptState, request.getAsUSVString(), exceptionState); 298 Request* newRequest = Request::create(scriptState, request.getAsUSVString(), exceptionState);
309 if (exceptionState.hadException()) 299 if (exceptionState.hadException())
310 return ScriptPromise(); 300 return ScriptPromise();
311 return matchImpl(scriptState, newRequest, options); 301 return matchImpl(scriptState, newRequest, options);
312 } 302 }
313 303
314 ScriptPromise CacheStorage::matchImpl(ScriptState* scriptState, const Request* r equest, const CacheQueryOptions& options) 304 ScriptPromise CacheStorage::matchImpl(ScriptState* scriptState, const Request* r equest, const CacheQueryOptions& options)
315 { 305 {
316 WebServiceWorkerRequest webRequest; 306 WebServiceWorkerRequest webRequest;
317 request->populateWebServiceWorkerRequest(webRequest); 307 request->populateWebServiceWorkerRequest(webRequest);
318 checkCacheQueryOptions(options, scriptState->getExecutionContext());
319 308
320 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; 309 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
321 const ScriptPromise promise = resolver->promise(); 310 const ScriptPromise promise = resolver->promise();
322 311
323 if (request->method() != HTTPNames::GET && !options.ignoreMethod()) { 312 if (request->method() != HTTPNames::GET && !options.ignoreMethod()) {
324 resolver->resolve(); 313 resolver->resolve();
325 return promise; 314 return promise;
326 } 315 }
327 316
328 if (m_webCacheStorage) 317 if (m_webCacheStorage)
(...skipping 19 matching lines...) Expand all
348 m_webCacheStorage.reset(); 337 m_webCacheStorage.reset();
349 } 338 }
350 339
351 DEFINE_TRACE(CacheStorage) 340 DEFINE_TRACE(CacheStorage)
352 { 341 {
353 visitor->trace(m_scopedFetcher); 342 visitor->trace(m_scopedFetcher);
354 visitor->trace(m_nameToCacheMap); 343 visitor->trace(m_nameToCacheMap);
355 } 344 }
356 345
357 } // namespace blink 346 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698