summaryrefslogtreecommitdiffstats
path: root/mojo/system/message_pipe.h
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-11 22:41:48 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-11 22:41:48 +0000
commitef3797e4d14ce4b64cbbfdcf95843dc9bbdbb5b7 (patch)
tree243d458b098f7e06fdd00910a406116f5fb2db25 /mojo/system/message_pipe.h
parent5260b6683833c6d7c014346683b6bfc009f4ae72 (diff)
downloadchromium_src-ef3797e4d14ce4b64cbbfdcf95843dc9bbdbb5b7.zip
chromium_src-ef3797e4d14ce4b64cbbfdcf95843dc9bbdbb5b7.tar.gz
chromium_src-ef3797e4d14ce4b64cbbfdcf95843dc9bbdbb5b7.tar.bz2
Mojo: Implement plumbing to support passing handles over MessagePipes.
This is tricky for several reasons: - We have fine-grained locking (and would like to keep it that way), and need to avoid deadlock. In particular, acquiring multiple dispatcher locks simultaneously is dangerous -- so we allow it to fail. - We want clean failure semantics. In particular, on failure, WriteMessage() should leave the handles being sent valid. This means that we may not remove them from the handle table until the call has succeeded. Thus we have to mark them as busy. - We need to avoid various races. E.g., still to do: When sending a handle in-process, it's important that once |WriteMessage()| has sent a handle, no more calls done on that particular handle may proceed. As a result, we won't be able to simply transfer dispatchers to a new handle (in-process) but instead must create a new dispatcher referencing the same resource. This will also ensure that |Wait()|s on that handle will be properly cancelled. R=darin@chromium.org, darin Review URL: https://codereview.chromium.org/67413003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@234302 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo/system/message_pipe.h')
-rw-r--r--mojo/system/message_pipe.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/mojo/system/message_pipe.h b/mojo/system/message_pipe.h
index 67f99d2..fc5ec63 100644
--- a/mojo/system/message_pipe.h
+++ b/mojo/system/message_pipe.h
@@ -5,6 +5,8 @@
#ifndef MOJO_SYSTEM_MESSAGE_PIPE_H_
#define MOJO_SYSTEM_MESSAGE_PIPE_H_
+#include <vector>
+
#include "base/basictypes.h"
#include "base/callback.h"
#include "base/memory/ref_counted.h"
@@ -18,6 +20,7 @@ namespace mojo {
namespace system {
class Channel;
+class Dispatcher;
class MessagePipeEndpoint;
class Waiter;
@@ -43,16 +46,17 @@ class MOJO_SYSTEM_EXPORT MessagePipe :
void CancelAllWaiters(unsigned port);
void Close(unsigned port);
// Unlike |MessagePipeDispatcher::WriteMessage()|, this does not validate its
- // arguments. |bytes|/|num_bytes| and |handles|/|num_handles| must be valid.
+ // arguments.
MojoResult WriteMessage(unsigned port,
const void* bytes, uint32_t num_bytes,
- const MojoHandle* handles, uint32_t num_handles,
+ const std::vector<Dispatcher*>* dispatchers,
MojoWriteMessageFlags flags);
// Unlike |MessagePipeDispatcher::ReadMessage()|, this does not validate its
- // arguments. |bytes|/|num_bytes| and |handles|/|num_handles| must be valid.
+ // arguments.
MojoResult ReadMessage(unsigned port,
void* bytes, uint32_t* num_bytes,
- MojoHandle* handles, uint32_t* num_handles,
+ uint32_t max_num_dispatchers,
+ std::vector<scoped_refptr<Dispatcher> >* dispatchers,
MojoReadMessageFlags flags);
MojoResult AddWaiter(unsigned port,
Waiter* waiter,