Index: mojo/system/dispatcher.cc |
diff --git a/mojo/system/dispatcher.cc b/mojo/system/dispatcher.cc |
index 04f3550e9cd08eb739af4efb98eded9ef6608c48..bb3327ffedb44e463ed26fa89e630145516ffac5 100644 |
--- a/mojo/system/dispatcher.cc |
+++ b/mojo/system/dispatcher.cc |
@@ -5,6 +5,7 @@ |
#include "mojo/system/dispatcher.h" |
#include "base/logging.h" |
+#include "mojo/system/limits.h" |
namespace mojo { |
namespace system { |
@@ -19,28 +20,33 @@ MojoResult Dispatcher::Close() { |
return CloseImplNoLock(); |
} |
-MojoResult Dispatcher::WriteMessage(const void* bytes, |
- uint32_t num_bytes, |
- const MojoHandle* handles, |
- uint32_t num_handles, |
+MojoResult Dispatcher::WriteMessage(const void* bytes, uint32_t num_bytes, |
+ const std::vector<Dispatcher*>* dispatchers, |
MojoWriteMessageFlags flags) { |
+ DCHECK(!dispatchers || (dispatchers->size() > 0 && |
+ dispatchers->size() < kMaxMessageNumHandles)); |
+ |
base::AutoLock locker(lock_); |
if (is_closed_) |
return MOJO_RESULT_INVALID_ARGUMENT; |
- return WriteMessageImplNoLock(bytes, num_bytes, handles, num_handles, flags); |
+ return WriteMessageImplNoLock(bytes, num_bytes, dispatchers, flags); |
} |
-MojoResult Dispatcher::ReadMessage(void* bytes, |
- uint32_t* num_bytes, |
- MojoHandle* handles, |
- uint32_t* num_handles, |
- MojoReadMessageFlags flags) { |
+MojoResult Dispatcher::ReadMessage( |
+ void* bytes, uint32_t* num_bytes, |
+ uint32_t max_num_dispatchers, |
+ std::vector<scoped_refptr<Dispatcher> >* dispatchers, |
+ MojoReadMessageFlags flags) { |
+ DCHECK(max_num_dispatchers == 0 || !!dispatchers); |
+ |
base::AutoLock locker(lock_); |
if (is_closed_) |
return MOJO_RESULT_INVALID_ARGUMENT; |
- return ReadMessageImplNoLock(bytes, num_bytes, handles, num_handles, flags); |
+ return ReadMessageImplNoLock(bytes, num_bytes, |
+ max_num_dispatchers, dispatchers, |
+ flags); |
} |
MojoResult Dispatcher::AddWaiter(Waiter* waiter, |
@@ -86,11 +92,10 @@ MojoResult Dispatcher::CloseImplNoLock() { |
return MOJO_RESULT_OK; |
} |
-MojoResult Dispatcher::WriteMessageImplNoLock(const void* bytes, |
- uint32_t num_bytes, |
- const MojoHandle* handles, |
- uint32_t num_handles, |
- MojoWriteMessageFlags flags) { |
+MojoResult Dispatcher::WriteMessageImplNoLock( |
+ const void* bytes, uint32_t num_bytes, |
+ const std::vector<Dispatcher*>* dispatchers, |
+ MojoWriteMessageFlags flags) { |
lock_.AssertAcquired(); |
DCHECK(!is_closed_); |
// By default, this isn't supported. Only dispatchers for message pipes (with |
@@ -98,11 +103,11 @@ MojoResult Dispatcher::WriteMessageImplNoLock(const void* bytes, |
return MOJO_RESULT_INVALID_ARGUMENT; |
} |
-MojoResult Dispatcher::ReadMessageImplNoLock(void* bytes, |
- uint32_t* num_bytes, |
- MojoHandle* handles, |
- uint32_t* num_handles, |
- MojoReadMessageFlags flags) { |
+MojoResult Dispatcher::ReadMessageImplNoLock( |
+ void* bytes, uint32_t* num_bytes, |
+ uint32_t max_num_dispatchers, |
+ std::vector<scoped_refptr<Dispatcher> >* dispatchers, |
+ MojoReadMessageFlags flags) { |
lock_.AssertAcquired(); |
DCHECK(!is_closed_); |
// By default, this isn't supported. Only dispatchers for message pipes (with |