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

Side by Side Diff: mojo/public/cpp/bindings/lib/interface_endpoint_client.cc

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, 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/public/cpp/bindings/lib/fixed_buffer.cc ('k') | mojo/public/cpp/bindings/lib/message.cc » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/public/cpp/bindings/lib/interface_endpoint_client.h" 5 #include "mojo/public/cpp/bindings/lib/interface_endpoint_client.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 if (encountered_error_) 212 if (encountered_error_)
213 return false; 213 return false;
214 214
215 // Reserve 0 in case we want it to convey special meaning in the future. 215 // Reserve 0 in case we want it to convey special meaning in the future.
216 uint64_t request_id = next_request_id_++; 216 uint64_t request_id = next_request_id_++;
217 if (request_id == 0) 217 if (request_id == 0)
218 request_id = next_request_id_++; 218 request_id = next_request_id_++;
219 219
220 message->set_request_id(request_id); 220 message->set_request_id(request_id);
221 221
222 bool is_sync = message->has_flag(kMessageIsSync);
222 if (!controller_->SendMessage(message)) 223 if (!controller_->SendMessage(message))
223 return false; 224 return false;
224 225
225 if (!message->has_flag(kMessageIsSync)) { 226 if (!is_sync) {
226 // We assume ownership of |responder|. 227 // We assume ownership of |responder|.
227 async_responders_[request_id] = base::WrapUnique(responder); 228 async_responders_[request_id] = base::WrapUnique(responder);
228 return true; 229 return true;
229 } 230 }
230 231
231 bool response_received = false; 232 bool response_received = false;
232 std::unique_ptr<MessageReceiver> sync_responder(responder); 233 std::unique_ptr<MessageReceiver> sync_responder(responder);
233 sync_responses_.insert(std::make_pair( 234 sync_responses_.insert(std::make_pair(
234 request_id, base::WrapUnique(new SyncResponseInfo(&response_received)))); 235 request_id, base::WrapUnique(new SyncResponseInfo(&response_received))));
235 236
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 } else { 303 } else {
303 if (!incoming_receiver_) 304 if (!incoming_receiver_)
304 return false; 305 return false;
305 306
306 return incoming_receiver_->Accept(message); 307 return incoming_receiver_->Accept(message);
307 } 308 }
308 } 309 }
309 310
310 } // namespace internal 311 } // namespace internal
311 } // namespace mojo 312 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/fixed_buffer.cc ('k') | mojo/public/cpp/bindings/lib/message.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698