| OLD | NEW |
| (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 #ifndef ReadableStreamDataConsumerHandle_h | |
| 6 #define ReadableStreamDataConsumerHandle_h | |
| 7 | |
| 8 #include "bindings/core/v8/ScriptValue.h" | |
| 9 #include "modules/ModulesExport.h" | |
| 10 #include "modules/fetch/FetchDataConsumerHandle.h" | |
| 11 #include "wtf/Forward.h" | |
| 12 #include "wtf/PtrUtil.h" | |
| 13 #include "wtf/RefPtr.h" | |
| 14 #include <memory> | |
| 15 | |
| 16 namespace blink { | |
| 17 | |
| 18 class ScriptState; | |
| 19 | |
| 20 // This class is a FetchDataConsumerHandle pulling bytes from ReadableStream | |
| 21 // implemented with V8 Extras. | |
| 22 // The stream will be immediately locked by the handle and will never be | |
| 23 // released. | |
| 24 // | |
| 25 // The ReadableStreamReader handle held in a ReadableStreamDataConsumerHandle | |
| 26 // is weak. A user must guarantee that the ReadableStreamReader object is kept | |
| 27 // alive appropriately. | |
| 28 // TODO(yhirano): CURRENTLY THIS HANDLE SUPPORTS READING ONLY FROM THE THREAD ON | |
| 29 // WHICH IT IS CREATED. FIX THIS. | |
| 30 class MODULES_EXPORT ReadableStreamDataConsumerHandle final : public FetchDataCo
nsumerHandle { | |
| 31 WTF_MAKE_NONCOPYABLE(ReadableStreamDataConsumerHandle); | |
| 32 public: | |
| 33 static std::unique_ptr<ReadableStreamDataConsumerHandle> create(ScriptState*
scriptState, ScriptValue streamReader) | |
| 34 { | |
| 35 return wrapUnique(new ReadableStreamDataConsumerHandle(scriptState, stre
amReader)); | |
| 36 } | |
| 37 ~ReadableStreamDataConsumerHandle() override; | |
| 38 | |
| 39 std::unique_ptr<Reader> obtainFetchDataReader(Client*) override; | |
| 40 | |
| 41 private: | |
| 42 class ReadingContext; | |
| 43 ReadableStreamDataConsumerHandle(ScriptState*, ScriptValue streamReader); | |
| 44 const char* debugName() const override { return "ReadableStreamDataConsumerH
andle"; } | |
| 45 | |
| 46 RefPtr<ReadingContext> m_readingContext; | |
| 47 }; | |
| 48 | |
| 49 } // namespace blink | |
| 50 | |
| 51 #endif // ReadableStreamDataConsumerHandle_h | |
| OLD | NEW |