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

Side by Side Diff: third_party/WebKit/Source/core/dom/DOMArrayBuffer.cpp

Issue 2730943002: XMLHttpRequest: return null upon failing responseArrayBuffer allocation. (Closed)
Patch Set: mirror updated spec, and return |null| for failed allocs Created 3 years, 9 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 "core/dom/DOMArrayBuffer.h" 5 #include "core/dom/DOMArrayBuffer.h"
6 6
7 #include "bindings/core/v8/DOMDataStore.h" 7 #include "bindings/core/v8/DOMDataStore.h"
8 #include "wtf/RefPtr.h"
8 9
9 namespace blink { 10 namespace blink {
10 11
12 DOMArrayBuffer* DOMArrayBuffer::createUninitializedOrNull(
13 unsigned numElements,
14 unsigned elementByteSize) {
15 RefPtr<ArrayBuffer> buffer =
16 WTF::ArrayBuffer::createUninitializedOrNull(numElements, elementByteSize);
17 if (!buffer)
18 return nullptr;
19 return create(std::move(buffer));
20 }
21
11 v8::Local<v8::Object> DOMArrayBuffer::wrap( 22 v8::Local<v8::Object> DOMArrayBuffer::wrap(
12 v8::Isolate* isolate, 23 v8::Isolate* isolate,
13 v8::Local<v8::Object> creationContext) { 24 v8::Local<v8::Object> creationContext) {
14 DCHECK(!DOMDataStore::containsWrapper(this, isolate)); 25 DCHECK(!DOMDataStore::containsWrapper(this, isolate));
15 26
16 const WrapperTypeInfo* wrapperTypeInfo = this->wrapperTypeInfo(); 27 const WrapperTypeInfo* wrapperTypeInfo = this->wrapperTypeInfo();
17 v8::Local<v8::Object> wrapper = 28 v8::Local<v8::Object> wrapper =
18 v8::ArrayBuffer::New(isolate, data(), byteLength()); 29 v8::ArrayBuffer::New(isolate, data(), byteLength());
19 30
20 return associateWithWrapper(isolate, wrapperTypeInfo, wrapper); 31 return associateWithWrapper(isolate, wrapperTypeInfo, wrapper);
21 } 32 }
22 33
23 } // namespace blink 34 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/DOMArrayBuffer.h ('k') | third_party/WebKit/Source/core/mojo/MojoHandle.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698