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

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

Issue 2167973003: Use As than Cast in RequestInit.cpp (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 | « no previous file | 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 "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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 91
92 v8::Isolate* isolate = toIsolate(context); 92 v8::Isolate* isolate = toIsolate(context);
93 if (isCredentialSet) { 93 if (isCredentialSet) {
94 if (V8PasswordCredential::hasInstance(v8Credential, isolate)) { 94 if (V8PasswordCredential::hasInstance(v8Credential, isolate)) {
95 // TODO(mkwst): According to the spec, we'd serialize this once we t ouch the network. We're 95 // TODO(mkwst): According to the spec, we'd serialize this once we t ouch the network. We're
96 // serializing it here, ahead of time, because lifetime issues aroun d ResourceRequest make 96 // serializing it here, ahead of time, because lifetime issues aroun d ResourceRequest make
97 // it pretty difficult to pass a PasswordCredential around at the pl atform level, and the 97 // it pretty difficult to pass a PasswordCredential around at the pl atform level, and the
98 // hop between the browser and renderer processes to deal with servi ce workers is equally 98 // hop between the browser and renderer processes to deal with servi ce workers is equally
99 // painful. There should be no developer-visible difference in behav ior with this option, 99 // painful. There should be no developer-visible difference in behav ior with this option,
100 // except that the `Content-Type` header will be set early. That see ms reasonable. 100 // except that the `Content-Type` header will be set early. That see ms reasonable.
101 PasswordCredential* credential = V8PasswordCredential::toImpl(v8::Lo cal<v8::Object>::Cast(v8Credential)); 101 PasswordCredential* credential = V8PasswordCredential::toImpl(v8Cred ential.As<v8::Object>());
102 attachedCredential = credential->encodeFormData(contentType); 102 attachedCredential = credential->encodeFormData(contentType);
103 credentials = "password"; 103 credentials = "password";
104 } else if (v8Credential->IsString()) { 104 } else if (v8Credential->IsString()) {
105 credentials = toUSVString(isolate, v8Credential, exceptionState); 105 credentials = toUSVString(isolate, v8Credential, exceptionState);
106 } 106 }
107 } 107 }
108 108
109 if (attachedCredential.get() || !isBodySet || v8Body->IsUndefined() || v8Bod y->IsNull()) 109 if (attachedCredential.get() || !isBodySet || v8Body->IsUndefined() || v8Bod y->IsNull())
110 return; 110 return;
111 111
112 if (v8Body->IsArrayBuffer()) { 112 if (v8Body->IsArrayBuffer()) {
113 body = FetchFormDataConsumerHandle::create(V8ArrayBuffer::toImpl(v8::Loc al<v8::Object>::Cast(v8Body))); 113 body = FetchFormDataConsumerHandle::create(V8ArrayBuffer::toImpl(v8Body. As<v8::Object>()));
114 } else if (v8Body->IsArrayBufferView()) { 114 } else if (v8Body->IsArrayBufferView()) {
115 body = FetchFormDataConsumerHandle::create(V8ArrayBufferView::toImpl(v8: :Local<v8::Object>::Cast(v8Body))); 115 body = FetchFormDataConsumerHandle::create(V8ArrayBufferView::toImpl(v8B ody.As<v8::Object>()));
116 } else if (V8Blob::hasInstance(v8Body, isolate)) { 116 } else if (V8Blob::hasInstance(v8Body, isolate)) {
117 RefPtr<BlobDataHandle> blobDataHandle = V8Blob::toImpl(v8::Local<v8::Obj ect>::Cast(v8Body))->blobDataHandle(); 117 RefPtr<BlobDataHandle> blobDataHandle = V8Blob::toImpl(v8Body.As<v8::Obj ect>())->blobDataHandle();
118 contentType = blobDataHandle->type(); 118 contentType = blobDataHandle->type();
119 body = FetchBlobDataConsumerHandle::create(context, blobDataHandle.relea se()); 119 body = FetchBlobDataConsumerHandle::create(context, blobDataHandle.relea se());
120 } else if (V8FormData::hasInstance(v8Body, isolate)) { 120 } else if (V8FormData::hasInstance(v8Body, isolate)) {
121 RefPtr<EncodedFormData> formData = V8FormData::toImpl(v8::Local<v8::Obje ct>::Cast(v8Body))->encodeMultiPartFormData(); 121 RefPtr<EncodedFormData> formData = V8FormData::toImpl(v8Body.As<v8::Obje ct>())->encodeMultiPartFormData();
122 // Here we handle formData->boundary() as a C-style string. See 122 // Here we handle formData->boundary() as a C-style string. See
123 // FormDataEncoder::generateUniqueBoundaryString. 123 // FormDataEncoder::generateUniqueBoundaryString.
124 contentType = AtomicString("multipart/form-data; boundary=") + formData- >boundary().data(); 124 contentType = AtomicString("multipart/form-data; boundary=") + formData- >boundary().data();
125 body = FetchFormDataConsumerHandle::create(context, formData.release()); 125 body = FetchFormDataConsumerHandle::create(context, formData.release());
126 } else if (V8URLSearchParams::hasInstance(v8Body, isolate)) { 126 } else if (V8URLSearchParams::hasInstance(v8Body, isolate)) {
127 RefPtr<EncodedFormData> formData = V8URLSearchParams::toImpl(v8::Local<v 8::Object>::Cast(v8Body))->toEncodedFormData(); 127 RefPtr<EncodedFormData> formData = V8URLSearchParams::toImpl(v8Body.As<v 8::Object>())->toEncodedFormData();
128 contentType = AtomicString("application/x-www-form-urlencoded;charset=UT F-8"); 128 contentType = AtomicString("application/x-www-form-urlencoded;charset=UT F-8");
129 body = FetchFormDataConsumerHandle::create(context, formData.release()); 129 body = FetchFormDataConsumerHandle::create(context, formData.release());
130 } else if (v8Body->IsString()) { 130 } else if (v8Body->IsString()) {
131 contentType = "text/plain;charset=UTF-8"; 131 contentType = "text/plain;charset=UTF-8";
132 body = FetchFormDataConsumerHandle::create(toUSVString(isolate, v8Body, exceptionState)); 132 body = FetchFormDataConsumerHandle::create(toUSVString(isolate, v8Body, exceptionState));
133 } 133 }
134 } 134 }
135 135
136 } // namespace blink 136 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698