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

Unified Diff: mojo/edk/system/raw_channel_posix.cc

Issue 1337953004: base::Lock -> Mutex in RawChannel. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 3 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/raw_channel.cc ('k') | mojo/edk/system/raw_channel_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/raw_channel_posix.cc
diff --git a/mojo/edk/system/raw_channel_posix.cc b/mojo/edk/system/raw_channel_posix.cc
index 47862a709f691120dc47b328439d295b09ebc147..e673446b4bba6c5dac9deaf0412ee5c9d94c2afd 100644
--- a/mojo/edk/system/raw_channel_posix.cc
+++ b/mojo/edk/system/raw_channel_posix.cc
@@ -42,7 +42,8 @@ class RawChannelPosix final : public RawChannel,
// |RawChannel| protected methods:
// Actually override this so that we can send multiple messages with (only)
// FDs if necessary.
- void EnqueueMessageNoLock(scoped_ptr<MessageInTransit> message) override;
+ void EnqueueMessageNoLock(scoped_ptr<MessageInTransit> message) override
+ MOJO_EXCLUSIVE_LOCKS_REQUIRED(write_mutex());
// Override this to handle those extra FD-only messages.
bool OnReadMessageForRawChannel(
const MessageInTransit::View& message_view) override;
@@ -78,14 +79,12 @@ class RawChannelPosix final : public RawChannel,
std::deque<embedder::PlatformHandle> read_platform_handles_;
- // The following members are used on multiple threads and protected by
- // |write_lock()|:
- bool pending_write_;
+ bool pending_write_ MOJO_GUARDED_BY(write_mutex());
- // 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.
- base::WeakPtrFactory<RawChannelPosix> weak_ptr_factory_;
+ // This is used for posting tasks from write threads to the I/O thread. The
+ // weak pointers it produces are only used/invalidated on the I/O thread.
+ base::WeakPtrFactory<RawChannelPosix> weak_ptr_factory_
+ MOJO_GUARDED_BY(write_mutex());
MOJO_DISALLOW_COPY_AND_ASSIGN(RawChannelPosix);
};
@@ -102,7 +101,7 @@ RawChannelPosix::~RawChannelPosix() {
DCHECK(!pending_read_);
DCHECK(!pending_write_);
- // No need to take the |write_lock()| here -- if there are still weak pointers
+ // No need to take |write_mutex()| here -- if there are still weak pointers
// outstanding, then we're hosed anyway (since we wouldn't be able to
// invalidate them cleanly, since we might not be on the I/O thread).
DCHECK(!weak_ptr_factory_.HasWeakPtrs());
@@ -215,7 +214,7 @@ embedder::ScopedPlatformHandleVectorPtr RawChannelPosix::GetReadPlatformHandles(
RawChannel::IOResult RawChannelPosix::WriteNoLock(
size_t* platform_handles_written,
size_t* bytes_written) {
- write_lock().AssertAcquired();
+ write_mutex().AssertHeld();
DCHECK(!pending_write_);
@@ -288,7 +287,7 @@ RawChannel::IOResult RawChannelPosix::WriteNoLock(
}
RawChannel::IOResult RawChannelPosix::ScheduleWriteNoLock() {
- write_lock().AssertAcquired();
+ write_mutex().AssertHeld();
DCHECK(!pending_write_);
@@ -332,7 +331,7 @@ void RawChannelPosix::OnShutdownNoLock(
scoped_ptr<ReadBuffer> /*read_buffer*/,
scoped_ptr<WriteBuffer> /*write_buffer*/) {
DCHECK_EQ(base::MessageLoop::current(), message_loop_for_io());
- write_lock().AssertAcquired();
+ write_mutex().AssertHeld();
read_watcher_.reset(); // This will stop watching (if necessary).
write_watcher_.reset(); // This will stop watching (if necessary).
@@ -385,7 +384,7 @@ void RawChannelPosix::OnFileCanWriteWithoutBlocking(int fd) {
size_t platform_handles_written = 0;
size_t bytes_written = 0;
{
- base::AutoLock locker(write_lock());
+ MutexLocker locker(&write_mutex());
DCHECK(pending_write_);
@@ -454,7 +453,7 @@ void RawChannelPosix::WaitToWrite() {
fd_.get().fd, false, base::MessageLoopForIO::WATCH_WRITE,
write_watcher_.get(), this)) {
{
- base::AutoLock locker(write_lock());
+ MutexLocker locker(&write_mutex());
DCHECK(pending_write_);
pending_write_ = false;
« no previous file with comments | « mojo/edk/system/raw_channel.cc ('k') | mojo/edk/system/raw_channel_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698