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

Unified Diff: mojo/system/dispatcher.cc

Issue 67413003: Mojo: Implement plumbing to support passing handles over MessagePipes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased & review comments 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
« no previous file with comments | « mojo/system/dispatcher.h ('k') | mojo/system/dispatcher_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « mojo/system/dispatcher.h ('k') | mojo/system/dispatcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698