| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 WebDataConsumerHandle_h | 5 #ifndef WebDataConsumerHandle_h |
| 6 #define WebDataConsumerHandle_h | 6 #define WebDataConsumerHandle_h |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "public/platform/WebCommon.h" | 11 #include "public/platform/WebCommon.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 class WebTaskRunner; |
| 16 |
| 15 // WebDataConsumerHandle represents the "consumer" side of a data pipe. A user | 17 // WebDataConsumerHandle represents the "consumer" side of a data pipe. A user |
| 16 // can read data from it. | 18 // can read data from it. |
| 17 // | 19 // |
| 18 // A WebDataConsumerHandle is a thread-safe object. A user can call | 20 // A WebDataConsumerHandle is a thread-safe object. A user can call |
| 19 // |obtainReader| or destruct the object on any thread. | 21 // |obtainReader| or destruct the object on any thread. |
| 20 // A WebDataConsumerHandle having a reader is called "locked". A | 22 // A WebDataConsumerHandle having a reader is called "locked". A |
| 21 // WebDataConsumerHandle or its reader are called "waiting" when reading from | 23 // WebDataConsumerHandle or its reader are called "waiting" when reading from |
| 22 // the handle or reader returns ShouldWait. | 24 // the handle or reader returns ShouldWait. |
| 23 // | 25 // |
| 24 // WebDataConsumerHandle can be created / used / destructed only on | 26 // WebDataConsumerHandle can be created / used / destructed only on |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 WebDataConsumerHandle(); | 95 WebDataConsumerHandle(); |
| 94 virtual ~WebDataConsumerHandle(); | 96 virtual ~WebDataConsumerHandle(); |
| 95 | 97 |
| 96 // Returns a non-null reader. This function can be called only when this | 98 // Returns a non-null reader. This function can be called only when this |
| 97 // handle is not locked. |client| can be null. Otherwise, |*client| must be | 99 // handle is not locked. |client| can be null. Otherwise, |*client| must be |
| 98 // valid as long as the reader is valid. The returned reader is bound to | 100 // valid as long as the reader is valid. The returned reader is bound to |
| 99 // the calling thread and client notification will be called on the thread | 101 // the calling thread and client notification will be called on the thread |
| 100 // if |client| is not null. | 102 // if |client| is not null. |
| 101 // If |client| is not null and the handle is not waiting, client | 103 // If |client| is not null and the handle is not waiting, client |
| 102 // notification is called asynchronously. | 104 // notification is called asynchronously. |
| 103 virtual std::unique_ptr<Reader> obtainReader(Client*) = 0; | 105 virtual std::unique_ptr<Reader> obtainReader(Client*, std::unique_ptr<WebTas
kRunner>) = 0; |
| 104 | 106 |
| 105 // Returns a string literal (e.g. class name) for debugging only. | 107 // Returns a string literal (e.g. class name) for debugging only. |
| 106 virtual const char* debugName() const = 0; | 108 virtual const char* debugName() const = 0; |
| 107 }; | 109 }; |
| 108 | 110 |
| 109 } // namespace blink | 111 } // namespace blink |
| 110 | 112 |
| 111 #endif // WebDataConsumerHandle_h | 113 #endif // WebDataConsumerHandle_h |
| OLD | NEW |