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

Side by Side Diff: Source/modules/serviceworkers/Cache.cpp

Issue 675733003: Cache.put() validation of Request properties (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « LayoutTests/http/tests/serviceworker/cache-put-expected.txt ('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/serviceworkers/Cache.h" 6 #include "modules/serviceworkers/Cache.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 "bindings/core/v8/V8ThrowException.h" 10 #include "bindings/core/v8/V8ThrowException.h"
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 batchOperations[0].matchParams = toWebQueryParams(options); 364 batchOperations[0].matchParams = toWebQueryParams(options);
365 365
366 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip tState); 366 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip tState);
367 const ScriptPromise promise = resolver->promise(); 367 const ScriptPromise promise = resolver->promise();
368 m_webCache->dispatchBatch(new CacheDeleteCallback(resolver), batchOperations ); 368 m_webCache->dispatchBatch(new CacheDeleteCallback(resolver), batchOperations );
369 return promise; 369 return promise;
370 } 370 }
371 371
372 ScriptPromise Cache::putImpl(ScriptState* scriptState, Request* request, Respons e* response) 372 ScriptPromise Cache::putImpl(ScriptState* scriptState, Request* request, Respons e* response)
373 { 373 {
374 KURL url(KURL(), request->url());
375 if (!url.protocolIsInHTTPFamily())
376 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr ror("Request scheme '" + url.protocol() + "' is unsupported", scriptState->isola te()));
377 if (request->method() != "GET")
378 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr ror("Request method '" + request->method() + "' is unsupported", scriptState->is olate()));
379
374 WebVector<WebServiceWorkerCache::BatchOperation> batchOperations(size_t(1)); 380 WebVector<WebServiceWorkerCache::BatchOperation> batchOperations(size_t(1));
375 batchOperations[0].operationType = WebServiceWorkerCache::OperationTypePut; 381 batchOperations[0].operationType = WebServiceWorkerCache::OperationTypePut;
376 request->populateWebServiceWorkerRequest(batchOperations[0].request); 382 request->populateWebServiceWorkerRequest(batchOperations[0].request);
377 response->populateWebServiceWorkerResponse(batchOperations[0].response); 383 response->populateWebServiceWorkerResponse(batchOperations[0].response);
378 384
379 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip tState); 385 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip tState);
380 const ScriptPromise promise = resolver->promise(); 386 const ScriptPromise promise = resolver->promise();
381 m_webCache->dispatchBatch(new CacheWithOneResponseCallbacks(resolver), batch Operations); 387 m_webCache->dispatchBatch(new CacheWithOneResponseCallbacks(resolver), batch Operations);
382 return promise; 388 return promise;
383 } 389 }
(...skipping 11 matching lines...) Expand all
395 WebServiceWorkerRequest webRequest; 401 WebServiceWorkerRequest webRequest;
396 request->populateWebServiceWorkerRequest(webRequest); 402 request->populateWebServiceWorkerRequest(webRequest);
397 403
398 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip tState); 404 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip tState);
399 const ScriptPromise promise = resolver->promise(); 405 const ScriptPromise promise = resolver->promise();
400 m_webCache->dispatchKeys(new CacheWithRequestsCallbacks(resolver), 0, toWebQ ueryParams(options)); 406 m_webCache->dispatchKeys(new CacheWithRequestsCallbacks(resolver), 0, toWebQ ueryParams(options));
401 return promise; 407 return promise;
402 } 408 }
403 409
404 } // namespace blink 410 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/serviceworker/cache-put-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698