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

Side by Side Diff: mojo/edk/js/core.cc

Issue 1880823005: [mojo-edk] Add explicit message object APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « mojo/edk/embedder/entrypoints.cc ('k') | mojo/edk/js/tests/connection_tests.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/edk/js/core.h" 5 #include "mojo/edk/js/core.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 MojoWriteMessageFlags flags) { 138 MojoWriteMessageFlags flags) {
139 std::vector<MojoHandle> raw_handles(handles.size()); 139 std::vector<MojoHandle> raw_handles(handles.size());
140 for (size_t i = 0; i < handles.size(); ++i) 140 for (size_t i = 0; i < handles.size(); ++i)
141 raw_handles[i] = handles[i]->get().value(); 141 raw_handles[i] = handles[i]->get().value();
142 MojoResult rv = MojoWriteMessage(handle.value(), 142 MojoResult rv = MojoWriteMessage(handle.value(),
143 buffer.bytes(), 143 buffer.bytes(),
144 static_cast<uint32_t>(buffer.num_bytes()), 144 static_cast<uint32_t>(buffer.num_bytes()),
145 raw_handles.empty() ? NULL : &raw_handles[0], 145 raw_handles.empty() ? NULL : &raw_handles[0],
146 static_cast<uint32_t>(raw_handles.size()), 146 static_cast<uint32_t>(raw_handles.size()),
147 flags); 147 flags);
148 // MojoWriteMessage takes ownership of the handles upon success, so 148 // MojoWriteMessage takes ownership of the handles, so release them here.
149 // release them here. 149 for (size_t i = 0; i < handles.size(); ++i)
150 if (rv == MOJO_RESULT_OK) { 150 ignore_result(handles[i]->release());
151 for (size_t i = 0; i < handles.size(); ++i) 151
152 ignore_result(handles[i]->release());
153 }
154 return rv; 152 return rv;
155 } 153 }
156 154
157 gin::Dictionary ReadMessage(const gin::Arguments& args, 155 gin::Dictionary ReadMessage(const gin::Arguments& args,
158 mojo::Handle handle, 156 mojo::Handle handle,
159 MojoReadMessageFlags flags) { 157 MojoReadMessageFlags flags) {
160 uint32_t num_bytes = 0; 158 uint32_t num_bytes = 0;
161 uint32_t num_handles = 0; 159 uint32_t num_handles = 0;
162 MojoResult result = MojoReadMessage( 160 MojoResult result = MojoReadMessage(
163 handle.value(), NULL, &num_bytes, NULL, &num_handles, flags); 161 handle.value(), NULL, &num_bytes, NULL, &num_handles, flags);
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 373
376 data->SetObjectTemplate(&g_wrapper_info, templ); 374 data->SetObjectTemplate(&g_wrapper_info, templ);
377 } 375 }
378 376
379 return templ->NewInstance(); 377 return templ->NewInstance();
380 } 378 }
381 379
382 } // namespace js 380 } // namespace js
383 } // namespace edk 381 } // namespace edk
384 } // namespace mojo 382 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/embedder/entrypoints.cc ('k') | mojo/edk/js/tests/connection_tests.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698