OLD | NEW |
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/Body.h" | 5 #include "modules/fetch/Body.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include "bindings/core/v8/ScriptPromiseResolver.h" | 8 #include "bindings/core/v8/ScriptPromiseResolver.h" |
9 #include "bindings/core/v8/ScriptState.h" | 9 #include "bindings/core/v8/ScriptState.h" |
10 #include "bindings/core/v8/V8ArrayBuffer.h" | 10 #include "bindings/core/v8/V8ArrayBuffer.h" |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 } else { | 196 } else { |
197 resolver->Resolve(String()); | 197 resolver->Resolve(String()); |
198 } | 198 } |
199 return promise; | 199 return promise; |
200 } | 200 } |
201 | 201 |
202 ScriptValue Body::body(ScriptState* script_state) { | 202 ScriptValue Body::body(ScriptState* script_state) { |
203 if (!BodyBuffer()) | 203 if (!BodyBuffer()) |
204 return ScriptValue::CreateNull(script_state); | 204 return ScriptValue::CreateNull(script_state); |
205 ScriptValue stream = BodyBuffer()->Stream(); | 205 ScriptValue stream = BodyBuffer()->Stream(); |
206 ASSERT(stream.GetScriptState() == script_state); | 206 DCHECK_EQ(stream.GetScriptState(), script_state); |
207 return stream; | 207 return stream; |
208 } | 208 } |
209 | 209 |
210 bool Body::bodyUsed() { | 210 bool Body::bodyUsed() { |
211 return BodyBuffer() && BodyBuffer()->IsStreamDisturbed(); | 211 return BodyBuffer() && BodyBuffer()->IsStreamDisturbed(); |
212 } | 212 } |
213 | 213 |
214 bool Body::IsBodyLocked() { | 214 bool Body::IsBodyLocked() { |
215 return BodyBuffer() && BodyBuffer()->IsStreamLocked(); | 215 return BodyBuffer() && BodyBuffer()->IsStreamLocked(); |
216 } | 216 } |
(...skipping 10 matching lines...) Expand all Loading... |
227 | 227 |
228 ScriptPromise Body::RejectInvalidConsumption(ScriptState* script_state) { | 228 ScriptPromise Body::RejectInvalidConsumption(ScriptState* script_state) { |
229 if (IsBodyLocked() || bodyUsed()) | 229 if (IsBodyLocked() || bodyUsed()) |
230 return ScriptPromise::Reject( | 230 return ScriptPromise::Reject( |
231 script_state, V8ThrowException::CreateTypeError( | 231 script_state, V8ThrowException::CreateTypeError( |
232 script_state->GetIsolate(), "Already read")); | 232 script_state->GetIsolate(), "Already read")); |
233 return ScriptPromise(); | 233 return ScriptPromise(); |
234 } | 234 } |
235 | 235 |
236 } // namespace blink | 236 } // namespace blink |
OLD | NEW |