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

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

Issue 1969333002: [Fetch API] |(new Response(stream)).body| should return |stream| (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 "core/streams/ReadableStreamOperations.h" 5 #include "core/streams/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/ToV8.h" 9 #include "bindings/core/v8/ToV8.h"
10 #include "bindings/core/v8/V8ScriptRunner.h" 10 #include "bindings/core/v8/V8ScriptRunner.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 } 109 }
110 110
111 ScriptPromise ReadableStreamOperations::defaultReaderRead(ScriptState* scriptSta te, ScriptValue reader) 111 ScriptPromise ReadableStreamOperations::defaultReaderRead(ScriptState* scriptSta te, ScriptValue reader)
112 { 112 {
113 ASSERT(isReadableStreamDefaultReader(scriptState, reader)); 113 ASSERT(isReadableStreamDefaultReader(scriptState, reader));
114 114
115 v8::Local<v8::Value> args[] = { reader.v8Value() }; 115 v8::Local<v8::Value> args[] = { reader.v8Value() };
116 return ScriptPromise::cast(scriptState, V8ScriptRunner::callExtraOrCrash(scr iptState, "ReadableStreamDefaultReaderRead", args)); 116 return ScriptPromise::cast(scriptState, V8ScriptRunner::callExtraOrCrash(scr iptState, "ReadableStreamDefaultReaderRead", args));
117 } 117 }
118 118
119 void ReadableStreamOperations::tee(ScriptState* scriptState, ScriptValue stream, ScriptValue* newStream1, ScriptValue* newStream2)
120 {
121 ASSERT(isReadableStream(scriptState, stream));
122 ASSERT(!isLocked(scriptState, stream));
123
124 v8::TryCatch block(scriptState->isolate());
125 v8::Local<v8::Value> args[] = { stream.v8Value() };
126 ScriptValue result(scriptState, V8ScriptRunner::callExtra(scriptState, "Read ableStreamTee", args));
127 DCHECK(!block.HasCaught());
128 DCHECK(!result.isEmpty());
haraken 2016/05/13 07:06:03 Can you use V8ScriptRunner::callExtraOrCrash to ch
yhirano 2016/05/13 07:21:16 Done. Does that mean we don't need |block|? Curren
129 DCHECK(result.v8Value()->IsArray());
130 v8::Local<v8::Array> branches = result.v8Value().As<v8::Array>();
131 DCHECK_EQ(2u, branches->Length());
132 *newStream1 = ScriptValue(scriptState, v8CallOrCrash(branches->Get(scriptSta te->context(), 0)));
133 *newStream2 = ScriptValue(scriptState, v8CallOrCrash(branches->Get(scriptSta te->context(), 1)));
134
135 DCHECK(isReadableStream(scriptState, *newStream1));
136 DCHECK(isReadableStream(scriptState, *newStream2));
137 }
138
119 } // namespace blink 139 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698