| OLD | NEW |
| 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 #ifndef ReadableStreamDataConsumerHandle_h | 5 #ifndef ReadableStreamDataConsumerHandle_h |
| 6 #define ReadableStreamDataConsumerHandle_h | 6 #define ReadableStreamDataConsumerHandle_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptValue.h" |
| 8 #include "modules/ModulesExport.h" | 9 #include "modules/ModulesExport.h" |
| 9 #include "modules/fetch/FetchDataConsumerHandle.h" | 10 #include "modules/fetch/FetchDataConsumerHandle.h" |
| 10 #include "wtf/Forward.h" | 11 #include "wtf/Forward.h" |
| 11 #include "wtf/PassOwnPtr.h" | 12 #include "wtf/PassOwnPtr.h" |
| 12 #include "wtf/RefPtr.h" | 13 #include "wtf/RefPtr.h" |
| 13 #include <v8.h> | |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 | 16 |
| 17 class ScriptState; | 17 class ScriptState; |
| 18 | 18 |
| 19 // This class is a FetchDataConsumerHandle pulling bytes from ReadableStream | 19 // This class is a FetchDataConsumerHandle pulling bytes from ReadableStream |
| 20 // implemented with V8 Extras. | 20 // implemented with V8 Extras. |
| 21 // The stream will be immediately locked by the handle and will never be | 21 // The stream will be immediately locked by the handle and will never be |
| 22 // released. | 22 // released. |
| 23 // TODO(yhirano): CURRENTLY THIS HANDLE SUPPORTS READING ONLY FROM THE THREAD ON | 23 // TODO(yhirano): CURRENTLY THIS HANDLE SUPPORTS READING ONLY FROM THE THREAD ON |
| 24 // WHICH IT IS CREATED. FIX THIS. | 24 // WHICH IT IS CREATED. FIX THIS. |
| 25 // TODO(yhirano): This implementation may cause leaks because the handle and | 25 // TODO(yhirano): This implementation may cause leaks because the handle and |
| 26 // the reader own a strong reference to the associated ReadableStreamReader. | 26 // the reader own a strong reference to the associated ReadableStreamReader. |
| 27 // Fix it. | 27 // Fix it. |
| 28 class MODULES_EXPORT ReadableStreamDataConsumerHandle final : public FetchDataCo
nsumerHandle { | 28 class MODULES_EXPORT ReadableStreamDataConsumerHandle final : public FetchDataCo
nsumerHandle { |
| 29 WTF_MAKE_NONCOPYABLE(ReadableStreamDataConsumerHandle); | 29 WTF_MAKE_NONCOPYABLE(ReadableStreamDataConsumerHandle); |
| 30 public: | 30 public: |
| 31 static PassOwnPtr<ReadableStreamDataConsumerHandle> create(ScriptState* scri
ptState, v8::Local<v8::Value> stream) | 31 static PassOwnPtr<ReadableStreamDataConsumerHandle> create(ScriptState* scri
ptState, ScriptValue stream) |
| 32 { | 32 { |
| 33 return adoptPtr(new ReadableStreamDataConsumerHandle(scriptState, stream
)); | 33 return adoptPtr(new ReadableStreamDataConsumerHandle(scriptState, stream
)); |
| 34 } | 34 } |
| 35 ~ReadableStreamDataConsumerHandle() override; | 35 ~ReadableStreamDataConsumerHandle() override; |
| 36 | 36 |
| 37 private: | 37 private: |
| 38 class ReadingContext; | 38 class ReadingContext; |
| 39 ReadableStreamDataConsumerHandle(ScriptState*, v8::Local<v8::Value> stream); | 39 ReadableStreamDataConsumerHandle(ScriptState*, ScriptValue stream); |
| 40 Reader* obtainReaderInternal(Client*) override; | 40 Reader* obtainReaderInternal(Client*) override; |
| 41 const char* debugName() const override { return "ReadableStreamDataConsumerH
andle"; } | 41 const char* debugName() const override { return "ReadableStreamDataConsumerH
andle"; } |
| 42 | 42 |
| 43 RefPtr<ReadingContext> m_readingContext; | 43 RefPtr<ReadingContext> m_readingContext; |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 } // namespace blink | 46 } // namespace blink |
| 47 | 47 |
| 48 #endif // ReadableStreamDataConsumerHandle_h | 48 #endif // ReadableStreamDataConsumerHandle_h |
| OLD | NEW |