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