summaryrefslogtreecommitdiffstats
path: root/mojo/system/dispatcher.cc
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-05 05:58:10 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-05 05:58:10 +0000
commit23b89dfa99470b2cc6d0e25ca47d708d9e2cd77d (patch)
treee60007ea90c0ad1af1653f772f689054b9c7bb4d /mojo/system/dispatcher.cc
parenta0c57c178a064a6a28daa15356876c4298948258 (diff)
downloadchromium_src-23b89dfa99470b2cc6d0e25ca47d708d9e2cd77d.zip
chromium_src-23b89dfa99470b2cc6d0e25ca47d708d9e2cd77d.tar.gz
chromium_src-23b89dfa99470b2cc6d0e25ca47d708d9e2cd77d.tar.bz2
Mojo: First pass at cross-process passing of MessagePipe handles.
There's still stuff left to do: - Some high-priority TODOs are marked with an additional FIXME (mostly for my benefit). - Notably, we need better error handling (in particular, if the other process spews garbage, we should correctly detect this and not die). - There's a crasher bug (see RemoteMessagePipeTest.HandlePassing). - Also, we need more testing, and more end-to-end testing. R=darin@chromium.org Review URL: https://codereview.chromium.org/180953003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@254946 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo/system/dispatcher.cc')
-rw-r--r--mojo/system/dispatcher.cc30
1 files changed, 22 insertions, 8 deletions
diff --git a/mojo/system/dispatcher.cc b/mojo/system/dispatcher.cc
index 896d044..c22a73b 100644
--- a/mojo/system/dispatcher.cc
+++ b/mojo/system/dispatcher.cc
@@ -6,6 +6,7 @@
#include "base/logging.h"
#include "mojo/system/constants.h"
+#include "mojo/system/message_pipe_dispatcher.h"
namespace mojo {
namespace system {
@@ -39,11 +40,11 @@ size_t Dispatcher::MessageInTransitAccess::GetMaximumSerializedSize(
// static
bool Dispatcher::MessageInTransitAccess::SerializeAndClose(
Dispatcher* dispatcher,
- void* destination,
Channel* channel,
+ void* destination,
size_t* actual_size) {
DCHECK(dispatcher);
- return dispatcher->SerializeAndClose(destination, channel, actual_size);
+ return dispatcher->SerializeAndClose(channel, destination, actual_size);
}
// static
@@ -52,7 +53,20 @@ scoped_refptr<Dispatcher> Dispatcher::MessageInTransitAccess::Deserialize(
int32_t type,
const void* source,
size_t size) {
- // TODO(vtl)
+ switch (static_cast<int32_t>(type)) {
+ case kTypeUnknown:
+ DVLOG(2) << "Deserializing invalid handle";
+ return scoped_refptr<Dispatcher>();
+ case kTypeMessagePipe:
+ return scoped_refptr<Dispatcher>(
+ MessagePipeDispatcher::Deserialize(channel, source, size));
+ case kTypeDataPipeProducer:
+ case kTypeDataPipeConsumer:
+ LOG(WARNING) << "Deserialization of dispatcher type " << type
+ << " not supported";
+ return scoped_refptr<Dispatcher>();
+ }
+ LOG(WARNING) << "Unknown dispatcher type " << type;
return scoped_refptr<Dispatcher>();
}
@@ -333,8 +347,8 @@ size_t Dispatcher::GetMaximumSerializedSizeImplNoLock(
return 0;
}
-bool Dispatcher::SerializeAndCloseImplNoLock(void* /*destination*/,
- Channel* /*channel*/,
+bool Dispatcher::SerializeAndCloseImplNoLock(Channel* /*channel*/,
+ void* /*destination*/,
size_t* /*actual_size*/) {
lock_.AssertAcquired();
DCHECK(is_closed_);
@@ -379,8 +393,8 @@ size_t Dispatcher::GetMaximumSerializedSize(const Channel* channel) const {
return GetMaximumSerializedSizeImplNoLock(channel);
}
-bool Dispatcher::SerializeAndClose(void* destination,
- Channel* channel,
+bool Dispatcher::SerializeAndClose(Channel* channel,
+ void* destination,
size_t* actual_size) {
DCHECK(destination);
DCHECK(channel);
@@ -401,7 +415,7 @@ bool Dispatcher::SerializeAndClose(void* destination,
// No need to cancel waiters: we shouldn't have any (and shouldn't be in
// |Core|'s handle table.
- if (!SerializeAndCloseImplNoLock(destination, channel, actual_size))
+ if (!SerializeAndCloseImplNoLock(channel, destination, actual_size))
return false;
DCHECK_LE(*actual_size, max_size);