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

Unified Diff: Source/modules/serviceworkers/Request.cpp

Issue 562413003: Request construction spec changes to use the 'used' flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
Index: Source/modules/serviceworkers/Request.cpp
diff --git a/Source/modules/serviceworkers/Request.cpp b/Source/modules/serviceworkers/Request.cpp
index 228183ab44e1f76190ec19d5d79be7e9cc30d7fc..71744fbad68a3ff3b7138ff56ae12c08e44b03b6 100644
--- a/Source/modules/serviceworkers/Request.cpp
+++ b/Source/modules/serviceworkers/Request.cpp
@@ -194,12 +194,21 @@ Request* Request::create(ExecutionContext* context, Request* input, ExceptionSta
Request* Request::create(ExecutionContext* context, Request* input, const Dictionary& init, ExceptionState& exceptionState)
{
- // "1. Let |request| be |input|'s associated request, if |input| is a
+ // "1. If input is a Request object, run these substeps:"
+ // " 1. If input's used flag is set, throw a TypeError."
+ // " 2. Set input's used flag."
+ if (input->bodyUsed()) {
+ exceptionState.throwTypeError(
+ "Cannot construct a Request with a Request object that has already been used.");
+ return 0;
+ }
+ input->setUsed();
+ // "2. Let |request| be |input|'s associated request, if |input| is a
// Request object, and a new request otherwise."
- // "2. Set |request| to a restricted copy of itself."
+ // "3. Set |request| to a restricted copy of itself."
FetchRequestData* request(input->request()->createRestrictedCopy(context, SecurityOrigin::create(context->url())));
- // "3. Let |fallbackMode| be null."
- // "4. Let |fallbackCredentials| be null."
+ // "4. Let |fallbackMode| be null."
+ // "5. Let |fallbackCredentials| be null."
// Instead of using null as a special fallback value, just pass the current
// mode and credentials; it has the same effect.
const FetchRequestData::Mode currentMode = request->mode();
« Source/modules/serviceworkers/Body.h ('K') | « Source/modules/serviceworkers/Body.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698