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

Side by Side Diff: Source/core/streams/UnderlyingSourceBase.cpp

Issue 1167343002: Add methods for creating V8 extras-based ReadableStreams from C++ (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: That todo is not necessary according to yhirano@ Created 5 years, 5 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "core/streams/UnderlyingSourceBase.h"
7
8 #include "core/streams/ReadableStreamController.h"
9 #include <v8.h>
10
11 namespace blink {
12
13 ScriptPromise UnderlyingSourceBase::startWrapper(ScriptState* scriptState, Scrip tValue stream)
14 {
15 // Cannot call start twice (e.g., cannot use the same UnderlyingSourceBase t o construct multiple streams)
16 ASSERT(!m_controller);
17
18 // In ReadableStream.js, we special-case externally-controlled streams by ha ving them pass themselves to start
19 // as the first argument. This allows us to create a ReadableStreamControlle r.
20
21 m_controller = new ReadableStreamController(stream);
22
23 return start(scriptState);
24 }
25
26 ScriptPromise UnderlyingSourceBase::start(ScriptState* scriptState)
27 {
28 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isolate() ));
29 }
30
31 ScriptPromise UnderlyingSourceBase::pull(ScriptState* scriptState)
32 {
33 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isolate() ));
34 }
35
36 ScriptPromise UnderlyingSourceBase::cancelWrapper(ScriptState* scriptState, Scri ptValue reason)
37 {
38 m_controller->noteHasBeenCanceled();
39 return cancel(scriptState, reason);
40 }
41
42 ScriptPromise UnderlyingSourceBase::cancel(ScriptState* scriptState, ScriptValue reason)
43 {
44 return ScriptPromise::cast(scriptState, v8::Undefined(scriptState->isolate() ));
45 }
46
47 bool UnderlyingSourceBase::hasPendingActivity() const
48 {
49 return m_controller && m_controller->isActive();
50 }
51
52
53 DEFINE_TRACE(UnderlyingSourceBase)
54 {
55 ActiveDOMObject::trace(visitor);
56 visitor->trace(m_controller);
57 }
58
59 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/streams/UnderlyingSourceBase.h ('k') | Source/core/streams/UnderlyingSourceBase.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698