Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Unified Diff: mojo/edk/system/raw_channel.h

Issue 1403033003: Last set of fixes to make the src/mojo/edk pass the page cycler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: another small fix Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: mojo/edk/system/raw_channel.h
diff --git a/mojo/edk/system/raw_channel.h b/mojo/edk/system/raw_channel.h
index d1799f39c27c794c2ac0dc2541a634a5eeb52768..a78d520f13ff85174cadc1a1f82733b17e04f318 100644
--- a/mojo/edk/system/raw_channel.h
+++ b/mojo/edk/system/raw_channel.h
@@ -69,9 +69,7 @@ class MOJO_SYSTEM_IMPL_EXPORT RawChannel {
// Called when there's a (fatal) error. The delegate may not call back into
// this object synchronously.
//
- // For each raw channel, there'll be at most one |ERROR_READ_...| and at
- // most one |ERROR_WRITE| notification. After |OnError(ERROR_READ_...)|,
- // |OnReadMessage()| won't be called again.
+ // For each raw channel, there'll be at most one OnError notification.
virtual void OnError(Error error) = 0;
protected:
@@ -192,7 +190,7 @@ class MOJO_SYSTEM_IMPL_EXPORT RawChannel {
// Gets buffers to be written. These buffers will always come from the front
// of |message_queue_|. Once they are completely written, the front
// |MessageInTransit| should be popped (and destroyed); this is done in
- // |OnWriteCompletedNoLock()|.
+ // |OnWriteCompletedInternalNoLock()|.
void GetBuffers(std::vector<Buffer>* buffers);
bool IsEmpty() const { return message_queue_.IsEmpty(); }
@@ -223,13 +221,20 @@ class MOJO_SYSTEM_IMPL_EXPORT RawChannel {
virtual ~RawChannel();
// |result| must not be |IO_PENDING|. Must be called on the I/O thread WITHOUT
- // |write_lock_| held. This object may be destroyed by this call.
+ // |write_lock_| held. This object may be destroyed by this call. This
+ // acquires |read_lock_| inside of it.
void OnReadCompleted(IOResult io_result, size_t bytes_read);
yzshen1 2015/10/14 18:23:46 Does it make sense tor remove On(Read|Write)Comple
jam 2015/10/14 20:01:44 good point. done.
+ // Like above, except that the caller needs to acquire read_lock_ first.
yzshen1 2015/10/14 18:23:46 style nit: please use |some_variable_name_| (and l
jam 2015/10/14 20:01:44 I stopped this since it's not in the style guide;
yzshen1 2015/10/14 21:37:00 I see, although I think consistency within the fil
+ void OnReadCompletedNoLock(IOResult io_result, size_t bytes_read);
// |result| must not be |IO_PENDING|. Must be called on the I/O thread WITHOUT
// |write_lock_| held. This object may be destroyed by this call.
void OnWriteCompleted(IOResult io_result,
size_t platform_handles_written,
size_t bytes_written);
+ // Like above, except that the caller needs to acquire write_lock_ first.
+ void OnWriteCompletedNoLock(IOResult io_result,
+ size_t platform_handles_written,
+ size_t bytes_written);
// Serialize the read buffer into the given array so that it can be sent to
// another process. Increments |num_valid_bytes_| by |additional_bytes_read|
@@ -239,9 +244,9 @@ class MOJO_SYSTEM_IMPL_EXPORT RawChannel {
// Serialize the pending messages to be written to the OS pipe to the given
// buffer so that it can be sent to another process.
- void SerializeWriteBuffer(std::vector<char>* buffer,
- size_t additional_bytes_written,
- size_t additional_platform_handles_written);
+ void SerializeWriteBuffer(size_t additional_bytes_written,
+ size_t additional_platform_handles_written,
+ std::vector<char>* buffer);
base::MessageLoopForIO* message_loop_for_io() { return message_loop_for_io_; }
base::Lock& write_lock() { return write_lock_; }
@@ -256,6 +261,8 @@ class MOJO_SYSTEM_IMPL_EXPORT RawChannel {
return write_buffer_.get();
}
+ bool pending_error() { return pending_error_; }
+
// Adds |message| to the write message queue. Implementation subclasses may
// override this to add any additional "control" messages needed. This is
// called (on any thread) with |write_lock_| held.
@@ -361,9 +368,9 @@ class MOJO_SYSTEM_IMPL_EXPORT RawChannel {
// failure or any other error occurs, cancels pending writes and returns
// false. Must be called under |write_lock_| and only if |write_stopped_| is
// false.
- bool OnWriteCompletedNoLock(IOResult io_result,
- size_t platform_handles_written,
- size_t bytes_written);
+ bool OnWriteCompletedInternalNoLock(IOResult io_result,
+ size_t platform_handles_written,
+ size_t bytes_written);
// Helper method to dispatch messages from the read buffer.
// |did_dispatch_message| is true iff it dispatched any messages.
@@ -406,6 +413,10 @@ class MOJO_SYSTEM_IMPL_EXPORT RawChannel {
bool error_occurred_;
+ // True iff a PostTask has been called to set an error. Can be written under
+ // either read or write lock. It's read with both acquired.
+ bool pending_error_;
+
// This is used for posting tasks from write threads to the I/O thread. It
// must only be accessed under |write_lock_|. The weak pointers it produces
// are only used/invalidated on the I/O thread.

Powered by Google App Engine
This is Rietveld 408576698