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

Unified Diff: mojo/system/raw_channel_posix.cc

Issue 60103005: Mojo: First stab at making MessagePipes work across OS pipes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 7 years, 1 month 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/system/raw_channel_posix.cc
diff --git a/mojo/system/raw_channel_posix.cc b/mojo/system/raw_channel_posix.cc
index e218d8497cdf3989aad9a797b92a4de5b3f8173a..f0634244e3d4ecda715695eaebc45f0172da6aa0 100644
--- a/mojo/system/raw_channel_posix.cc
+++ b/mojo/system/raw_channel_posix.cc
@@ -39,7 +39,7 @@ class RawChannelPosix : public RawChannel,
virtual ~RawChannelPosix();
// |RawChannel| implementation:
- virtual void Init() OVERRIDE;
+ virtual bool Init() OVERRIDE;
virtual void Shutdown() OVERRIDE;
virtual bool WriteMessage(MessageInTransit* message) OVERRIDE;
@@ -122,7 +122,7 @@ RawChannelPosix::~RawChannelPosix() {
DCHECK(!write_watcher_.get());
}
-void RawChannelPosix::Init() {
+bool RawChannelPosix::Init() {
DCHECK_EQ(base::MessageLoop::current(), message_loop());
DCHECK(!read_watcher_.get());
@@ -133,9 +133,17 @@ void RawChannelPosix::Init() {
// No need to take the lock. No one should be using us yet.
DCHECK(write_message_queue_.empty());
- bool result = message_loop_for_io()->WatchFileDescriptor(
- fd_, true, base::MessageLoopForIO::WATCH_READ, read_watcher_.get(), this);
- DCHECK(result);
+ if (!message_loop_for_io()->WatchFileDescriptor(fd_, true,
+ base::MessageLoopForIO::WATCH_READ, read_watcher_.get(), this)) {
+ // TODO(vtl): I'm not sure |WatchFileDescriptor()| actually fails cleanly
+ // (in the sense of returning the message loop's state to what it was before
+ // it was called).
+ read_watcher_.reset();
+ write_watcher_.reset();
+ return false;
+ }
+
+ return true;
}
void RawChannelPosix::Shutdown() {

Powered by Google App Engine
This is Rietveld 408576698