Index: third_party/mojo/src/mojo/edk/system/message_in_transit.h |
diff --git a/third_party/mojo/src/mojo/edk/system/message_in_transit.h b/third_party/mojo/src/mojo/edk/system/message_in_transit.h |
index 9f118f9730b5549cf319de4f6d8f56c569e0ebfd..31332ed57f1f3f837f3c5e19a33d59150ef4050b 100644 |
--- a/third_party/mojo/src/mojo/edk/system/message_in_transit.h |
+++ b/third_party/mojo/src/mojo/edk/system/message_in_transit.h |
@@ -10,6 +10,7 @@ |
#include <vector> |
+#include "base/logging.h" |
#include "base/macros.h" |
#include "base/memory/aligned_memory.h" |
#include "base/memory/scoped_ptr.h" |
@@ -142,6 +143,38 @@ class MOJO_SYSTEM_IMPL_EXPORT MessageInTransit { |
DISALLOW_COPY_AND_ASSIGN(View); |
}; |
+ class ReadContext { |
+ public: |
+ ReadContext(const View& view) : view_(view), passed_(false) {} |
+ |
+ const View& view() { |
+ DCHECK(!passed_); |
+ return view_; |
+ } |
+ |
+ bool passed() const { return passed_; } |
+ bool has_dispatchers() const { return dispatchers_.get(); } |
+ |
+ void set_dispatchers(scoped_ptr<DispatcherVector> dispatchers) { |
+ DCHECK(!passed_); |
+ dispatchers_ = dispatchers.Pass(); |
+ } |
+ |
+ scoped_ptr<MessageInTransit> PassMessage() { |
+ DCHECK(!passed_); |
+ passed_ = true; |
+ scoped_ptr<MessageInTransit> message(new MessageInTransit(view_)); |
+ if (dispatchers_ != nullptr) |
+ message->SetDispatchers(dispatchers_.Pass()); |
+ return message.Pass(); |
+ } |
+ |
+ private: |
+ const View& view_; |
+ bool passed_; |
+ scoped_ptr<DispatcherVector> dispatchers_; |
+ }; |
+ |
// |bytes| is optional; if null, the message data will be zero-initialized. |
MessageInTransit(Type type, |
Subtype subtype, |