| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 | 93 |
| 94 void DidFetchDataLoadedString(const String& string) override { | 94 void DidFetchDataLoadedString(const String& string) override { |
| 95 if (!Resolver()->GetExecutionContext() || | 95 if (!Resolver()->GetExecutionContext() || |
| 96 Resolver()->GetExecutionContext()->IsContextDestroyed()) | 96 Resolver()->GetExecutionContext()->IsContextDestroyed()) |
| 97 return; | 97 return; |
| 98 ScriptState::Scope scope(Resolver()->GetScriptState()); | 98 ScriptState::Scope scope(Resolver()->GetScriptState()); |
| 99 v8::Isolate* isolate = Resolver()->GetScriptState()->GetIsolate(); | 99 v8::Isolate* isolate = Resolver()->GetScriptState()->GetIsolate(); |
| 100 v8::Local<v8::String> input_string = V8String(isolate, string); | 100 v8::Local<v8::String> input_string = V8String(isolate, string); |
| 101 v8::TryCatch trycatch(isolate); | 101 v8::TryCatch trycatch(isolate); |
| 102 v8::Local<v8::Value> parsed; | 102 v8::Local<v8::Value> parsed; |
| 103 if (V8Call(v8::JSON::Parse(isolate, input_string), parsed, trycatch)) | 103 if (v8::JSON::Parse(isolate, input_string).ToLocal(&parsed)) |
| 104 Resolver()->Resolve(parsed); | 104 Resolver()->Resolve(parsed); |
| 105 else | 105 else |
| 106 Resolver()->Reject(trycatch.Exception()); | 106 Resolver()->Reject(trycatch.Exception()); |
| 107 } | 107 } |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 } // namespace | 110 } // namespace |
| 111 | 111 |
| 112 ScriptPromise Body::arrayBuffer(ScriptState* script_state) { | 112 ScriptPromise Body::arrayBuffer(ScriptState* script_state) { |
| 113 ScriptPromise promise = RejectInvalidConsumption(script_state); | 113 ScriptPromise promise = RejectInvalidConsumption(script_state); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |