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

Unified Diff: third_party/mojo/src/mojo/edk/system/message_in_transit.h

Issue 929433005: WIP: A couple of more ChannelMojo speedup ideas (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Build and test fix Created 5 years, 10 months 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
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,

Powered by Google App Engine
This is Rietveld 408576698