Chromium Code Reviews| 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 20 matching lines...) Expand all Loading... | |
| 45 // The associated handle gets readable. This function will be called | 47 // The associated handle gets readable. This function will be called |
| 46 // when the associated reader was waiting but is not waiting any more. | 48 // when the associated reader was waiting but is not waiting any more. |
| 47 // This means this function can be called when handle gets errored or | 49 // This means this function can be called when handle gets errored or |
| 48 // closed. This also means that this function will not be called even | 50 // closed. This also means that this function will not be called even |
| 49 // when some data arrives if the handle already has non-empty readable | 51 // when some data arrives if the handle already has non-empty readable |
| 50 // data. | 52 // data. |
| 51 // It is not guaranteed that the handle is not waiting when this | 53 // It is not guaranteed that the handle is not waiting when this |
| 52 // function is called, i.e. it can be called more than needed. | 54 // function is called, i.e. it can be called more than needed. |
| 53 // One can use / destruct the associated reader in this function. | 55 // One can use / destruct the associated reader in this function. |
| 54 virtual void didGetReadable() = 0; | 56 virtual void didGetReadable() = 0; |
| 57 | |
| 58 virtual WebTaskRunner* getTaskRunner() = 0; | |
|
yhirano
2016/07/28 16:25:05
Please write comments. What is this? Is it allowed
| |
| 55 }; | 59 }; |
| 56 | 60 |
| 57 // This class provides a means to read data from the associated handle. A | 61 // This class provides a means to read data from the associated handle. A |
| 58 // Reader object is bound to the thread on which |obtainReader| is called. | 62 // Reader object is bound to the thread on which |obtainReader| is called. |
| 59 // Any functions including the destructor should be called on the thread. | 63 // Any functions including the destructor should be called on the thread. |
| 60 // A reader can outlive the associated handle. In such a case, the handle | 64 // A reader can outlive the associated handle. In such a case, the handle |
| 61 // destruction will not affect the reader functionality. | 65 // destruction will not affect the reader functionality. |
| 62 // Reading functions may success (i.e. return Ok) or fail (otherwise), and | 66 // Reading functions may success (i.e. return Ok) or fail (otherwise), and |
| 63 // the behavior which is not specified is unspecified. | 67 // the behavior which is not specified is unspecified. |
| 64 class BLINK_PLATFORM_EXPORT Reader { | 68 class BLINK_PLATFORM_EXPORT Reader { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 // notification is called asynchronously. | 106 // notification is called asynchronously. |
| 103 virtual std::unique_ptr<Reader> obtainReader(Client*) = 0; | 107 virtual std::unique_ptr<Reader> obtainReader(Client*) = 0; |
| 104 | 108 |
| 105 // Returns a string literal (e.g. class name) for debugging only. | 109 // Returns a string literal (e.g. class name) for debugging only. |
| 106 virtual const char* debugName() const = 0; | 110 virtual const char* debugName() const = 0; |
| 107 }; | 111 }; |
| 108 | 112 |
| 109 } // namespace blink | 113 } // namespace blink |
| 110 | 114 |
| 111 #endif // WebDataConsumerHandle_h | 115 #endif // WebDataConsumerHandle_h |
| OLD | NEW |