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

Unified Diff: mojo/system/raw_channel.h

Issue 223783006: Mojo: Make Channel take a RawChannel rather than creating it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: spurious space Created 6 years, 9 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/system/multiprocess_message_pipe_unittest.cc ('k') | mojo/system/raw_channel.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/system/raw_channel.h
diff --git a/mojo/system/raw_channel.h b/mojo/system/raw_channel.h
index 8f760d691940a2268b637bd0bcf7d897da4cd6f7..f1ce443e9d77aaeb8751619a36a62d4f7b345ac2 100644
--- a/mojo/system/raw_channel.h
+++ b/mojo/system/raw_channel.h
@@ -72,15 +72,14 @@ class MOJO_SYSTEM_IMPL_EXPORT RawChannel {
// Static factory method. |handle| should be a handle to a
// (platform-appropriate) bidirectional communication channel (e.g., a socket
- // on POSIX, a named pipe on Windows). Does *not* take ownership of |delegate|
- // and |message_loop_for_io|, which must remain alive while this object does.
- static RawChannel* Create(embedder::ScopedPlatformHandle handle,
- Delegate* delegate,
- base::MessageLoopForIO* message_loop_for_io);
+ // on POSIX, a named pipe on Windows).
+ static scoped_ptr<RawChannel> Create(embedder::ScopedPlatformHandle handle);
- // This must be called (on an I/O thread) before this object is used. Returns
- // true on success. On failure, |Shutdown()| should *not* be called.
- bool Init();
+ // This must be called (on an I/O thread) before this object is used. Does
+ // *not* take ownership of |delegate|. Both the I/O thread and |delegate| must
+ // remain alive for the lifetime of this object. Returns true on success. On
+ // failure, |Shutdown()| should *not* be called.
+ bool Init(Delegate* delegate);
// This must be called (on the I/O thread) before this object is destroyed.
void Shutdown();
@@ -150,7 +149,7 @@ class MOJO_SYSTEM_IMPL_EXPORT RawChannel {
DISALLOW_COPY_AND_ASSIGN(WriteBuffer);
};
- RawChannel(Delegate* delegate, base::MessageLoopForIO* message_loop_for_io);
+ RawChannel();
base::MessageLoopForIO* message_loop_for_io() { return message_loop_for_io_; }
base::Lock& write_lock() { return write_lock_; }
@@ -223,8 +222,10 @@ class MOJO_SYSTEM_IMPL_EXPORT RawChannel {
// Must be called only if |write_stopped_| is false and under |write_lock_|.
bool OnWriteCompletedNoLock(bool result, size_t bytes_written);
- Delegate* const delegate_;
- base::MessageLoopForIO* const message_loop_for_io_;
+ // Set in |Init()| and never changed (hence usable on any thread without
+ // locking):
+ Delegate* delegate_;
+ base::MessageLoopForIO* message_loop_for_io_;
// Only used on the I/O thread:
bool read_stopped_;
« no previous file with comments | « mojo/system/multiprocess_message_pipe_unittest.cc ('k') | mojo/system/raw_channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698