OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "config.h" | |
6 #include "core/streams/ReadableStream.h" | |
7 | |
8 #include "bindings/core/v8/ExceptionState.h" | |
9 #include "bindings/core/v8/ScriptFunction.h" | |
10 #include "bindings/core/v8/V8Binding.h" | |
11 #include "core/streams/UnderlyingSource.h" | |
12 | |
13 namespace WebCore { | |
tkent
2014/07/30 01:52:25
namespace blink
yhirano
2014/07/30 03:27:23
Done.
| |
14 | |
15 class ReadableStream::OnStarted : public ScriptFunction { | |
16 public: | |
17 OnStarted(v8::Isolate* isolate, ReadableStream* stream) | |
18 : ScriptFunction(isolate) | |
19 , m_stream(stream) { } | |
20 virtual ScriptValue call(ScriptValue value) OVERRIDE | |
21 { | |
22 m_stream->onStarted(); | |
23 return value; | |
24 } | |
25 | |
26 private: | |
27 Persistent<ReadableStream> m_stream; | |
28 }; | |
29 | |
30 class ReadableStream::OnStartFailed : public ScriptFunction { | |
31 public: | |
32 OnStartFailed(v8::Isolate* isolate, ReadableStream* stream) | |
33 : ScriptFunction(isolate) | |
34 , m_stream(stream) { } | |
35 virtual ScriptValue call(ScriptValue value) OVERRIDE | |
36 { | |
37 m_stream->error(value); | |
38 return value; | |
39 } | |
40 | |
41 private: | |
42 Persistent<ReadableStream> m_stream; | |
43 }; | |
44 | |
45 ReadableStream::ReadableStream(ScriptState* scriptState, UnderlyingSource* sourc e, ExceptionState* exceptionState) | |
46 : m_scriptState(scriptState) | |
47 , m_source(source) | |
48 , m_isStarted(false) | |
49 , m_isDraining(false) | |
50 , m_isPulling(false) | |
51 , m_state(Waiting) | |
52 { | |
53 ScriptPromise promise = source->startSource(exceptionState); | |
54 promise.then(adoptPtr(new OnStarted(scriptState->isolate(), this)), adoptPtr (new OnStartFailed(scriptState->isolate(), this))); | |
55 } | |
56 | |
57 ReadableStream::~ReadableStream() | |
58 { | |
59 } | |
60 | |
61 bool ReadableStream::enqueueInternal(ScriptValue chunk) | |
62 { | |
63 // FIXME: Implemnt this method. | |
64 return false; | |
65 } | |
66 | |
67 void ReadableStream::error(ScriptValue error) | |
68 { | |
69 // FIXME: Implement this function correctly. | |
70 m_state = Errored; | |
71 } | |
72 | |
73 void ReadableStream::onStarted() | |
74 { | |
75 m_isStarted = true; | |
76 } | |
77 | |
78 void ReadableStream::trace(Visitor* visitor) | |
79 { | |
80 visitor->trace(m_source); | |
81 } | |
82 | |
83 } // namespace WebCore | |
tkent
2014/07/30 01:52:24
namespace blink
yhirano
2014/07/30 03:27:23
Done.
| |
84 | |
OLD | NEW |