OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 MOJO_EDK_SYSTEM_RAW_CHANNEL_H_ | 5 #ifndef MOJO_EDK_SYSTEM_RAW_CHANNEL_H_ |
6 #define MOJO_EDK_SYSTEM_RAW_CHANNEL_H_ | 6 #define MOJO_EDK_SYSTEM_RAW_CHANNEL_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 // the aforementioned thread). | 34 // the aforementioned thread). |
35 // | 35 // |
36 // OS-specific implementation subclasses are to be instantiated using the | 36 // OS-specific implementation subclasses are to be instantiated using the |
37 // |Create()| static factory method. | 37 // |Create()| static factory method. |
38 // | 38 // |
39 // With the exception of |WriteMessage()|, this class is thread-unsafe (and in | 39 // With the exception of |WriteMessage()|, this class is thread-unsafe (and in |
40 // general its methods should only be used on the I/O thread, i.e., the thread | 40 // general its methods should only be used on the I/O thread, i.e., the thread |
41 // on which |Init()| is called). | 41 // on which |Init()| is called). |
42 class MOJO_SYSTEM_IMPL_EXPORT RawChannel { | 42 class MOJO_SYSTEM_IMPL_EXPORT RawChannel { |
43 public: | 43 public: |
44 // This object may be destroyed on any thread (if |Init()| was called, after | |
45 // |Shutdown()| was called). | |
46 virtual ~RawChannel(); | |
47 | 44 |
48 // The |Delegate| is only accessed on the same thread as the message loop | 45 // The |Delegate| is only accessed on the same thread as the message loop |
49 // (passed in on creation). | 46 // (passed in on creation). |
50 class MOJO_SYSTEM_IMPL_EXPORT Delegate { | 47 class MOJO_SYSTEM_IMPL_EXPORT Delegate { |
51 public: | 48 public: |
52 enum Error { | 49 enum Error { |
53 // Failed read due to raw channel shutdown (e.g., on the other side). | 50 // Failed read due to raw channel shutdown (e.g., on the other side). |
54 ERROR_READ_SHUTDOWN, | 51 ERROR_READ_SHUTDOWN, |
55 // Failed read due to raw channel being broken (e.g., if the other side | 52 // Failed read due to raw channel being broken (e.g., if the other side |
56 // died without shutting down). | 53 // died without shutting down). |
(...skipping 20 matching lines...) Expand all Loading... |
77 // |OnReadMessage()| won't be called again. | 74 // |OnReadMessage()| won't be called again. |
78 virtual void OnError(Error error) = 0; | 75 virtual void OnError(Error error) = 0; |
79 | 76 |
80 protected: | 77 protected: |
81 virtual ~Delegate() {} | 78 virtual ~Delegate() {} |
82 }; | 79 }; |
83 | 80 |
84 // Static factory method. |handle| should be a handle to a | 81 // Static factory method. |handle| should be a handle to a |
85 // (platform-appropriate) bidirectional communication channel (e.g., a socket | 82 // (platform-appropriate) bidirectional communication channel (e.g., a socket |
86 // on POSIX, a named pipe on Windows). | 83 // on POSIX, a named pipe on Windows). |
87 static scoped_ptr<RawChannel> Create(embedder::ScopedPlatformHandle handle); | 84 static RawChannel* Create(embedder::ScopedPlatformHandle handle); |
| 85 |
| 86 // Returns the amount of space needed in the |MessageInTransit|'s |
| 87 // |TransportData|'s "platform handle table" per platform handle (to be |
| 88 // attached to a message). (This amount may be zero.) |
| 89 static size_t GetSerializedPlatformHandleSize(); |
88 | 90 |
89 // This must be called (on an I/O thread) before this object is used. Does | 91 // This must be called (on an I/O thread) before this object is used. Does |
90 // *not* take ownership of |delegate|. Both the I/O thread and |delegate| must | 92 // *not* take ownership of |delegate|. Both the I/O thread and |delegate| must |
91 // remain alive until |Shutdown()| is called (unless this fails); |delegate| | 93 // remain alive until |Shutdown()| is called (unless this fails); |delegate| |
92 // will no longer be used after |Shutdown()|. | 94 // will no longer be used after |Shutdown()|. |
93 void Init(Delegate* delegate); | 95 void Init(Delegate* delegate); |
94 | 96 |
95 // This must be called (on the I/O thread) before this object is destroyed. | 97 // This must be called (on the I/O thread) before this object is destroyed. |
96 void Shutdown(); | 98 void Shutdown(); |
97 | 99 |
| 100 // Returns the platform handle for the pipe synchronously. |
| 101 |
| 102 |
| 103 // Flushes all pending writes synchronously. |
| 104 |
| 105 |
| 106 // TODO(jam): change above to write it to shared memory and return handle as |
| 107 // writing synchronously won't work for lots of pending data. |
| 108 // Returns any partially read data. |
| 109 // NOTE: After calling this, consider the channel shutdown and don't call into |
| 110 // it anymore |
| 111 embedder::ScopedPlatformHandle ReleaseHandle( |
| 112 std::vector<char>* read_buffer); |
| 113 |
98 // Writes the given message (or schedules it to be written). |message| must | 114 // Writes the given message (or schedules it to be written). |message| must |
99 // have no |Dispatcher|s still attached (i.e., | 115 // have no |Dispatcher|s still attached (i.e., |
100 // |SerializeAndCloseDispatchers()| should have been called). This method is | 116 // |SerializeAndCloseDispatchers()| should have been called). This method is |
101 // thread-safe and may be called from any thread. Returns true on success. | 117 // thread-safe and may be called from any thread. Returns true on success. |
102 bool WriteMessage(scoped_ptr<MessageInTransit> message); | 118 bool WriteMessage(scoped_ptr<MessageInTransit> message); |
103 | 119 |
104 // Returns true if the write buffer is empty (i.e., all messages written using | 120 // Returns true if the write buffer is empty (i.e., all messages written using |
105 // |WriteMessage()| have actually been sent. | 121 // |WriteMessage()| have actually been sent. |
106 // TODO(vtl): We should really also notify our delegate when the write buffer | 122 // TODO(vtl): We should really also notify our delegate when the write buffer |
107 // becomes empty (or something like that). | 123 // becomes empty (or something like that). |
108 bool IsWriteBufferEmpty(); | 124 bool IsWriteBufferEmpty(); |
109 | 125 |
110 // Returns the amount of space needed in the |MessageInTransit|'s | 126 bool IsReadBufferEmpty(); |
111 // |TransportData|'s "platform handle table" per platform handle (to be | 127 |
112 // attached to a message). (This amount may be zero.) | 128 void SetInitialReadBufferData(char* data, size_t size); |
113 virtual size_t GetSerializedPlatformHandleSize() const = 0; | |
114 | 129 |
115 protected: | 130 protected: |
116 // Result of I/O operations. | 131 // Result of I/O operations. |
117 enum IOResult { | 132 enum IOResult { |
118 IO_SUCCEEDED, | 133 IO_SUCCEEDED, |
119 // Failed due to a (probably) clean shutdown (e.g., of the other end). | 134 // Failed due to a (probably) clean shutdown (e.g., of the other end). |
120 IO_FAILED_SHUTDOWN, | 135 IO_FAILED_SHUTDOWN, |
121 // Failed due to the connection being broken (e.g., the other end dying). | 136 // Failed due to the connection being broken (e.g., the other end dying). |
122 IO_FAILED_BROKEN, | 137 IO_FAILED_BROKEN, |
123 // Failed due to some other (unexpected) reason. | 138 // Failed due to some other (unexpected) reason. |
124 IO_FAILED_UNKNOWN, | 139 IO_FAILED_UNKNOWN, |
125 IO_PENDING | 140 IO_PENDING |
126 }; | 141 }; |
127 | 142 |
128 class MOJO_SYSTEM_IMPL_EXPORT ReadBuffer { | 143 class MOJO_SYSTEM_IMPL_EXPORT ReadBuffer { |
129 public: | 144 public: |
130 ReadBuffer(); | 145 ReadBuffer(); |
131 ~ReadBuffer(); | 146 ~ReadBuffer(); |
132 | 147 |
133 void GetBuffer(char** addr, size_t* size); | 148 void GetBuffer(char** addr, size_t* size); |
134 | 149 |
| 150 void Reset() {num_valid_bytes_ = 0; } |
| 151 |
| 152 // temp for debugging |
| 153 // TODO(jam): pass in a cleaner way to ReleaseHandle, just like shutdown |
| 154 // case. |
| 155 char* buffer() { return &buffer_[0]; } |
| 156 size_t num_valid_bytes() {return num_valid_bytes_;} |
| 157 |
135 private: | 158 private: |
136 friend class RawChannel; | 159 friend class RawChannel; |
137 | 160 |
138 // We store data from |[Schedule]Read()|s in |buffer_|. The start of | 161 // We store data from |[Schedule]Read()|s in |buffer_|. The start of |
139 // |buffer_| is always aligned with a message boundary (we will copy memory | 162 // |buffer_| is always aligned with a message boundary (we will copy memory |
140 // to ensure this), but |buffer_| may be larger than the actual number of | 163 // to ensure this), but |buffer_| may be larger than the actual number of |
141 // bytes we have. | 164 // bytes we have. |
142 std::vector<char> buffer_; | 165 std::vector<char> buffer_; |
143 size_t num_valid_bytes_; | 166 size_t num_valid_bytes_; |
144 | 167 |
145 MOJO_DISALLOW_COPY_AND_ASSIGN(ReadBuffer); | 168 MOJO_DISALLOW_COPY_AND_ASSIGN(ReadBuffer); |
146 }; | 169 }; |
147 | 170 |
148 class MOJO_SYSTEM_IMPL_EXPORT WriteBuffer { | 171 class MOJO_SYSTEM_IMPL_EXPORT WriteBuffer { |
149 public: | 172 public: |
150 struct Buffer { | 173 struct Buffer { |
151 const char* addr; | 174 const char* addr; |
152 size_t size; | 175 size_t size; |
153 }; | 176 }; |
154 | 177 |
155 explicit WriteBuffer(size_t serialized_platform_handle_size); | 178 WriteBuffer(); |
156 ~WriteBuffer(); | 179 ~WriteBuffer(); |
157 | 180 |
158 // Returns true if there are (more) platform handles to be sent (from the | 181 // Returns true if there are (more) platform handles to be sent (from the |
159 // front of |message_queue_|). | 182 // front of |message_queue_|). |
160 bool HavePlatformHandlesToSend() const; | 183 bool HavePlatformHandlesToSend() const; |
161 // Gets platform handles to be sent (from the front of |message_queue_|). | 184 // Gets platform handles to be sent (from the front of |message_queue_|). |
162 // This should only be called if |HavePlatformHandlesToSend()| returned | 185 // This should only be called if |HavePlatformHandlesToSend()| returned |
163 // true. There are two components to this: the actual |PlatformHandle|s | 186 // true. There are two components to this: the actual |PlatformHandle|s |
164 // (which should be closed once sent) and any additional serialization | 187 // (which should be closed once sent) and any additional serialization |
165 // information (which will be embedded in the message's data; there are | 188 // information (which will be embedded in the message's data; there are |
166 // |GetSerializedPlatformHandleSize()| bytes per handle). Once all platform | 189 // |GetSerializedPlatformHandleSize()| bytes per handle). Once all platform |
167 // handles have been sent, the message data should be written next (see | 190 // handles have been sent, the message data should be written next (see |
168 // |GetBuffers()|). | 191 // |GetBuffers()|). |
169 // TODO(vtl): Maybe this method should be const, but | 192 // TODO(vtl): Maybe this method should be const, but |
170 // |PlatformHandle::CloseIfNecessary()| isn't const (and actually modifies | 193 // |PlatformHandle::CloseIfNecessary()| isn't const (and actually modifies |
171 // state). | 194 // state). |
172 void GetPlatformHandlesToSend(size_t* num_platform_handles, | 195 void GetPlatformHandlesToSend(size_t* num_platform_handles, |
173 embedder::PlatformHandle** platform_handles, | 196 embedder::PlatformHandle** platform_handles, |
174 void** serialization_data); | 197 void** serialization_data); |
175 | 198 |
176 // Gets buffers to be written. These buffers will always come from the front | 199 // Gets buffers to be written. These buffers will always come from the front |
177 // of |message_queue_|. Once they are completely written, the front | 200 // of |message_queue_|. Once they are completely written, the front |
178 // |MessageInTransit| should be popped (and destroyed); this is done in | 201 // |MessageInTransit| should be popped (and destroyed); this is done in |
179 // |OnWriteCompletedNoLock()|. | 202 // |OnWriteCompletedNoLock()|. |
180 void GetBuffers(std::vector<Buffer>* buffers) const; | 203 void GetBuffers(std::vector<Buffer>* buffers) const; |
181 | 204 |
182 private: | 205 |
| 206 |
| 207 |
| 208 |
| 209 // temp for testing |
| 210 size_t queue_size() {return message_queue_.Size();} |
| 211 |
| 212 // TODO(jam): better way of giving buffer on release handle |
| 213 MessageInTransitQueue* message_queue() { return &message_queue_; } |
| 214 |
| 215 |
| 216 |
| 217 // TODO JAM REMOVE AND ADD METHODS |
| 218 // private: |
183 friend class RawChannel; | 219 friend class RawChannel; |
184 | 220 |
185 const size_t serialized_platform_handle_size_; | 221 size_t serialized_platform_handle_size_; |
186 | 222 |
187 MessageInTransitQueue message_queue_; | 223 MessageInTransitQueue message_queue_; |
188 // Platform handles are sent before the message data, but doing so may | 224 // Platform handles are sent before the message data, but doing so may |
189 // require several passes. |platform_handles_offset_| indicates the position | 225 // require several passes. |platform_handles_offset_| indicates the position |
190 // in the first message's vector of platform handles to send next. | 226 // in the first message's vector of platform handles to send next. |
191 size_t platform_handles_offset_; | 227 size_t platform_handles_offset_; |
192 // The first message's data may have been partially sent. |data_offset_| | 228 // The first message's data may have been partially sent. |data_offset_| |
193 // indicates the position in the first message's data to start the next | 229 // indicates the position in the first message's data to start the next |
194 // write. | 230 // write. |
195 size_t data_offset_; | 231 size_t data_offset_; |
196 | 232 |
197 MOJO_DISALLOW_COPY_AND_ASSIGN(WriteBuffer); | 233 MOJO_DISALLOW_COPY_AND_ASSIGN(WriteBuffer); |
198 }; | 234 }; |
199 | 235 |
200 RawChannel(); | 236 RawChannel(); |
201 | 237 |
| 238 // Shutdown must be called on the IO thread. This object deletes itself once |
| 239 // it's flushed all pending writes and insured that the other side of the pipe |
| 240 // read them. |
| 241 virtual ~RawChannel(); |
| 242 |
202 // |result| must not be |IO_PENDING|. Must be called on the I/O thread WITHOUT | 243 // |result| must not be |IO_PENDING|. Must be called on the I/O thread WITHOUT |
203 // |write_lock_| held. This object may be destroyed by this call. | 244 // |write_lock_| held. This object may be destroyed by this call. |
204 void OnReadCompleted(IOResult io_result, size_t bytes_read); | 245 void OnReadCompleted(IOResult io_result, size_t bytes_read); |
205 // |result| must not be |IO_PENDING|. Must be called on the I/O thread WITHOUT | 246 // |result| must not be |IO_PENDING|. Must be called on the I/O thread WITHOUT |
206 // |write_lock_| held. This object may be destroyed by this call. | 247 // |write_lock_| held. This object may be destroyed by this call. |
207 void OnWriteCompleted(IOResult io_result, | 248 void OnWriteCompleted(IOResult io_result, |
208 size_t platform_handles_written, | 249 size_t platform_handles_written, |
209 size_t bytes_written); | 250 size_t bytes_written); |
210 | 251 |
211 base::MessageLoopForIO* message_loop_for_io() { return message_loop_for_io_; } | 252 base::MessageLoopForIO* message_loop_for_io() { return message_loop_for_io_; } |
212 base::Lock& write_lock() { return write_lock_; } | 253 base::Lock& write_lock() { return write_lock_; } |
| 254 base::Lock& read_lock() { return read_lock_; } |
213 | 255 |
214 // Should only be called on the I/O thread. | 256 // Should only be called on the I/O thread. |
215 ReadBuffer* read_buffer() { return read_buffer_.get(); } | 257 ReadBuffer* read_buffer() { return read_buffer_.get(); } |
216 | 258 |
217 // Only called under |write_lock_|. | 259 // Only called under |write_lock_|. |
218 WriteBuffer* write_buffer_no_lock() { | 260 WriteBuffer* write_buffer_no_lock() { |
219 write_lock_.AssertAcquired(); | 261 write_lock_.AssertAcquired(); |
220 return write_buffer_.get(); | 262 return write_buffer_.get(); |
221 } | 263 } |
222 | 264 |
223 // Adds |message| to the write message queue. Implementation subclasses may | 265 // Adds |message| to the write message queue. Implementation subclasses may |
224 // override this to add any additional "control" messages needed. This is | 266 // override this to add any additional "control" messages needed. This is |
225 // called (on any thread) with |write_lock_| held. | 267 // called (on any thread) with |write_lock_| held. |
226 virtual void EnqueueMessageNoLock(scoped_ptr<MessageInTransit> message); | 268 virtual void EnqueueMessageNoLock(scoped_ptr<MessageInTransit> message); |
227 | 269 |
228 // Handles any control messages targeted to the |RawChannel| (or | 270 // Handles any control messages targeted to the |RawChannel| (or |
229 // implementation subclass). Implementation subclasses may override this to | 271 // implementation subclass). Implementation subclasses may override this to |
230 // handle any implementation-specific control messages, but should call | 272 // handle any implementation-specific control messages, but should call |
231 // |RawChannel::OnReadMessageForRawChannel()| for any remaining messages. | 273 // |RawChannel::OnReadMessageForRawChannel()| for any remaining messages. |
232 // Returns true on success and false on error (e.g., invalid control message). | 274 // Returns true on success and false on error (e.g., invalid control message). |
233 // This is only called on the I/O thread. | 275 // This is only called on the I/O thread. |
234 virtual bool OnReadMessageForRawChannel( | 276 virtual bool OnReadMessageForRawChannel( |
235 const MessageInTransit::View& message_view); | 277 const MessageInTransit::View& message_view); |
| 278 |
| 279 virtual embedder::PlatformHandle HandleForDebuggingNoLock() = 0; |
| 280 |
| 281 // Implementation must write any pending messages synchronously. |
| 282 // TODO(jam): change to return shared memory with pending serialized msgs. |
| 283 virtual embedder::ScopedPlatformHandle ReleaseHandleNoLock( |
| 284 std::vector<char>* read_buffer) = 0; |
236 | 285 |
237 // Reads into |read_buffer()|. | 286 // Reads into |read_buffer()|. |
238 // This class guarantees that: | 287 // This class guarantees that: |
239 // - the area indicated by |GetBuffer()| will stay valid until read completion | 288 // - the area indicated by |GetBuffer()| will stay valid until read completion |
240 // (but please also see the comments for |OnShutdownNoLock()|); | 289 // (but please also see the comments for |OnShutdownNoLock()|); |
241 // - a second read is not started if there is a pending read; | 290 // - a second read is not started if there is a pending read; |
242 // - the method is called on the I/O thread WITHOUT |write_lock_| held. | 291 // - the method is called on the I/O thread WITHOUT |write_lock_| held. |
243 // | 292 // |
244 // The implementing subclass must guarantee that: | 293 // The implementing subclass must guarantee that: |
245 // - |bytes_read| is untouched unless |Read()| returns |IO_SUCCEEDED|; | 294 // - |bytes_read| is untouched unless |Read()| returns |IO_SUCCEEDED|; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 | 331 |
283 // Must be called on the I/O thread WITHOUT |write_lock_| held. | 332 // Must be called on the I/O thread WITHOUT |write_lock_| held. |
284 virtual void OnInit() = 0; | 333 virtual void OnInit() = 0; |
285 // On shutdown, passes the ownership of the buffers to subclasses, which may | 334 // On shutdown, passes the ownership of the buffers to subclasses, which may |
286 // want to preserve them if there are pending read/writes. After this is | 335 // want to preserve them if there are pending read/writes. After this is |
287 // called, |OnReadCompleted()| must no longer be called. Must be called on the | 336 // called, |OnReadCompleted()| must no longer be called. Must be called on the |
288 // I/O thread under |write_lock_|. | 337 // I/O thread under |write_lock_|. |
289 virtual void OnShutdownNoLock(scoped_ptr<ReadBuffer> read_buffer, | 338 virtual void OnShutdownNoLock(scoped_ptr<ReadBuffer> read_buffer, |
290 scoped_ptr<WriteBuffer> write_buffer) = 0; | 339 scoped_ptr<WriteBuffer> write_buffer) = 0; |
291 | 340 |
| 341 void SendQueuedMessagesNoLock(); |
| 342 |
292 private: | 343 private: |
| 344 friend class base::DeleteHelper<RawChannel>; |
| 345 |
293 // Converts an |IO_FAILED_...| for a read to a |Delegate::Error|. | 346 // Converts an |IO_FAILED_...| for a read to a |Delegate::Error|. |
294 static Delegate::Error ReadIOResultToError(IOResult io_result); | 347 static Delegate::Error ReadIOResultToError(IOResult io_result); |
295 | 348 |
296 // Calls |delegate_->OnError(error)|. Must be called on the I/O thread WITHOUT | 349 // Calls |delegate_->OnError(error)|. Must be called on the I/O thread WITHOUT |
297 // |write_lock_| held. This object may be destroyed by this call. | 350 // |write_lock_| held. This object may be destroyed by this call. |
298 void CallOnError(Delegate::Error error); | 351 void CallOnError(Delegate::Error error); |
299 | 352 |
| 353 void LockAndCallOnError(Delegate::Error error); |
| 354 |
300 // If |io_result| is |IO_SUCCESS|, updates the write buffer and schedules a | 355 // If |io_result| is |IO_SUCCESS|, updates the write buffer and schedules a |
301 // write operation to run later if there is more to write. If |io_result| is | 356 // write operation to run later if there is more to write. If |io_result| is |
302 // failure or any other error occurs, cancels pending writes and returns | 357 // failure or any other error occurs, cancels pending writes and returns |
303 // false. Must be called under |write_lock_| and only if |write_stopped_| is | 358 // false. Must be called under |write_lock_| and only if |write_stopped_| is |
304 // false. | 359 // false. |
305 bool OnWriteCompletedNoLock(IOResult io_result, | 360 bool OnWriteCompletedNoLock(IOResult io_result, |
306 size_t platform_handles_written, | 361 size_t platform_handles_written, |
307 size_t bytes_written); | 362 size_t bytes_written); |
308 | 363 |
| 364 // Helper method to dispatch messages from the read buffer. |
| 365 // |did_dispatch_message| is true iff it dispatched any messages. |
| 366 // |stop_dispatching| is set to true if the code calling this should stop |
| 367 // dispatching, either because we hit an erorr or the delegate shutdown the |
| 368 // channel. |
| 369 void DispatchMessages(bool* did_dispatch_message, bool* stop_dispatching); |
| 370 |
309 // Set in |Init()| and never changed (hence usable on any thread without | 371 // Set in |Init()| and never changed (hence usable on any thread without |
310 // locking): | 372 // locking): |
311 base::MessageLoopForIO* message_loop_for_io_; | 373 base::MessageLoopForIO* message_loop_for_io_; |
312 | 374 |
| 375 |
| 376 |
| 377 |
| 378 |
| 379 // TODO(jam): one lock only.... |
| 380 |
| 381 |
| 382 |
| 383 |
313 // Only used on the I/O thread: | 384 // Only used on the I/O thread: |
| 385 |
| 386 bool* set_on_shutdown_; |
| 387 |
| 388 base::Lock read_lock_; // Protects read_buffer_. |
| 389 // This is usually only accessed on IO thread, except when ReleaseHandle is |
| 390 // called. |
| 391 scoped_ptr<ReadBuffer> read_buffer_; |
| 392 // ditto: usually used on io thread except ReleaseHandle |
314 Delegate* delegate_; | 393 Delegate* delegate_; |
315 bool* set_on_shutdown_; | 394 |
316 scoped_ptr<ReadBuffer> read_buffer_; | 395 // If grabbing both locks, grab read first. |
317 | 396 |
318 base::Lock write_lock_; // Protects the following members. | 397 base::Lock write_lock_; // Protects the following members. |
| 398 bool write_ready_; |
319 bool write_stopped_; | 399 bool write_stopped_; |
320 scoped_ptr<WriteBuffer> write_buffer_; | 400 scoped_ptr<WriteBuffer> write_buffer_; |
321 | 401 |
| 402 bool error_occurred_; |
| 403 |
322 // This is used for posting tasks from write threads to the I/O thread. It | 404 // This is used for posting tasks from write threads to the I/O thread. It |
323 // must only be accessed under |write_lock_|. The weak pointers it produces | 405 // must only be accessed under |write_lock_|. The weak pointers it produces |
324 // are only used/invalidated on the I/O thread. | 406 // are only used/invalidated on the I/O thread. |
325 base::WeakPtrFactory<RawChannel> weak_ptr_factory_; | 407 base::WeakPtrFactory<RawChannel> weak_ptr_factory_; |
326 | 408 |
327 MOJO_DISALLOW_COPY_AND_ASSIGN(RawChannel); | 409 MOJO_DISALLOW_COPY_AND_ASSIGN(RawChannel); |
328 }; | 410 }; |
329 | 411 |
330 } // namespace system | 412 } // namespace system |
331 } // namespace mojo | 413 } // namespace mojo |
332 | 414 |
333 #endif // MOJO_EDK_SYSTEM_RAW_CHANNEL_H_ | 415 #endif // MOJO_EDK_SYSTEM_RAW_CHANNEL_H_ |
OLD | NEW |