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

Unified Diff: ipc/ipc_channel_mojo.cc

Issue 2183963002: Revert of Mojo C++ bindings: make ipc/ mojom targets to use STL string/vector types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 | « ipc/ipc_channel_mojo.h ('k') | ipc/ipc_channel_mojo_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_channel_mojo.cc
diff --git a/ipc/ipc_channel_mojo.cc b/ipc/ipc_channel_mojo.cc
index 627efc1dc54f1b7abd9aba0add6247bcce0cce88..9ce2e661bd145a204ca7f62dfa7e68b494c029ed 100644
--- a/ipc/ipc_channel_mojo.cc
+++ b/ipc/ipc_channel_mojo.cc
@@ -179,7 +179,7 @@
}
MojoResult WrapAttachment(MessageAttachment* attachment,
- std::vector<mojom::SerializedHandlePtr>* handles) {
+ mojo::Array<mojom::SerializedHandlePtr>* handles) {
mojom::SerializedHandlePtr serialized_handle;
MojoResult wrap_result = WrapAttachmentImpl(attachment, &serialized_handle);
if (wrap_result != MOJO_RESULT_OK) {
@@ -409,46 +409,38 @@
// static
MojoResult ChannelMojo::ReadFromMessageAttachmentSet(
Message* message,
- base::Optional<std::vector<mojom::SerializedHandlePtr>>* handles) {
- DCHECK(!*handles);
-
- MojoResult result = MOJO_RESULT_OK;
- if (!message->HasAttachments())
- return result;
-
- std::vector<mojom::SerializedHandlePtr> output_handles;
- MessageAttachmentSet* set = message->attachment_set();
-
- for (unsigned i = 0;
- result == MOJO_RESULT_OK && i < set->num_non_brokerable_attachments();
- ++i) {
- result = WrapAttachment(set->GetNonBrokerableAttachmentAt(i).get(),
- &output_handles);
- }
- for (unsigned i = 0;
- result == MOJO_RESULT_OK && i < set->num_brokerable_attachments(); ++i) {
- result = WrapAttachment(set->GetBrokerableAttachmentAt(i).get(),
- &output_handles);
- }
-
- set->CommitAllDescriptors();
-
- if (!output_handles.empty())
- *handles = std::move(output_handles);
-
- return result;
+ mojo::Array<mojom::SerializedHandlePtr>* handles) {
+ if (message->HasAttachments()) {
+ MessageAttachmentSet* set = message->attachment_set();
+ for (unsigned i = 0; i < set->num_non_brokerable_attachments(); ++i) {
+ MojoResult result = WrapAttachment(
+ set->GetNonBrokerableAttachmentAt(i).get(), handles);
+ if (result != MOJO_RESULT_OK) {
+ set->CommitAllDescriptors();
+ return result;
+ }
+ }
+ for (unsigned i = 0; i < set->num_brokerable_attachments(); ++i) {
+ MojoResult result =
+ WrapAttachment(set->GetBrokerableAttachmentAt(i).get(), handles);
+ if (result != MOJO_RESULT_OK) {
+ set->CommitAllDescriptors();
+ return result;
+ }
+ }
+ set->CommitAllDescriptors();
+ }
+ return MOJO_RESULT_OK;
}
// static
MojoResult ChannelMojo::WriteToMessageAttachmentSet(
- base::Optional<std::vector<mojom::SerializedHandlePtr>> handle_buffer,
+ mojo::Array<mojom::SerializedHandlePtr> handle_buffer,
Message* message) {
- if (!handle_buffer)
- return MOJO_RESULT_OK;
- for (size_t i = 0; i < handle_buffer->size(); ++i) {
+ for (size_t i = 0; i < handle_buffer.size(); ++i) {
scoped_refptr<MessageAttachment> unwrapped_attachment;
- MojoResult unwrap_result =
- UnwrapAttachment(std::move((*handle_buffer)[i]), &unwrapped_attachment);
+ MojoResult unwrap_result = UnwrapAttachment(std::move(handle_buffer[i]),
+ &unwrapped_attachment);
if (unwrap_result != MOJO_RESULT_OK) {
LOG(WARNING) << "Pipe failed to unwrap handles. Closing: "
<< unwrap_result;
« no previous file with comments | « ipc/ipc_channel_mojo.h ('k') | ipc/ipc_channel_mojo_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698