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

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: nit 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
« no previous file with comments | « mojo/edk/system/message_pipe_dispatcher.cc ('k') | mojo/edk/system/raw_channel.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..8b0b0106ffface5f352e47ff6d91315be415901d 100644
--- a/mojo/edk/system/raw_channel.h
+++ b/mojo/edk/system/raw_channel.h
@@ -192,7 +192,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 +223,16 @@ 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.
- void OnReadCompleted(IOResult io_result, size_t bytes_read);
+ // |write_lock_| held. This object may be destroyed by this call. This
+ // acquires |read_lock_| inside of it. The caller needs to acquire read_lock_
+ // first.
+ 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);
+ // |write_lock_| held. This object may be destroyed by this call. 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 +242,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 +259,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 +366,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.
@@ -374,6 +379,9 @@ class MOJO_SYSTEM_IMPL_EXPORT RawChannel {
void UpdateWriteBuffer(size_t platform_handles_written, size_t bytes_written);
+ // Acquires read_lock_ and calls OnReadCompletedNoLock.
+ void CallOnReadCompleted(IOResult io_result, size_t bytes_read);
+
// Set in |Init()| and never changed (hence usable on any thread without
// locking):
base::MessageLoopForIO* message_loop_for_io_;
@@ -406,6 +414,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.
« no previous file with comments | « mojo/edk/system/message_pipe_dispatcher.cc ('k') | mojo/edk/system/raw_channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698