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

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

Issue 1320823003: CacheStorage: Show a warning message when unsupported CacheQueryOptions are specified (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: swap arguments Created 5 years, 3 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
« no previous file with comments | « Source/modules/cachestorage/Cache.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "config.h" 5 #include "config.h"
6 #include "modules/cachestorage/CacheStorage.h" 6 #include "modules/cachestorage/CacheStorage.h"
7 7
8 #include "bindings/core/v8/ScriptPromiseResolver.h" 8 #include "bindings/core/v8/ScriptPromiseResolver.h"
9 #include "bindings/core/v8/ScriptState.h" 9 #include "bindings/core/v8/ScriptState.h"
10 #include "core/dom/DOMException.h" 10 #include "core/dom/DOMException.h"
11 #include "core/dom/ExceptionCode.h" 11 #include "core/dom/ExceptionCode.h"
12 #include "core/inspector/ConsoleMessage.h"
12 #include "modules/cachestorage/CacheStorageError.h" 13 #include "modules/cachestorage/CacheStorageError.h"
13 #include "modules/fetch/Request.h" 14 #include "modules/fetch/Request.h"
14 #include "modules/fetch/Response.h" 15 #include "modules/fetch/Response.h"
15 #include "public/platform/WebServiceWorkerCacheError.h" 16 #include "public/platform/WebServiceWorkerCacheError.h"
16 #include "public/platform/WebServiceWorkerCacheStorage.h" 17 #include "public/platform/WebServiceWorkerCacheStorage.h"
17 18
18 namespace blink { 19 namespace blink {
19 20
20 namespace { 21 namespace {
21 22
(...skipping 10 matching lines...) Expand all
32 return false; 33 return false;
33 34
34 String errorMessage; 35 String errorMessage;
35 if (!executionContext->isPrivilegedContext(errorMessage)) { 36 if (!executionContext->isPrivilegedContext(errorMessage)) {
36 exceptionState.throwSecurityError(errorMessage); 37 exceptionState.throwSecurityError(errorMessage);
37 return false; 38 return false;
38 } 39 }
39 return true; 40 return true;
40 } 41 }
41 42
43 void checkCacheQueryOptions(const CacheQueryOptions& options, ExecutionContext* context)
44 {
45 if (options.ignoreSearch())
46 context->addConsoleMessage(ConsoleMessage::create(JSMessageSource, Warni ngMessageLevel, "Cache.match() does not support 'ignoreSearch' option yet. See h ttp://crbug.com/520784"));
47 if (options.ignoreMethod())
48 context->addConsoleMessage(ConsoleMessage::create(JSMessageSource, Warni ngMessageLevel, "Cache.match() does not support 'ignoreMethod' option yet. See h ttp://crbug.com/482256"));
49 if (options.ignoreVary())
50 context->addConsoleMessage(ConsoleMessage::create(JSMessageSource, Warni ngMessageLevel, "Cache.match() does not support 'ignoreVary' option yet. See htt p://crbug.com/499216"));
51 }
52
42 } 53 }
43 54
44 // FIXME: Consider using CallbackPromiseAdapter. 55 // FIXME: Consider using CallbackPromiseAdapter.
45 class CacheStorage::Callbacks final : public WebServiceWorkerCacheStorage::Cache StorageCallbacks { 56 class CacheStorage::Callbacks final : public WebServiceWorkerCacheStorage::Cache StorageCallbacks {
46 WTF_MAKE_NONCOPYABLE(Callbacks); 57 WTF_MAKE_NONCOPYABLE(Callbacks);
47 public: 58 public:
48 explicit Callbacks(ScriptPromiseResolver* resolver) 59 explicit Callbacks(ScriptPromiseResolver* resolver)
49 : m_resolver(resolver) { } 60 : m_resolver(resolver) { }
50 ~Callbacks() override { } 61 ~Callbacks() override { }
51 62
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 Request* newRequest = Request::create(scriptState, request.getAsUSVString(), exceptionState); 305 Request* newRequest = Request::create(scriptState, request.getAsUSVString(), exceptionState);
295 if (exceptionState.hadException()) 306 if (exceptionState.hadException())
296 return ScriptPromise(); 307 return ScriptPromise();
297 return matchImpl(scriptState, newRequest, options); 308 return matchImpl(scriptState, newRequest, options);
298 } 309 }
299 310
300 ScriptPromise CacheStorage::matchImpl(ScriptState* scriptState, const Request* r equest, const CacheQueryOptions& options) 311 ScriptPromise CacheStorage::matchImpl(ScriptState* scriptState, const Request* r equest, const CacheQueryOptions& options)
301 { 312 {
302 WebServiceWorkerRequest webRequest; 313 WebServiceWorkerRequest webRequest;
303 request->populateWebServiceWorkerRequest(webRequest); 314 request->populateWebServiceWorkerRequest(webRequest);
315 checkCacheQueryOptions(options, scriptState->executionContext());
304 316
305 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; 317 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
306 const ScriptPromise promise = resolver->promise(); 318 const ScriptPromise promise = resolver->promise();
307 319
308 if (m_webCacheStorage) 320 if (m_webCacheStorage)
309 m_webCacheStorage->dispatchMatch(new MatchCallbacks(resolver), webReques t, Cache::toWebQueryParams(options)); 321 m_webCacheStorage->dispatchMatch(new MatchCallbacks(resolver), webReques t, Cache::toWebQueryParams(options));
310 else 322 else
311 resolver->reject(createNoImplementationException()); 323 resolver->reject(createNoImplementationException());
312 324
313 return promise; 325 return promise;
(...skipping 13 matching lines...) Expand all
327 { 339 {
328 m_webCacheStorage.clear(); 340 m_webCacheStorage.clear();
329 } 341 }
330 342
331 DEFINE_TRACE(CacheStorage) 343 DEFINE_TRACE(CacheStorage)
332 { 344 {
333 visitor->trace(m_nameToCacheMap); 345 visitor->trace(m_nameToCacheMap);
334 } 346 }
335 347
336 } // namespace blink 348 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/cachestorage/Cache.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698