| 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 DataConsumerHandleUtil_h | 5 #ifndef DataConsumerHandleUtil_h |
| 6 #define DataConsumerHandleUtil_h | 6 #define DataConsumerHandleUtil_h |
| 7 | 7 |
| 8 #include "modules/ModulesExport.h" | 8 #include "modules/ModulesExport.h" |
| 9 #include "modules/fetch/FetchDataConsumerHandle.h" | 9 #include "modules/fetch/FetchDataConsumerHandle.h" |
| 10 #include "public/platform/WebDataConsumerHandle.h" | 10 #include "public/platform/WebDataConsumerHandle.h" |
| 11 #include "wtf/Allocator.h" | |
| 12 #include "wtf/WeakPtr.h" | |
| 13 #include <memory> | 11 #include <memory> |
| 14 | 12 |
| 15 namespace blink { | 13 namespace blink { |
| 16 | 14 |
| 17 // Returns a handle that returns ShouldWait for read / beginRead and | 15 // Returns a handle that returns ShouldWait for read / beginRead and |
| 18 // UnexpectedError for endRead. | 16 // UnexpectedError for endRead. |
| 19 MODULES_EXPORT std::unique_ptr<WebDataConsumerHandle> | 17 MODULES_EXPORT std::unique_ptr<WebDataConsumerHandle> |
| 20 createWaitingDataConsumerHandle(); | 18 createWaitingDataConsumerHandle(); |
| 21 | 19 |
| 22 // Returns a handle that returns Done for read / beginRead and | |
| 23 // UnexpectedError for endRead. | |
| 24 MODULES_EXPORT std::unique_ptr<WebDataConsumerHandle> | |
| 25 createDoneDataConsumerHandle(); | |
| 26 | |
| 27 // Returns a handle that returns UnexpectedError for read / beginRead / | |
| 28 // endRead. | |
| 29 MODULES_EXPORT std::unique_ptr<WebDataConsumerHandle> | |
| 30 createUnexpectedErrorDataConsumerHandle(); | |
| 31 | |
| 32 // Returns a FetchDataConsumerHandle that wraps WebDataConsumerHandle. | 20 // Returns a FetchDataConsumerHandle that wraps WebDataConsumerHandle. |
| 33 MODULES_EXPORT std::unique_ptr<FetchDataConsumerHandle> | 21 MODULES_EXPORT std::unique_ptr<FetchDataConsumerHandle> |
| 34 createFetchDataConsumerHandleFromWebHandle( | 22 createFetchDataConsumerHandleFromWebHandle( |
| 35 std::unique_ptr<WebDataConsumerHandle>); | 23 std::unique_ptr<WebDataConsumerHandle>); |
| 36 | 24 |
| 37 // A helper class to call Client::didGetReadable() asynchronously after | |
| 38 // Reader creation. | |
| 39 // NotifyOnReaderCreationHelper must be owned by a reader and | |
| 40 // |client| must be the client of the reader. | |
| 41 class NotifyOnReaderCreationHelper final { | |
| 42 DISALLOW_NEW(); | |
| 43 | |
| 44 public: | |
| 45 NotifyOnReaderCreationHelper(WebDataConsumerHandle::Client* /* client */); | |
| 46 | |
| 47 private: | |
| 48 void notify(WebDataConsumerHandle::Client*); | |
| 49 | |
| 50 WeakPtrFactory<NotifyOnReaderCreationHelper> m_factory; | |
| 51 }; | |
| 52 | |
| 53 } // namespace blink | 25 } // namespace blink |
| 54 | 26 |
| 55 #endif // DataConsumerHandleUtil_h | 27 #endif // DataConsumerHandleUtil_h |
| OLD | NEW |