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

Side by Side Diff: third_party/WebKit/Source/modules/fetch/RequestInit.cpp

Issue 1844223002: Literal AtomicString construction can rely on strlen optimization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/fetch/RequestInit.h" 5 #include "modules/fetch/RequestInit.h"
6 6
7 #include "bindings/core/v8/Dictionary.h" 7 #include "bindings/core/v8/Dictionary.h"
8 #include "bindings/core/v8/V8ArrayBuffer.h" 8 #include "bindings/core/v8/V8ArrayBuffer.h"
9 #include "bindings/core/v8/V8ArrayBufferView.h" 9 #include "bindings/core/v8/V8ArrayBufferView.h"
10 #include "bindings/core/v8/V8Binding.h" 10 #include "bindings/core/v8/V8Binding.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 } else if (v8Body->IsArrayBufferView()) { 72 } else if (v8Body->IsArrayBufferView()) {
73 body = FetchFormDataConsumerHandle::create(V8ArrayBufferView::toImpl(v8: :Local<v8::Object>::Cast(v8Body))); 73 body = FetchFormDataConsumerHandle::create(V8ArrayBufferView::toImpl(v8: :Local<v8::Object>::Cast(v8Body)));
74 } else if (V8Blob::hasInstance(v8Body, isolate)) { 74 } else if (V8Blob::hasInstance(v8Body, isolate)) {
75 RefPtr<BlobDataHandle> blobDataHandle = V8Blob::toImpl(v8::Local<v8::Obj ect>::Cast(v8Body))->blobDataHandle(); 75 RefPtr<BlobDataHandle> blobDataHandle = V8Blob::toImpl(v8::Local<v8::Obj ect>::Cast(v8Body))->blobDataHandle();
76 contentType = blobDataHandle->type(); 76 contentType = blobDataHandle->type();
77 body = FetchBlobDataConsumerHandle::create(context, blobDataHandle.relea se()); 77 body = FetchBlobDataConsumerHandle::create(context, blobDataHandle.relea se());
78 } else if (V8FormData::hasInstance(v8Body, isolate)) { 78 } else if (V8FormData::hasInstance(v8Body, isolate)) {
79 RefPtr<EncodedFormData> formData = V8FormData::toImpl(v8::Local<v8::Obje ct>::Cast(v8Body))->encodeMultiPartFormData(); 79 RefPtr<EncodedFormData> formData = V8FormData::toImpl(v8::Local<v8::Obje ct>::Cast(v8Body))->encodeMultiPartFormData();
80 // Here we handle formData->boundary() as a C-style string. See 80 // Here we handle formData->boundary() as a C-style string. See
81 // FormDataEncoder::generateUniqueBoundaryString. 81 // FormDataEncoder::generateUniqueBoundaryString.
82 contentType = AtomicString("multipart/form-data; boundary=", AtomicStrin g::ConstructFromLiteral) + formData->boundary().data(); 82 contentType = AtomicString("multipart/form-data; boundary=") + formData- >boundary().data();
83 body = FetchFormDataConsumerHandle::create(context, formData.release()); 83 body = FetchFormDataConsumerHandle::create(context, formData.release());
84 } else if (V8URLSearchParams::hasInstance(v8Body, isolate)) { 84 } else if (V8URLSearchParams::hasInstance(v8Body, isolate)) {
85 RefPtr<EncodedFormData> formData = V8URLSearchParams::toImpl(v8::Local<v 8::Object>::Cast(v8Body))->encodeFormData(); 85 RefPtr<EncodedFormData> formData = V8URLSearchParams::toImpl(v8::Local<v 8::Object>::Cast(v8Body))->encodeFormData();
86 contentType = AtomicString("application/x-www-form-urlencoded;charset=UT F-8", AtomicString::ConstructFromLiteral); 86 contentType = AtomicString("application/x-www-form-urlencoded;charset=UT F-8");
87 body = FetchFormDataConsumerHandle::create(context, formData.release()); 87 body = FetchFormDataConsumerHandle::create(context, formData.release());
88 } else if (V8PasswordCredential::hasInstance(v8Body, isolate)) { 88 } else if (V8PasswordCredential::hasInstance(v8Body, isolate)) {
89 // See https://w3c.github.io/webappsec-credential-management/#monkey-pat ching-fetch-4 89 // See https://w3c.github.io/webappsec-credential-management/#monkey-pat ching-fetch-4
90 // and https://w3c.github.io/webappsec-credential-management/#monkey-pat ching-fetch-3 90 // and https://w3c.github.io/webappsec-credential-management/#monkey-pat ching-fetch-3
91 isCredentialRequest = true; 91 isCredentialRequest = true;
92 PasswordCredential* credential = V8PasswordCredential::toImpl(v8::Local< v8::Object>::Cast(v8Body)); 92 PasswordCredential* credential = V8PasswordCredential::toImpl(v8::Local< v8::Object>::Cast(v8Body));
93 93
94 RefPtr<EncodedFormData> encodedData = credential->encodeFormData(content Type); 94 RefPtr<EncodedFormData> encodedData = credential->encodeFormData(content Type);
95 body = FetchFormDataConsumerHandle::create(context, encodedData.release( )); 95 body = FetchFormDataConsumerHandle::create(context, encodedData.release( ));
96 } else if (v8Body->IsString()) { 96 } else if (v8Body->IsString()) {
97 contentType = "text/plain;charset=UTF-8"; 97 contentType = "text/plain;charset=UTF-8";
98 body = FetchFormDataConsumerHandle::create(toUSVString(isolate, v8Body, exceptionState)); 98 body = FetchFormDataConsumerHandle::create(toUSVString(isolate, v8Body, exceptionState));
99 } 99 }
100 } 100 }
101 101
102 } // namespace blink 102 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698