summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mojo/system/core.cc4
-rw-r--r--mojo/system/core_test_base.cc2
-rw-r--r--mojo/system/dispatcher.cc20
-rw-r--r--mojo/system/dispatcher.h24
-rw-r--r--mojo/system/handle_table.cc5
-rw-r--r--mojo/system/handle_table.h7
-rw-r--r--mojo/system/local_message_pipe_endpoint.cc13
-rw-r--r--mojo/system/local_message_pipe_endpoint.h10
-rw-r--r--mojo/system/message_in_transit.cc2
-rw-r--r--mojo/system/message_in_transit.h9
-rw-r--r--mojo/system/message_pipe.cc16
-rw-r--r--mojo/system/message_pipe.h2
-rw-r--r--mojo/system/message_pipe_dispatcher.cc2
-rw-r--r--mojo/system/message_pipe_dispatcher.h11
-rw-r--r--mojo/system/message_pipe_endpoint.cc10
-rw-r--r--mojo/system/message_pipe_endpoint.h10
-rw-r--r--mojo/system/remote_message_pipe_unittest.cc2
-rw-r--r--mojo/system/transport_data.cc16
-rw-r--r--mojo/system/transport_data.h12
19 files changed, 82 insertions, 95 deletions
diff --git a/mojo/system/core.cc b/mojo/system/core.cc
index dd8fb57..49f0a9c 100644
--- a/mojo/system/core.cc
+++ b/mojo/system/core.cc
@@ -269,7 +269,7 @@ MojoResult Core::ReadMessage(MojoHandle message_pipe_handle,
if (!num_handles || *num_handles == 0)
return dispatcher->ReadMessage(bytes, num_bytes, NULL, num_handles, flags);
- std::vector<scoped_refptr<Dispatcher> > dispatchers;
+ DispatcherVector dispatchers;
MojoResult rv = dispatcher->ReadMessage(bytes, num_bytes,
&dispatchers, num_handles,
flags);
@@ -537,7 +537,7 @@ MojoResult Core::WaitManyInternal(const MojoHandle* handles,
MojoDeadline deadline) {
DCHECK_GT(num_handles, 0u);
- std::vector<scoped_refptr<Dispatcher> > dispatchers;
+ DispatcherVector dispatchers;
dispatchers.reserve(num_handles);
for (uint32_t i = 0; i < num_handles; i++) {
scoped_refptr<Dispatcher> dispatcher = GetDispatcher(handles[i]);
diff --git a/mojo/system/core_test_base.cc b/mojo/system/core_test_base.cc
index 29c3c5c..e4efe45 100644
--- a/mojo/system/core_test_base.cc
+++ b/mojo/system/core_test_base.cc
@@ -68,7 +68,7 @@ class MockDispatcher : public Dispatcher {
virtual MojoResult ReadMessageImplNoLock(
void* bytes,
uint32_t* num_bytes,
- std::vector<scoped_refptr<Dispatcher> >* /*dispatchers*/,
+ DispatcherVector* /*dispatchers*/,
uint32_t* /*num_dispatchers*/,
MojoReadMessageFlags /*flags*/) OVERRIDE {
info_->IncrementReadMessageCallCount();
diff --git a/mojo/system/dispatcher.cc b/mojo/system/dispatcher.cc
index 1107cf3..16735fc 100644
--- a/mojo/system/dispatcher.cc
+++ b/mojo/system/dispatcher.cc
@@ -108,11 +108,10 @@ MojoResult Dispatcher::WriteMessage(
return WriteMessageImplNoLock(bytes, num_bytes, transports, flags);
}
-MojoResult Dispatcher::ReadMessage(
- void* bytes,
- uint32_t* num_bytes,
- std::vector<scoped_refptr<Dispatcher> >* dispatchers,
- uint32_t* num_dispatchers,
+MojoResult Dispatcher::ReadMessage(void* bytes,
+ uint32_t* num_bytes,
+ DispatcherVector* dispatchers,
+ uint32_t* num_dispatchers,
MojoReadMessageFlags flags) {
DCHECK(!num_dispatchers || *num_dispatchers == 0 ||
(dispatchers && dispatchers->empty()));
@@ -256,12 +255,11 @@ MojoResult Dispatcher::WriteMessageImplNoLock(
return MOJO_RESULT_INVALID_ARGUMENT;
}
-MojoResult Dispatcher::ReadMessageImplNoLock(
- void* /*bytes*/,
- uint32_t* /*num_bytes*/,
- std::vector<scoped_refptr<Dispatcher> >* /*dispatchers*/,
- uint32_t* /*num_dispatchers*/,
- MojoReadMessageFlags /*flags*/) {
+MojoResult Dispatcher::ReadMessageImplNoLock(void* /*bytes*/,
+ uint32_t* /*num_bytes*/,
+ DispatcherVector* /*dispatchers*/,
+ uint32_t* /*num_dispatchers*/,
+ MojoReadMessageFlags /*flags*/) {
lock_.AssertAcquired();
DCHECK(!is_closed_);
// By default, not supported. Only needed for message pipe dispatchers.
diff --git a/mojo/system/dispatcher.h b/mojo/system/dispatcher.h
index 25c02e8..4e9e13f 100644
--- a/mojo/system/dispatcher.h
+++ b/mojo/system/dispatcher.h
@@ -32,6 +32,8 @@ class RawSharedBufferMapping;
class TransportData;
class Waiter;
+typedef std::vector<scoped_refptr<Dispatcher> > DispatcherVector;
+
namespace test {
// Test helper. We need to declare it here so we can friend it.
@@ -77,12 +79,11 @@ class MOJO_SYSTEM_IMPL_EXPORT Dispatcher :
// |dispatchers| must be non-null but empty, if |num_dispatchers| is non-null
// and nonzero. On success, it will be set to the dispatchers to be received
// (and assigned handles) as part of the message.
- MojoResult ReadMessage(
- void* bytes,
- uint32_t* num_bytes,
- std::vector<scoped_refptr<Dispatcher> >* dispatchers,
- uint32_t* num_dispatchers,
- MojoReadMessageFlags flags);
+ MojoResult ReadMessage(void* bytes,
+ uint32_t* num_bytes,
+ DispatcherVector* dispatchers,
+ uint32_t* num_dispatchers,
+ MojoReadMessageFlags flags);
MojoResult WriteData(const void* elements,
uint32_t* elements_num_bytes,
MojoWriteDataFlags flags);
@@ -205,12 +206,11 @@ class MOJO_SYSTEM_IMPL_EXPORT Dispatcher :
uint32_t num_bytes,
std::vector<DispatcherTransport>* transports,
MojoWriteMessageFlags flags);
- virtual MojoResult ReadMessageImplNoLock(
- void* bytes,
- uint32_t* num_bytes,
- std::vector<scoped_refptr<Dispatcher> >* dispatchers,
- uint32_t* num_dispatchers,
- MojoReadMessageFlags flags);
+ virtual MojoResult ReadMessageImplNoLock(void* bytes,
+ uint32_t* num_bytes,
+ DispatcherVector* dispatchers,
+ uint32_t* num_dispatchers,
+ MojoReadMessageFlags flags);
virtual MojoResult WriteDataImplNoLock(const void* elements,
uint32_t* num_bytes,
MojoWriteDataFlags flags);
diff --git a/mojo/system/handle_table.cc b/mojo/system/handle_table.cc
index b863e81..dd5a5f4 100644
--- a/mojo/system/handle_table.cc
+++ b/mojo/system/handle_table.cc
@@ -76,9 +76,8 @@ std::pair<MojoHandle, MojoHandle> HandleTable::AddDispatcherPair(
AddDispatcherNoSizeCheck(dispatcher1));
}
-bool HandleTable::AddDispatcherVector(
- const std::vector<scoped_refptr<Dispatcher> >& dispatchers,
- MojoHandle* handles) {
+bool HandleTable::AddDispatcherVector(const DispatcherVector& dispatchers,
+ MojoHandle* handles) {
DCHECK_LE(dispatchers.size(), kMaxMessageNumHandles);
DCHECK(handles);
// TODO(vtl): |std::numeric_limits<size_t>::max()| isn't a compile-time
diff --git a/mojo/system/handle_table.h b/mojo/system/handle_table.h
index 408fae2..96f7aba 100644
--- a/mojo/system/handle_table.h
+++ b/mojo/system/handle_table.h
@@ -21,6 +21,8 @@ class Core;
class Dispatcher;
class DispatcherTransport;
+typedef std::vector<scoped_refptr<Dispatcher> > DispatcherVector;
+
// Test-only function (defined/used in embedder/test_embedder.cc). Declared here
// so it can be friended.
namespace internal {
@@ -74,9 +76,8 @@ class MOJO_SYSTEM_IMPL_EXPORT HandleTable {
// of the dispatchers may be invalid (null). Returns true on success and false
// on failure (if the handle table is full), in which case it leaves
// |handles[...]| untouched (and all dispatchers unadded).
- bool AddDispatcherVector(
- const std::vector<scoped_refptr<Dispatcher> >& dispatchers,
- MojoHandle* handles);
+ bool AddDispatcherVector(const DispatcherVector& dispatchers,
+ MojoHandle* handles);
// Tries to mark the given handles as busy and start transport on them (i.e.,
// take their dispatcher locks); |transports| must be sized to contain
diff --git a/mojo/system/local_message_pipe_endpoint.cc b/mojo/system/local_message_pipe_endpoint.cc
index b5b6bd0..606ffa9 100644
--- a/mojo/system/local_message_pipe_endpoint.cc
+++ b/mojo/system/local_message_pipe_endpoint.cc
@@ -70,11 +70,11 @@ void LocalMessagePipeEndpoint::CancelAllWaiters() {
waiter_list_.CancelAllWaiters();
}
-MojoResult LocalMessagePipeEndpoint::ReadMessage(
- void* bytes, uint32_t* num_bytes,
- std::vector<scoped_refptr<Dispatcher> >* dispatchers,
- uint32_t* num_dispatchers,
- MojoReadMessageFlags flags) {
+MojoResult LocalMessagePipeEndpoint::ReadMessage(void* bytes,
+ uint32_t* num_bytes,
+ DispatcherVector* dispatchers,
+ uint32_t* num_dispatchers,
+ MojoReadMessageFlags flags) {
DCHECK(is_open_);
DCHECK(!dispatchers || dispatchers->empty());
@@ -97,8 +97,7 @@ MojoResult LocalMessagePipeEndpoint::ReadMessage(
else
enough_space = false;
- if (std::vector<scoped_refptr<Dispatcher> >* queued_dispatchers =
- message->dispatchers()) {
+ if (DispatcherVector* queued_dispatchers = message->dispatchers()) {
if (num_dispatchers)
*num_dispatchers = static_cast<uint32_t>(queued_dispatchers->size());
if (enough_space) {
diff --git a/mojo/system/local_message_pipe_endpoint.h b/mojo/system/local_message_pipe_endpoint.h
index 963188f..d30f54b 100644
--- a/mojo/system/local_message_pipe_endpoint.h
+++ b/mojo/system/local_message_pipe_endpoint.h
@@ -31,11 +31,11 @@ class MOJO_SYSTEM_IMPL_EXPORT LocalMessagePipeEndpoint
// implement/override these:
virtual void Close() OVERRIDE;
virtual void CancelAllWaiters() OVERRIDE;
- virtual MojoResult ReadMessage(
- void* bytes, uint32_t* num_bytes,
- std::vector<scoped_refptr<Dispatcher> >* dispatchers,
- uint32_t* num_dispatchers,
- MojoReadMessageFlags flags) OVERRIDE;
+ virtual MojoResult ReadMessage(void* bytes,
+ uint32_t* num_bytes,
+ DispatcherVector* dispatchers,
+ uint32_t* num_dispatchers,
+ MojoReadMessageFlags flags) OVERRIDE;
virtual MojoResult AddWaiter(Waiter* waiter,
MojoWaitFlags flags,
MojoResult wake_result) OVERRIDE;
diff --git a/mojo/system/message_in_transit.cc b/mojo/system/message_in_transit.cc
index 79f1184..b38ea12 100644
--- a/mojo/system/message_in_transit.cc
+++ b/mojo/system/message_in_transit.cc
@@ -151,7 +151,7 @@ bool MessageInTransit::GetNextMessageSize(const void* buffer,
}
void MessageInTransit::SetDispatchers(
- scoped_ptr<std::vector<scoped_refptr<Dispatcher> > > dispatchers) {
+ scoped_ptr<DispatcherVector> dispatchers) {
DCHECK(dispatchers);
DCHECK(!dispatchers_);
diff --git a/mojo/system/message_in_transit.h b/mojo/system/message_in_transit.h
index 103ac3e..38c38d4 100644
--- a/mojo/system/message_in_transit.h
+++ b/mojo/system/message_in_transit.h
@@ -149,8 +149,7 @@ class MOJO_SYSTEM_IMPL_EXPORT MessageInTransit {
// not be referenced from anywhere else (in particular, not from the handle
// table), i.e., each dispatcher must have a reference count of 1. This
// message must not already have dispatchers.
- void SetDispatchers(
- scoped_ptr<std::vector<scoped_refptr<Dispatcher> > > dispatchers);
+ void SetDispatchers(scoped_ptr<DispatcherVector> dispatchers);
// Serializes any dispatchers to the secondary buffer. This message must not
// already have a secondary buffer (so this must only be called once). The
@@ -188,9 +187,7 @@ class MOJO_SYSTEM_IMPL_EXPORT MessageInTransit {
// Gets the dispatchers attached to this message; this may return null if
// there are none. Note that the caller may mutate the set of dispatchers
// (e.g., take ownership of all the dispatchers, leaving the vector empty).
- std::vector<scoped_refptr<Dispatcher> >* dispatchers() {
- return dispatchers_.get();
- }
+ DispatcherVector* dispatchers() { return dispatchers_.get(); }
// Returns true if this message has dispatchers attached.
bool has_dispatchers() const {
@@ -240,7 +237,7 @@ class MOJO_SYSTEM_IMPL_EXPORT MessageInTransit {
// should be "owned" by this message, i.e., have a ref count of exactly 1. (We
// allow a dispatcher entry to be null, in case it couldn't be duplicated for
// some reason.)
- scoped_ptr<std::vector<scoped_refptr<Dispatcher> > > dispatchers_;
+ scoped_ptr<DispatcherVector> dispatchers_;
DISALLOW_COPY_AND_ASSIGN(MessageInTransit);
};
diff --git a/mojo/system/message_pipe.cc b/mojo/system/message_pipe.cc
index e25ac1c..1df6527 100644
--- a/mojo/system/message_pipe.cc
+++ b/mojo/system/message_pipe.cc
@@ -82,13 +82,12 @@ MojoResult MessagePipe::WriteMessage(
transports);
}
-MojoResult MessagePipe::ReadMessage(
- unsigned port,
- void* bytes,
- uint32_t* num_bytes,
- std::vector<scoped_refptr<Dispatcher> >* dispatchers,
- uint32_t* num_dispatchers,
- MojoReadMessageFlags flags) {
+MojoResult MessagePipe::ReadMessage(unsigned port,
+ void* bytes,
+ uint32_t* num_bytes,
+ DispatcherVector* dispatchers,
+ uint32_t* num_dispatchers,
+ MojoReadMessageFlags flags) {
DCHECK(port == 0 || port == 1);
base::AutoLock locker(lock_);
@@ -259,8 +258,7 @@ MojoResult MessagePipe::AttachTransportsNoLock(
// Clone the dispatchers and attach them to the message. (This must be done as
// a separate loop, since we want to leave the dispatchers alone on failure.)
- scoped_ptr<std::vector<scoped_refptr<Dispatcher> > >
- dispatchers(new std::vector<scoped_refptr<Dispatcher> >());
+ scoped_ptr<DispatcherVector> dispatchers(new DispatcherVector());
dispatchers->reserve(transports->size());
for (size_t i = 0; i < transports->size(); i++) {
if ((*transports)[i].is_valid()) {
diff --git a/mojo/system/message_pipe.h b/mojo/system/message_pipe.h
index 7fef65b..10668da 100644
--- a/mojo/system/message_pipe.h
+++ b/mojo/system/message_pipe.h
@@ -58,7 +58,7 @@ class MOJO_SYSTEM_IMPL_EXPORT MessagePipe :
MojoResult ReadMessage(unsigned port,
void* bytes,
uint32_t* num_bytes,
- std::vector<scoped_refptr<Dispatcher> >* dispatchers,
+ DispatcherVector* dispatchers,
uint32_t* num_dispatchers,
MojoReadMessageFlags flags);
MojoResult AddWaiter(unsigned port,
diff --git a/mojo/system/message_pipe_dispatcher.cc b/mojo/system/message_pipe_dispatcher.cc
index fc626ef..6d82583 100644
--- a/mojo/system/message_pipe_dispatcher.cc
+++ b/mojo/system/message_pipe_dispatcher.cc
@@ -162,7 +162,7 @@ MojoResult MessagePipeDispatcher::WriteMessageImplNoLock(
MojoResult MessagePipeDispatcher::ReadMessageImplNoLock(
void* bytes,
uint32_t* num_bytes,
- std::vector<scoped_refptr<Dispatcher> >* dispatchers,
+ DispatcherVector* dispatchers,
uint32_t* num_dispatchers,
MojoReadMessageFlags flags) {
lock().AssertAcquired();
diff --git a/mojo/system/message_pipe_dispatcher.h b/mojo/system/message_pipe_dispatcher.h
index 9b1b3fa..3dc1547 100644
--- a/mojo/system/message_pipe_dispatcher.h
+++ b/mojo/system/message_pipe_dispatcher.h
@@ -66,12 +66,11 @@ class MOJO_SYSTEM_IMPL_EXPORT MessagePipeDispatcher : public Dispatcher {
uint32_t num_bytes,
std::vector<DispatcherTransport>* transports,
MojoWriteMessageFlags flags) OVERRIDE;
- virtual MojoResult ReadMessageImplNoLock(
- void* bytes,
- uint32_t* num_bytes,
- std::vector<scoped_refptr<Dispatcher> >* dispatchers,
- uint32_t* num_dispatchers,
- MojoReadMessageFlags flags) OVERRIDE;
+ virtual MojoResult ReadMessageImplNoLock(void* bytes,
+ uint32_t* num_bytes,
+ DispatcherVector* dispatchers,
+ uint32_t* num_dispatchers,
+ MojoReadMessageFlags flags) OVERRIDE;
virtual MojoResult AddWaiterImplNoLock(Waiter* waiter,
MojoWaitFlags flags,
MojoResult wake_result) OVERRIDE;
diff --git a/mojo/system/message_pipe_endpoint.cc b/mojo/system/message_pipe_endpoint.cc
index a1a7be3..128313e 100644
--- a/mojo/system/message_pipe_endpoint.cc
+++ b/mojo/system/message_pipe_endpoint.cc
@@ -18,11 +18,11 @@ void MessagePipeEndpoint::CancelAllWaiters() {
NOTREACHED();
}
-MojoResult MessagePipeEndpoint::ReadMessage(
- void* /*bytes*/, uint32_t* /*num_bytes*/,
- std::vector<scoped_refptr<Dispatcher> >* /*dispatchers*/,
- uint32_t* /*num_dispatchers*/,
- MojoReadMessageFlags /*flags*/) {
+MojoResult MessagePipeEndpoint::ReadMessage(void* /*bytes*/,
+ uint32_t* /*num_bytes*/,
+ DispatcherVector* /*dispatchers*/,
+ uint32_t* /*num_dispatchers*/,
+ MojoReadMessageFlags /*flags*/) {
NOTREACHED();
return MOJO_RESULT_INTERNAL;
}
diff --git a/mojo/system/message_pipe_endpoint.h b/mojo/system/message_pipe_endpoint.h
index d14c58a..46a67e1 100644
--- a/mojo/system/message_pipe_endpoint.h
+++ b/mojo/system/message_pipe_endpoint.h
@@ -60,11 +60,11 @@ class MOJO_SYSTEM_IMPL_EXPORT MessagePipeEndpoint {
// operation involves both endpoints.
virtual void Close();
virtual void CancelAllWaiters();
- virtual MojoResult ReadMessage(
- void* bytes, uint32_t* num_bytes,
- std::vector<scoped_refptr<Dispatcher> >* dispatchers,
- uint32_t* num_dispatchers,
- MojoReadMessageFlags flags);
+ virtual MojoResult ReadMessage(void* bytes,
+ uint32_t* num_bytes,
+ DispatcherVector* dispatchers,
+ uint32_t* num_dispatchers,
+ MojoReadMessageFlags flags);
virtual MojoResult AddWaiter(Waiter* waiter,
MojoWaitFlags flags,
MojoResult wake_result);
diff --git a/mojo/system/remote_message_pipe_unittest.cc b/mojo/system/remote_message_pipe_unittest.cc
index 7deb252..e62c747 100644
--- a/mojo/system/remote_message_pipe_unittest.cc
+++ b/mojo/system/remote_message_pipe_unittest.cc
@@ -483,7 +483,7 @@ TEST_F(RemoteMessagePipeTest, HandlePassing) {
// Read from MP 1, port 1.
char read_buffer[100] = { 0 };
uint32_t read_buffer_size = static_cast<uint32_t>(sizeof(read_buffer));
- std::vector<scoped_refptr<Dispatcher> > read_dispatchers;
+ DispatcherVector read_dispatchers;
uint32_t read_num_dispatchers = 10; // Maximum to get.
EXPECT_EQ(MOJO_RESULT_OK,
mp1->ReadMessage(1, read_buffer, &read_buffer_size,
diff --git a/mojo/system/transport_data.cc b/mojo/system/transport_data.cc
index b3c4845..634452f 100644
--- a/mojo/system/transport_data.cc
+++ b/mojo/system/transport_data.cc
@@ -46,9 +46,8 @@ struct TransportData::PrivateStructForCompileAsserts {
sizeof_MessageInTransit_HandleTableEntry_invalid);
};
-TransportData::TransportData(
- scoped_ptr<std::vector<scoped_refptr<Dispatcher> > > dispatchers,
- Channel* channel)
+TransportData::TransportData(scoped_ptr<DispatcherVector> dispatchers,
+ Channel* channel)
: buffer_size_(0) {
DCHECK(dispatchers);
DCHECK(channel);
@@ -219,18 +218,17 @@ const char* TransportData::ValidateBuffer(const void* buffer,
}
// static
-scoped_ptr<std::vector<scoped_refptr<Dispatcher> > >
- TransportData::DeserializeDispatchersFromBuffer(const void* buffer,
- size_t buffer_size,
- Channel* channel) {
+scoped_ptr<DispatcherVector> TransportData::DeserializeDispatchersFromBuffer(
+ const void* buffer,
+ size_t buffer_size,
+ Channel* channel) {
DCHECK(buffer);
DCHECK_GT(buffer_size, 0u);
DCHECK(channel);
const Header* header = static_cast<const Header*>(buffer);
const size_t num_handles = header->num_handles;
- scoped_ptr<std::vector<scoped_refptr<Dispatcher> > > dispatchers(
- new std::vector<scoped_refptr<Dispatcher> >(num_handles));
+ scoped_ptr<DispatcherVector> dispatchers(new DispatcherVector(num_handles));
const HandleTableEntry* handle_table =
reinterpret_cast<const HandleTableEntry*>(
diff --git a/mojo/system/transport_data.h b/mojo/system/transport_data.h
index d4d9528..569ff8e 100644
--- a/mojo/system/transport_data.h
+++ b/mojo/system/transport_data.h
@@ -79,9 +79,7 @@ class MOJO_SYSTEM_IMPL_EXPORT TransportData {
// dispatcher.
static const size_t kMaxSerializedDispatcherPlatformHandles = 2;
- TransportData(
- scoped_ptr<std::vector<scoped_refptr<Dispatcher> > > dispatchers,
- Channel* channel);
+ TransportData(scoped_ptr<DispatcherVector> dispatchers, Channel* channel);
~TransportData();
const void* buffer() const { return buffer_.get(); }
@@ -112,10 +110,10 @@ class MOJO_SYSTEM_IMPL_EXPORT TransportData {
// Deserializes dispatchers from the given (serialized) transport data buffer
// (typically from a |MessageInTransit::View|). |buffer| should be non-null
// and |buffer_size| should be nonzero.
- static scoped_ptr<std::vector<scoped_refptr<Dispatcher> > >
- DeserializeDispatchersFromBuffer(const void* buffer,
- size_t buffer_size,
- Channel* channel);
+ static scoped_ptr<DispatcherVector> DeserializeDispatchersFromBuffer(
+ const void* buffer,
+ size_t buffer_size,
+ Channel* channel);
private:
// To allow us to make compile-assertions about |Header|, etc. in the .cc