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

Unified Diff: mojo/public/cpp/bindings/message.h

Issue 1932083002: Mojo: Use new message APIs to reduce copying (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 4 years, 8 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
« no previous file with comments | « mojo/public/cpp/bindings/lib/router.cc ('k') | mojo/public/cpp/bindings/tests/connector_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/message.h
diff --git a/mojo/public/cpp/bindings/message.h b/mojo/public/cpp/bindings/message.h
index 2d06500a210e6e15d3c16eaa1dbc4e392ffd8c6d..d8eed2bfc3ec00a96948954a86ade3b99fdc088c 100644
--- a/mojo/public/cpp/bindings/message.h
+++ b/mojo/public/cpp/bindings/message.h
@@ -13,8 +13,9 @@
#include <vector>
#include "base/logging.h"
+#include "mojo/public/cpp/bindings/lib/message_buffer.h"
#include "mojo/public/cpp/bindings/lib/message_internal.h"
-#include "mojo/public/cpp/bindings/lib/pickle_buffer.h"
+#include "mojo/public/cpp/system/message.h"
namespace mojo {
@@ -27,15 +28,18 @@ class Message {
Message();
~Message();
+ // Initializes a Message with enough space for |capacity| bytes.
void Initialize(size_t capacity, bool zero_initialized);
+ // Initializes a Message from an existing Mojo MessageHandle.
+ void InitializeFromMojoMessage(ScopedMessageHandle message,
+ uint32_t num_bytes,
+ std::vector<Handle>* handles);
+
// Transfers data and handles to |destination|.
void MoveTo(Message* destination);
- uint32_t data_num_bytes() const {
- DCHECK(buffer_->data_num_bytes() <= std::numeric_limits<uint32_t>::max());
- return static_cast<uint32_t>(buffer_->data_num_bytes());
- }
+ uint32_t data_num_bytes() const { return buffer_->data_num_bytes(); }
// Access the raw bytes of the message.
const uint8_t* data() const {
@@ -90,10 +94,15 @@ class Message {
// Access the underlying Buffer interface.
internal::Buffer* buffer() { return buffer_.get(); }
+ // Takes a scoped MessageHandle which may be passed to |WriteMessageNew()| for
+ // transmission. Note that this invalidates this Message object, taking
+ // ownership of its internal storage and any attached handles.
+ ScopedMessageHandle TakeMojoMessage();
+
private:
void CloseHandles();
- std::unique_ptr<internal::PickleBuffer> buffer_;
+ std::unique_ptr<internal::MessageBuffer> buffer_;
std::vector<Handle> handles_;
DISALLOW_COPY_AND_ASSIGN(Message);
« no previous file with comments | « mojo/public/cpp/bindings/lib/router.cc ('k') | mojo/public/cpp/bindings/tests/connector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698