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

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

Issue 534133002: [WIP] bindings: Introduce PropertyBag (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 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 "config.h" 5 #include "config.h"
6 #include "RequestInit.h" 6 #include "RequestInit.h"
7 7
8 #include "bindings/core/v8/Dictionary.h"
9 #include "bindings/core/v8/V8Binding.h" 8 #include "bindings/core/v8/V8Binding.h"
10 #include "bindings/core/v8/V8Blob.h" 9 #include "bindings/core/v8/V8Blob.h"
11 #include "bindings/core/v8/V8FormData.h" 10 #include "bindings/core/v8/V8FormData.h"
12 #include "bindings/core/v8/custom/V8ArrayBufferCustom.h" 11 #include "bindings/core/v8/custom/V8ArrayBufferCustom.h"
13 #include "bindings/core/v8/custom/V8ArrayBufferViewCustom.h" 12 #include "bindings/core/v8/custom/V8ArrayBufferViewCustom.h"
13 #include "bindings/modules/v8/DictionaryForModules.h"
14 #include "core/fileapi/Blob.h" 14 #include "core/fileapi/Blob.h"
15 #include "modules/serviceworkers/Headers.h" 15 #include "modules/serviceworkers/Headers.h"
16 #include "platform/blob/BlobData.h" 16 #include "platform/blob/BlobData.h"
17 #include "platform/network/FormData.h" 17 #include "platform/network/FormData.h"
18 #include "wtf/ArrayBuffer.h" 18 #include "wtf/ArrayBuffer.h"
19 19
20 namespace blink { 20 namespace blink {
21 21
22 RequestInit::RequestInit(ExecutionContext* context, const Dictionary& options, E xceptionState& exceptionState) 22 RequestInit::RequestInit(ExecutionContext* context, const Dictionary& options, E xceptionState& exceptionState)
23 { 23 {
24 DictionaryHelper::get(options, "method", method); 24 options.get("method", method);
25 DictionaryHelper::get(options, "headers", headers); 25 options.get("headers", headers);
26 if (!headers) { 26 if (!headers) {
27 DictionaryHelper::get(options, "headers", headersDictionary); 27 options.get("headers", headersDictionary);
28 } 28 }
29 DictionaryHelper::get(options, "mode", mode); 29 options.get("mode", mode);
30 DictionaryHelper::get(options, "credentials", credentials); 30 options.get("credentials", credentials);
31 31
32 v8::Local<v8::Value> body; 32 v8::Local<v8::Value> body;
33 if (!DictionaryHelper::get(options, "body", body) || body->IsUndefined() || body->IsNull()) 33 if (!options.get("body", body) || body->IsUndefined() || body->IsNull())
34 return; 34 return;
35 OwnPtr<BlobData> blobData = BlobData::create(); 35 OwnPtr<BlobData> blobData = BlobData::create();
36 v8::Isolate* isolate = toIsolate(context); 36 v8::Isolate* isolate = toIsolate(context);
37 if (body->IsArrayBuffer()) { 37 if (body->IsArrayBuffer()) {
38 ArrayBuffer* arrayBuffer = V8ArrayBuffer::toImpl(v8::Handle<v8::Object>: :Cast(body)); 38 ArrayBuffer* arrayBuffer = V8ArrayBuffer::toImpl(v8::Handle<v8::Object>: :Cast(body));
39 ASSERT(arrayBuffer); 39 ASSERT(arrayBuffer);
40 blobData->appendArrayBuffer(arrayBuffer); 40 blobData->appendArrayBuffer(arrayBuffer);
41 } else if (body->IsArrayBufferView()) { 41 } else if (body->IsArrayBufferView()) {
42 ArrayBufferView* arrayBufferView = V8ArrayBufferView::toImpl(v8::Handle< v8::Object>::Cast(body)); 42 ArrayBufferView* arrayBufferView = V8ArrayBufferView::toImpl(v8::Handle< v8::Object>::Cast(body));
43 ASSERT(arrayBufferView); 43 ASSERT(arrayBufferView);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 blobData->appendText(stringValue, false); 80 blobData->appendText(stringValue, false);
81 blobData->setContentType("text/plain;charset=UTF-8"); 81 blobData->setContentType("text/plain;charset=UTF-8");
82 } else { 82 } else {
83 return; 83 return;
84 } 84 }
85 const long long blobSize = blobData->length(); 85 const long long blobSize = blobData->length();
86 bodyBlobHandle = BlobDataHandle::create(blobData.release(), blobSize); 86 bodyBlobHandle = BlobDataHandle::create(blobData.release(), blobSize);
87 } 87 }
88 88
89 } 89 }
OLDNEW
« no previous file with comments | « Source/modules/serviceworkers/RegistrationOptionList.h ('k') | Source/modules/serviceworkers/Response.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698