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

Side by Side Diff: mojo/edk/system/ports/node.cc

Issue 1923373004: [mojo-edk] Move the selector in Node::GetMessageIf instead of copying it. (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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/system/ports/node.h" 5 #include "mojo/edk/system/ports/node.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <utility>
10
9 #include "base/logging.h" 11 #include "base/logging.h"
10 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
11 #include "base/synchronization/lock.h" 13 #include "base/synchronization/lock.h"
12 #include "mojo/edk/system/ports/node_delegate.h" 14 #include "mojo/edk/system/ports/node_delegate.h"
13 15
14 namespace mojo { 16 namespace mojo {
15 namespace edk { 17 namespace edk {
16 namespace ports { 18 namespace ports {
17 19
18 namespace { 20 namespace {
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 // This could also be treated like the port being unknown since the 264 // This could also be treated like the port being unknown since the
263 // embedder should no longer be referring to a port that has been sent. 265 // embedder should no longer be referring to a port that has been sent.
264 if (port->state != Port::kReceiving) 266 if (port->state != Port::kReceiving)
265 return ERROR_PORT_STATE_UNEXPECTED; 267 return ERROR_PORT_STATE_UNEXPECTED;
266 268
267 // Let the embedder get messages until there are no more before reporting 269 // Let the embedder get messages until there are no more before reporting
268 // that the peer closed its end. 270 // that the peer closed its end.
269 if (!CanAcceptMoreMessages(port)) 271 if (!CanAcceptMoreMessages(port))
270 return ERROR_PORT_PEER_CLOSED; 272 return ERROR_PORT_PEER_CLOSED;
271 273
272 port->message_queue.GetNextMessageIf(selector, message); 274 port->message_queue.GetNextMessageIf(std::move(selector), message);
273 } 275 }
274 276
275 // Allow referenced ports to trigger PortStatusChanged calls. 277 // Allow referenced ports to trigger PortStatusChanged calls.
276 if (*message) { 278 if (*message) {
277 for (size_t i = 0; i < (*message)->num_ports(); ++i) { 279 for (size_t i = 0; i < (*message)->num_ports(); ++i) {
278 const PortName& new_port_name = (*message)->ports()[i]; 280 const PortName& new_port_name = (*message)->ports()[i];
279 scoped_refptr<Port> new_port = GetPort(new_port_name); 281 scoped_refptr<Port> new_port = GetPort(new_port_name);
280 282
281 DCHECK(new_port) << "Port " << new_port_name << "@" << name_ 283 DCHECK(new_port) << "Port " << new_port_name << "@" << name_
282 << " does not exist!"; 284 << " does not exist!";
(...skipping 921 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 1206
1205 if (num_data_bytes) 1207 if (num_data_bytes)
1206 memcpy(header + 1, data, num_data_bytes); 1208 memcpy(header + 1, data, num_data_bytes);
1207 1209
1208 return message; 1210 return message;
1209 } 1211 }
1210 1212
1211 } // namespace ports 1213 } // namespace ports
1212 } // namespace edk 1214 } // namespace edk
1213 } // namespace mojo 1215 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698