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; | 129 |
130 void set_debug_started_sending() { debug_started_sending_ = true; } | |
131 bool debug_started_sending() { return debug_started_sending_; } | |
132 | |
133 virtual embedder::PlatformHandle HandleForDebuggingNoLock() = 0; | |
114 | 134 |
115 protected: | 135 protected: |
116 // Result of I/O operations. | 136 // Result of I/O operations. |
117 enum IOResult { | 137 enum IOResult { |
118 IO_SUCCEEDED, | 138 IO_SUCCEEDED, |
119 // Failed due to a (probably) clean shutdown (e.g., of the other end). | 139 // Failed due to a (probably) clean shutdown (e.g., of the other end). |
120 IO_FAILED_SHUTDOWN, | 140 IO_FAILED_SHUTDOWN, |
121 // Failed due to the connection being broken (e.g., the other end dying). | 141 // Failed due to the connection being broken (e.g., the other end dying). |
122 IO_FAILED_BROKEN, | 142 IO_FAILED_BROKEN, |
123 // Failed due to some other (unexpected) reason. | 143 // Failed due to some other (unexpected) reason. |
124 IO_FAILED_UNKNOWN, | 144 IO_FAILED_UNKNOWN, |
125 IO_PENDING | 145 IO_PENDING |
126 }; | 146 }; |
127 | 147 |
128 class MOJO_SYSTEM_IMPL_EXPORT ReadBuffer { | 148 class MOJO_SYSTEM_IMPL_EXPORT ReadBuffer { |
129 public: | 149 public: |
130 ReadBuffer(); | 150 ReadBuffer(); |
131 ~ReadBuffer(); | 151 ~ReadBuffer(); |
132 | 152 |
133 void GetBuffer(char** addr, size_t* size); | 153 void GetBuffer(char** addr, size_t* size); |
134 | 154 |
155 void Reset() {num_valid_bytes_ = 0; } | |
156 | |
157 // temp for debugging | |
158 // TODO(jam): pass in a cleaner way to ReleaseHandle, just like shutdown | |
159 // case. | |
160 char* buffer() { return &buffer_[0]; } | |
161 size_t num_valid_bytes() {return num_valid_bytes_;} | |
162 | |
135 private: | 163 private: |
136 friend class RawChannel; | 164 friend class RawChannel; |
137 | 165 |
138 // We store data from |[Schedule]Read()|s in |buffer_|. The start of | 166 // 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 | 167 // |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 | 168 // to ensure this), but |buffer_| may be larger than the actual number of |
141 // bytes we have. | 169 // bytes we have. |
142 std::vector<char> buffer_; | 170 std::vector<char> buffer_; |
143 size_t num_valid_bytes_; | 171 size_t num_valid_bytes_; |
144 | 172 |
145 MOJO_DISALLOW_COPY_AND_ASSIGN(ReadBuffer); | 173 MOJO_DISALLOW_COPY_AND_ASSIGN(ReadBuffer); |
146 }; | 174 }; |
147 | 175 |
148 class MOJO_SYSTEM_IMPL_EXPORT WriteBuffer { | 176 class MOJO_SYSTEM_IMPL_EXPORT WriteBuffer { |
149 public: | 177 public: |
150 struct Buffer { | 178 struct Buffer { |
151 const char* addr; | 179 const char* addr; |
152 size_t size; | 180 size_t size; |
153 }; | 181 }; |
154 | 182 |
155 explicit WriteBuffer(size_t serialized_platform_handle_size); | 183 WriteBuffer(); |
156 ~WriteBuffer(); | 184 ~WriteBuffer(); |
157 | 185 |
158 // Returns true if there are (more) platform handles to be sent (from the | 186 // Returns true if there are (more) platform handles to be sent (from the |
159 // front of |message_queue_|). | 187 // front of |message_queue_|). |
160 bool HavePlatformHandlesToSend() const; | 188 bool HavePlatformHandlesToSend() const; |
161 // Gets platform handles to be sent (from the front of |message_queue_|). | 189 // Gets platform handles to be sent (from the front of |message_queue_|). |
162 // This should only be called if |HavePlatformHandlesToSend()| returned | 190 // This should only be called if |HavePlatformHandlesToSend()| returned |
163 // true. There are two components to this: the actual |PlatformHandle|s | 191 // true. There are two components to this: the actual |PlatformHandle|s |
164 // (which should be closed once sent) and any additional serialization | 192 // (which should be closed once sent) and any additional serialization |
165 // information (which will be embedded in the message's data; there are | 193 // information (which will be embedded in the message's data; there are |
166 // |GetSerializedPlatformHandleSize()| bytes per handle). Once all platform | 194 // |GetSerializedPlatformHandleSize()| bytes per handle). Once all platform |
167 // handles have been sent, the message data should be written next (see | 195 // handles have been sent, the message data should be written next (see |
168 // |GetBuffers()|). | 196 // |GetBuffers()|). |
169 // TODO(vtl): Maybe this method should be const, but | 197 // TODO(vtl): Maybe this method should be const, but |
170 // |PlatformHandle::CloseIfNecessary()| isn't const (and actually modifies | 198 // |PlatformHandle::CloseIfNecessary()| isn't const (and actually modifies |
171 // state). | 199 // state). |
172 void GetPlatformHandlesToSend(size_t* num_platform_handles, | 200 void GetPlatformHandlesToSend(size_t* num_platform_handles, |
173 embedder::PlatformHandle** platform_handles, | 201 embedder::PlatformHandle** platform_handles, |
174 void** serialization_data); | 202 void** serialization_data); |
175 | 203 |
176 // Gets buffers to be written. These buffers will always come from the front | 204 // Gets buffers to be written. These buffers will always come from the front |
177 // of |message_queue_|. Once they are completely written, the front | 205 // of |message_queue_|. Once they are completely written, the front |
178 // |MessageInTransit| should be popped (and destroyed); this is done in | 206 // |MessageInTransit| should be popped (and destroyed); this is done in |
179 // |OnWriteCompletedNoLock()|. | 207 // |OnWriteCompletedNoLock()|. |
180 void GetBuffers(std::vector<Buffer>* buffers) const; | 208 void GetBuffers(std::vector<Buffer>* buffers) const; |
181 | 209 |
182 private: | 210 |
211 | |
212 | |
213 | |
214 // temp for testing | |
215 size_t queue_size() {return message_queue_.Size();} | |
216 | |
217 // TODO(jam): better way of giving buffer on release handle | |
218 MessageInTransitQueue* message_queue() { return &message_queue_; } | |
219 | |
220 | |
221 | |
222 // TODO JAM REMOVE AND ADD METHODS | |
223 // private: | |
183 friend class RawChannel; | 224 friend class RawChannel; |
184 | 225 |
185 const size_t serialized_platform_handle_size_; | 226 size_t serialized_platform_handle_size_; |
186 | 227 |
187 MessageInTransitQueue message_queue_; | 228 MessageInTransitQueue message_queue_; |
188 // Platform handles are sent before the message data, but doing so may | 229 // Platform handles are sent before the message data, but doing so may |
189 // require several passes. |platform_handles_offset_| indicates the position | 230 // require several passes. |platform_handles_offset_| indicates the position |
190 // in the first message's vector of platform handles to send next. | 231 // in the first message's vector of platform handles to send next. |
191 size_t platform_handles_offset_; | 232 size_t platform_handles_offset_; |
192 // The first message's data may have been partially sent. |data_offset_| | 233 // 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 | 234 // indicates the position in the first message's data to start the next |
194 // write. | 235 // write. |
195 size_t data_offset_; | 236 size_t data_offset_; |
196 | 237 |
197 MOJO_DISALLOW_COPY_AND_ASSIGN(WriteBuffer); | 238 MOJO_DISALLOW_COPY_AND_ASSIGN(WriteBuffer); |
198 }; | 239 }; |
199 | 240 |
200 RawChannel(); | 241 RawChannel(); |
201 | 242 |
243 // Shutdown must be called on the IO thread. This object deletes itself once | |
244 // it's flushed all pending writes and insured that the other side of the pipe | |
245 // read them. | |
246 virtual ~RawChannel(); | |
247 | |
202 // |result| must not be |IO_PENDING|. Must be called on the I/O thread WITHOUT | 248 // |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. | 249 // |write_lock_| held. This object may be destroyed by this call. |
204 void OnReadCompleted(IOResult io_result, size_t bytes_read); | 250 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 | 251 // |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. | 252 // |write_lock_| held. This object may be destroyed by this call. |
207 void OnWriteCompleted(IOResult io_result, | 253 void OnWriteCompleted(IOResult io_result, |
208 size_t platform_handles_written, | 254 size_t platform_handles_written, |
209 size_t bytes_written); | 255 size_t bytes_written); |
210 | 256 |
211 base::MessageLoopForIO* message_loop_for_io() { return message_loop_for_io_; } | 257 base::MessageLoopForIO* message_loop_for_io() { return message_loop_for_io_; } |
212 base::Lock& write_lock() { return write_lock_; } | 258 base::Lock& write_lock() { return write_lock_; } |
259 base::Lock& read_lock() { return read_lock_; } | |
213 | 260 |
214 // Should only be called on the I/O thread. | 261 // Should only be called on the I/O thread. |
yzshen1
2015/09/23 22:47:09
Now that ReleaseHandle could be called on non-IO t
| |
215 ReadBuffer* read_buffer() { return read_buffer_.get(); } | 262 ReadBuffer* read_buffer() { return read_buffer_.get(); } |
216 | 263 |
217 // Only called under |write_lock_|. | 264 // Only called under |write_lock_|. |
218 WriteBuffer* write_buffer_no_lock() { | 265 WriteBuffer* write_buffer_no_lock() { |
219 write_lock_.AssertAcquired(); | 266 write_lock_.AssertAcquired(); |
220 return write_buffer_.get(); | 267 return write_buffer_.get(); |
221 } | 268 } |
222 | 269 |
223 // Adds |message| to the write message queue. Implementation subclasses may | 270 // Adds |message| to the write message queue. Implementation subclasses may |
224 // override this to add any additional "control" messages needed. This is | 271 // override this to add any additional "control" messages needed. This is |
225 // called (on any thread) with |write_lock_| held. | 272 // called (on any thread) with |write_lock_| held. |
226 virtual void EnqueueMessageNoLock(scoped_ptr<MessageInTransit> message); | 273 virtual void EnqueueMessageNoLock(scoped_ptr<MessageInTransit> message); |
227 | 274 |
228 // Handles any control messages targeted to the |RawChannel| (or | 275 // Handles any control messages targeted to the |RawChannel| (or |
229 // implementation subclass). Implementation subclasses may override this to | 276 // implementation subclass). Implementation subclasses may override this to |
230 // handle any implementation-specific control messages, but should call | 277 // handle any implementation-specific control messages, but should call |
231 // |RawChannel::OnReadMessageForRawChannel()| for any remaining messages. | 278 // |RawChannel::OnReadMessageForRawChannel()| for any remaining messages. |
232 // Returns true on success and false on error (e.g., invalid control message). | 279 // Returns true on success and false on error (e.g., invalid control message). |
233 // This is only called on the I/O thread. | 280 // This is only called on the I/O thread. |
234 virtual bool OnReadMessageForRawChannel( | 281 virtual bool OnReadMessageForRawChannel( |
235 const MessageInTransit::View& message_view); | 282 const MessageInTransit::View& message_view); |
236 | 283 |
284 | |
285 // Implementation must write any pending messages synchronously. | |
286 // TODO(jam): change to return shared memory with pending serialized msgs. | |
287 virtual embedder::ScopedPlatformHandle ReleaseHandleNoLock( | |
288 std::vector<char>* read_buffer) = 0; | |
289 | |
237 // Reads into |read_buffer()|. | 290 // Reads into |read_buffer()|. |
238 // This class guarantees that: | 291 // This class guarantees that: |
239 // - the area indicated by |GetBuffer()| will stay valid until read completion | 292 // - the area indicated by |GetBuffer()| will stay valid until read completion |
240 // (but please also see the comments for |OnShutdownNoLock()|); | 293 // (but please also see the comments for |OnShutdownNoLock()|); |
241 // - a second read is not started if there is a pending read; | 294 // - 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. | 295 // - the method is called on the I/O thread WITHOUT |write_lock_| held. |
243 // | 296 // |
244 // The implementing subclass must guarantee that: | 297 // The implementing subclass must guarantee that: |
245 // - |bytes_read| is untouched unless |Read()| returns |IO_SUCCEEDED|; | 298 // - |bytes_read| is untouched unless |Read()| returns |IO_SUCCEEDED|; |
246 // - if the method returns |IO_PENDING|, |OnReadCompleted()| will be called on | 299 // - if the method returns |IO_PENDING|, |OnReadCompleted()| will be called on |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
282 | 335 |
283 // Must be called on the I/O thread WITHOUT |write_lock_| held. | 336 // Must be called on the I/O thread WITHOUT |write_lock_| held. |
284 virtual void OnInit() = 0; | 337 virtual void OnInit() = 0; |
285 // On shutdown, passes the ownership of the buffers to subclasses, which may | 338 // 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 | 339 // 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 | 340 // called, |OnReadCompleted()| must no longer be called. Must be called on the |
288 // I/O thread under |write_lock_|. | 341 // I/O thread under |write_lock_|. |
289 virtual void OnShutdownNoLock(scoped_ptr<ReadBuffer> read_buffer, | 342 virtual void OnShutdownNoLock(scoped_ptr<ReadBuffer> read_buffer, |
290 scoped_ptr<WriteBuffer> write_buffer) = 0; | 343 scoped_ptr<WriteBuffer> write_buffer) = 0; |
291 | 344 |
345 void SendQueuedMessagesNoLock(); | |
346 | |
292 private: | 347 private: |
348 friend class base::DeleteHelper<RawChannel>; | |
349 | |
293 // Converts an |IO_FAILED_...| for a read to a |Delegate::Error|. | 350 // Converts an |IO_FAILED_...| for a read to a |Delegate::Error|. |
294 static Delegate::Error ReadIOResultToError(IOResult io_result); | 351 static Delegate::Error ReadIOResultToError(IOResult io_result); |
295 | 352 |
296 // Calls |delegate_->OnError(error)|. Must be called on the I/O thread WITHOUT | 353 // 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. | 354 // |write_lock_| held. This object may be destroyed by this call. |
298 void CallOnError(Delegate::Error error); | 355 void CallOnError(Delegate::Error error); |
299 | 356 |
357 void LockAndCallOnError(Delegate::Error error); | |
358 | |
300 // If |io_result| is |IO_SUCCESS|, updates the write buffer and schedules a | 359 // 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 | 360 // 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 | 361 // 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 | 362 // false. Must be called under |write_lock_| and only if |write_stopped_| is |
304 // false. | 363 // false. |
305 bool OnWriteCompletedNoLock(IOResult io_result, | 364 bool OnWriteCompletedNoLock(IOResult io_result, |
306 size_t platform_handles_written, | 365 size_t platform_handles_written, |
307 size_t bytes_written); | 366 size_t bytes_written); |
308 | 367 |
368 // Handler for the RAW_CHANNEL_QUIT message. | |
369 void HandleQuitMessage(); | |
370 | |
371 // Helper method to dispatch messages from the read buffer. | |
372 // |did_dispatch_message| is true iff it dispatched any messages. | |
373 // |stop_dispatching| is set to true if the code calling this should stop | |
374 // dispatching, either because we hit an erorr or the delegate shutdown the | |
375 // channel. | |
376 void DispatchMessages(bool* did_dispatch_message, bool* stop_dispatching); | |
377 | |
309 // Set in |Init()| and never changed (hence usable on any thread without | 378 // Set in |Init()| and never changed (hence usable on any thread without |
310 // locking): | 379 // locking): |
311 base::MessageLoopForIO* message_loop_for_io_; | 380 base::MessageLoopForIO* message_loop_for_io_; |
312 | 381 |
382 | |
383 | |
384 | |
385 | |
386 // TODO(jam): one lock only.... | |
387 | |
388 | |
389 | |
390 | |
313 // Only used on the I/O thread: | 391 // Only used on the I/O thread: |
392 | |
393 bool* set_on_shutdown_; | |
394 | |
395 base::Lock read_lock_; // Protects read_buffer_. | |
396 // This is usually only accessed on IO thread, except when ReleaseHandle is | |
397 // called. | |
398 scoped_ptr<ReadBuffer> read_buffer_; | |
399 // ditto: usually used on io thread except ReleaseHandle | |
314 Delegate* delegate_; | 400 Delegate* delegate_; |
315 bool* set_on_shutdown_; | 401 |
316 scoped_ptr<ReadBuffer> read_buffer_; | 402 // If grabbing both locks, grab read first. |
317 | 403 |
318 base::Lock write_lock_; // Protects the following members. | 404 base::Lock write_lock_; // Protects the following members. |
405 bool write_ready_; | |
319 bool write_stopped_; | 406 bool write_stopped_; |
320 scoped_ptr<WriteBuffer> write_buffer_; | 407 scoped_ptr<WriteBuffer> write_buffer_; |
321 | 408 |
409 bool debug_started_sending_; | |
410 | |
411 bool error_occurred_; | |
412 | |
322 // This is used for posting tasks from write threads to the I/O thread. It | 413 // 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 | 414 // must only be accessed under |write_lock_|. The weak pointers it produces |
324 // are only used/invalidated on the I/O thread. | 415 // are only used/invalidated on the I/O thread. |
325 base::WeakPtrFactory<RawChannel> weak_ptr_factory_; | 416 base::WeakPtrFactory<RawChannel> weak_ptr_factory_; |
326 | 417 |
327 MOJO_DISALLOW_COPY_AND_ASSIGN(RawChannel); | 418 MOJO_DISALLOW_COPY_AND_ASSIGN(RawChannel); |
328 }; | 419 }; |
329 | 420 |
330 } // namespace system | 421 } // namespace system |
331 } // namespace mojo | 422 } // namespace mojo |
332 | 423 |
333 #endif // MOJO_EDK_SYSTEM_RAW_CHANNEL_H_ | 424 #endif // MOJO_EDK_SYSTEM_RAW_CHANNEL_H_ |
OLD | NEW |