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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ReadableStreamOperations.cpp

Issue 1595713003: Make ReadableStreamOperations use ScriptValue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comment and add a couple asserts Created 4 years, 11 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "bindings/core/v8/ReadableStreamOperations.h" 5 #include "bindings/core/v8/ReadableStreamOperations.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "bindings/core/v8/ScriptState.h" 8 #include "bindings/core/v8/ScriptState.h"
9 #include "bindings/core/v8/V8Binding.h" 9 #include "bindings/core/v8/V8Binding.h"
10 10
11 namespace blink { 11 namespace blink {
12 12
13 ScriptValue ReadableStreamOperations::getReader(ScriptState* scriptState, v8::Lo cal<v8::Value> stream, ExceptionState& es) 13 ScriptValue ReadableStreamOperations::getReader(ScriptState* scriptState, Script Value stream, ExceptionState& es)
14 { 14 {
15 ASSERT(isReadableStream(scriptState, stream)); 15 ASSERT(isReadableStream(scriptState, stream));
16 16
17 v8::TryCatch block(scriptState->isolate()); 17 v8::TryCatch block(scriptState->isolate());
18 v8::Local<v8::Value> args[] = { stream }; 18 v8::Local<v8::Value> args[] = { stream.v8Value() };
19 ScriptValue result(scriptState, v8CallExtra(scriptState, "AcquireReadableStr eamReader", args)); 19 ScriptValue result(scriptState, v8CallExtra(scriptState, "AcquireReadableStr eamReader", args));
20 if (block.HasCaught()) 20 if (block.HasCaught())
21 es.rethrowV8Exception(block.Exception()); 21 es.rethrowV8Exception(block.Exception());
22 return result; 22 return result;
23 } 23 }
24 24
25 bool ReadableStreamOperations::isReadableStream(ScriptState* scriptState, v8::Lo cal<v8::Value> value) 25 bool ReadableStreamOperations::isReadableStream(ScriptState* scriptState, Script Value value)
26 { 26 {
27 if (!value->IsObject()) 27 ASSERT(!value.isEmpty());
28
29 if (!value.isObject())
28 return false; 30 return false;
29 31
30 v8::Local<v8::Value> args[] = { value }; 32 v8::Local<v8::Value> args[] = { value.v8Value() };
31 return v8CallExtraOrCrash(scriptState, "IsReadableStream", args)->ToBoolean( )->Value(); 33 return v8CallExtraOrCrash(scriptState, "IsReadableStream", args)->ToBoolean( )->Value();
32 } 34 }
33 35
34 bool ReadableStreamOperations::isDisturbed(ScriptState* scriptState, v8::Local<v 8::Value> stream) 36 bool ReadableStreamOperations::isDisturbed(ScriptState* scriptState, ScriptValue stream)
35 { 37 {
36 ASSERT(isReadableStream(scriptState, stream)); 38 ASSERT(isReadableStream(scriptState, stream));
37 39
38 v8::Local<v8::Value> args[] = { stream }; 40 v8::Local<v8::Value> args[] = { stream.v8Value() };
39 return v8CallExtraOrCrash(scriptState, "IsReadableStreamDisturbed", args)->T oBoolean()->Value(); 41 return v8CallExtraOrCrash(scriptState, "IsReadableStreamDisturbed", args)->T oBoolean()->Value();
40 } 42 }
41 43
42 bool ReadableStreamOperations::isLocked(ScriptState* scriptState, v8::Local<v8:: Value> stream) 44 bool ReadableStreamOperations::isLocked(ScriptState* scriptState, ScriptValue st ream)
43 { 45 {
44 ASSERT(isReadableStream(scriptState, stream)); 46 ASSERT(isReadableStream(scriptState, stream));
45 47
46 v8::Local<v8::Value> args[] = { stream }; 48 v8::Local<v8::Value> args[] = { stream.v8Value() };
47 return v8CallExtraOrCrash(scriptState, "IsReadableStreamLocked", args)->ToBo olean()->Value(); 49 return v8CallExtraOrCrash(scriptState, "IsReadableStreamLocked", args)->ToBo olean()->Value();
48 } 50 }
49 51
50 bool ReadableStreamOperations::isReadableStreamReader(ScriptState* scriptState, v8::Local<v8::Value> value) 52 bool ReadableStreamOperations::isReadableStreamReader(ScriptState* scriptState, ScriptValue value)
51 { 53 {
52 if (!value->IsObject()) 54 ASSERT(!value.isEmpty());
55
56 if (!value.isObject())
53 return false; 57 return false;
54 58
55 v8::Local<v8::Value> args[] = { value }; 59 v8::Local<v8::Value> args[] = { value.v8Value() };
56 return v8CallExtraOrCrash(scriptState, "IsReadableStreamReader", args)->ToBo olean()->Value(); 60 return v8CallExtraOrCrash(scriptState, "IsReadableStreamReader", args)->ToBo olean()->Value();
57 } 61 }
58 62
59 ScriptPromise ReadableStreamOperations::read(ScriptState* scriptState, v8::Local <v8::Value> reader) 63 ScriptPromise ReadableStreamOperations::read(ScriptState* scriptState, ScriptVal ue reader)
60 { 64 {
61 ASSERT(isReadableStreamReader(scriptState, reader)); 65 ASSERT(isReadableStreamReader(scriptState, reader));
62 66
63 v8::Local<v8::Value> args[] = { reader }; 67 v8::Local<v8::Value> args[] = { reader.v8Value() };
64 return ScriptPromise::cast(scriptState, v8CallExtraOrCrash(scriptState, "Rea dFromReadableStreamReader", args)); 68 return ScriptPromise::cast(scriptState, v8CallExtraOrCrash(scriptState, "Rea dFromReadableStreamReader", args));
65 } 69 }
66 70
67 } // namespace blink 71 } // namespace blink
68 72
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698