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 | 9 |
10 #if INSIDE_BLINK | 10 #if INSIDE_BLINK |
11 #include "wtf/PassOwnPtr.h" | 11 #include "wtf/PassOwnPtr.h" |
12 #endif | 12 #endif |
13 | 13 |
14 #include "public/platform/WebCommon.h" | 14 #include "public/platform/WebCommon.h" |
15 | 15 |
16 namespace blink { | 16 namespace blink { |
17 | 17 |
18 // WebDataConsumerHandle represents the "consumer" side of a data pipe. A user | 18 // WebDataConsumerHandle represents the "consumer" side of a data pipe. A user |
19 // can read data from it. | 19 // can read data from it. |
20 // | 20 // |
21 // A WebDataConsumerHandle is a thread-safe object. A user can call | 21 // A WebDataConsumerHandle is a thread-safe object. A user can call |
22 // |obtainReader| or destruct the object on any thread. | 22 // |obtainReader| or destruct the object on any thread. |
23 // A WebDataConsumerHandle having a reader is called "locked". A | 23 // A WebDataConsumerHandle having a reader is called "locked". A |
24 // WebDataConsumerHandle or its reader are called "waiting" when reading from | 24 // WebDataConsumerHandle or its reader are called "waiting" when reading from |
25 // the handle or reader returns ShouldWait. | 25 // the handle or reader returns ShouldWait. |
| 26 // |
| 27 // WebDataConsumerHandle can be created / used / destructed only on |
| 28 // Oilpan-enabled threads. |
| 29 // TODO(yhirano): Remove this restriction. |
26 class BLINK_PLATFORM_EXPORT WebDataConsumerHandle { | 30 class BLINK_PLATFORM_EXPORT WebDataConsumerHandle { |
27 public: | 31 public: |
28 using Flags = unsigned; | 32 using Flags = unsigned; |
29 static const Flags FlagNone = 0; | 33 static const Flags FlagNone = 0; |
30 | 34 |
31 enum Result { | 35 enum Result { |
32 Ok, | 36 Ok, |
33 Done, | 37 Done, |
34 Busy, | 38 Busy, |
35 ShouldWait, | 39 ShouldWait, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 | 97 |
94 // Ends a two-phase read. | 98 // Ends a two-phase read. |
95 // |readSize| indicates the actual read size. | 99 // |readSize| indicates the actual read size. |
96 virtual Result endRead(size_t readSize) | 100 virtual Result endRead(size_t readSize) |
97 { | 101 { |
98 BLINK_ASSERT_NOT_REACHED(); | 102 BLINK_ASSERT_NOT_REACHED(); |
99 return UnexpectedError; | 103 return UnexpectedError; |
100 } | 104 } |
101 }; | 105 }; |
102 | 106 |
103 virtual ~WebDataConsumerHandle() { } | 107 WebDataConsumerHandle(); |
| 108 virtual ~WebDataConsumerHandle(); |
104 | 109 |
105 // Returns a non-null reader. This function can be called only when this | 110 // Returns a non-null reader. This function can be called only when this |
106 // handle is not locked. |client| can be null. Otherwise, |*client| must be | 111 // handle is not locked. |client| can be null. Otherwise, |*client| must be |
107 // valid as long as the reader is valid. The returned reader is bound to | 112 // valid as long as the reader is valid. The returned reader is bound to |
108 // the calling thread and client notification will be called on the thread | 113 // the calling thread and client notification will be called on the thread |
109 // if |client| is not null. | 114 // if |client| is not null. |
110 // If |client| is not null and the handle is not waiting, client | 115 // If |client| is not null and the handle is not waiting, client |
111 // notification is called asynchronously. | 116 // notification is called asynchronously. |
112 #if INSIDE_BLINK | 117 #if INSIDE_BLINK |
113 PassOwnPtr<Reader> obtainReader(Client* client) { return adoptPtr(obtainRead
erInternal(client)); } | 118 PassOwnPtr<Reader> obtainReader(Client*); |
114 #endif | 119 #endif |
115 | 120 |
116 // Returns a string literal (e.g. class name) for debugging only. | 121 // Returns a string literal (e.g. class name) for debugging only. |
117 virtual const char* debugName() const { return "WebDataConsumerHandle"; } | 122 virtual const char* debugName() const { return "WebDataConsumerHandle"; } |
118 | 123 |
119 private: | 124 private: |
120 // The caller takes ownership of the returned object. | 125 // The caller takes ownership of the returned object. |
121 virtual Reader* obtainReaderInternal(Client* client) | 126 virtual Reader* obtainReaderInternal(Client* client) |
122 { | 127 { |
123 BLINK_ASSERT_NOT_REACHED(); | 128 BLINK_ASSERT_NOT_REACHED(); |
124 return nullptr; | 129 return nullptr; |
125 } | 130 } |
126 }; | 131 }; |
127 | 132 |
128 } // namespace blink | 133 } // namespace blink |
129 | 134 |
130 #endif // WebDataConsumerHandle_h | 135 #endif // WebDataConsumerHandle_h |
OLD | NEW |