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

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

Issue 1414553002: Fix out-of-memory crashes related to ArrayBuffer allocation Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase+more tweaks Created 5 years, 1 month 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 "modules/fetch/Body.h" 6 #include "modules/fetch/Body.h"
7 7
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "bindings/core/v8/ScriptPromiseResolver.h" 9 #include "bindings/core/v8/ScriptPromiseResolver.h"
10 #include "bindings/core/v8/ScriptState.h" 10 #include "bindings/core/v8/ScriptState.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // gone (which means that the V8::TerminateExecution() signal has been sent 117 // gone (which means that the V8::TerminateExecution() signal has been sent
118 // to this worker thread). 118 // to this worker thread).
119 if (!scriptState->executionContext()) 119 if (!scriptState->executionContext())
120 return ScriptPromise(); 120 return ScriptPromise();
121 121
122 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; 122 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
123 ScriptPromise promise = resolver->promise(); 123 ScriptPromise promise = resolver->promise();
124 if (bodyBuffer()) { 124 if (bodyBuffer()) {
125 bodyBuffer()->startLoading(scriptState->executionContext(), FetchDataLoa der::createLoaderAsArrayBuffer(), new BodyArrayBufferConsumer(resolver)); 125 bodyBuffer()->startLoading(scriptState->executionContext(), FetchDataLoa der::createLoaderAsArrayBuffer(), new BodyArrayBufferConsumer(resolver));
126 } else { 126 } else {
127 resolver->resolve(DOMArrayBuffer::create(0u, 1)); 127 resolver->resolve(DOMArrayBuffer::deprecatedCreateOrCrash(nullptr, 1));
128 } 128 }
129 return promise; 129 return promise;
130 } 130 }
131 131
132 ScriptPromise Body::blob(ScriptState* scriptState) 132 ScriptPromise Body::blob(ScriptState* scriptState)
133 { 133 {
134 if (m_opaque) 134 if (m_opaque)
135 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr ror(scriptState->isolate(), "The body is opaque.")); 135 return ScriptPromise::reject(scriptState, V8ThrowException::createTypeEr ror(scriptState->isolate(), "The body is opaque."));
136 136
137 if (bodyUsed()) 137 if (bodyUsed())
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 220
221 Body::Body(ExecutionContext* context) 221 Body::Body(ExecutionContext* context)
222 : ActiveDOMObject(context) 222 : ActiveDOMObject(context)
223 , m_bodyPassed(false) 223 , m_bodyPassed(false)
224 , m_opaque(false) 224 , m_opaque(false)
225 { 225 {
226 suspendIfNeeded(); 226 suspendIfNeeded();
227 } 227 }
228 228
229 } // namespace blink 229 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698