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

Side by Side Diff: mojo/public/cpp/bindings/lib/router.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/pickle_buffer.cc ('k') | mojo/public/cpp/bindings/message.h » ('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/public/cpp/bindings/lib/router.h" 5 #include "mojo/public/cpp/bindings/lib/router.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 146
147 bool Router::AcceptWithResponder(Message* message, MessageReceiver* responder) { 147 bool Router::AcceptWithResponder(Message* message, MessageReceiver* responder) {
148 DCHECK(thread_checker_.CalledOnValidThread()); 148 DCHECK(thread_checker_.CalledOnValidThread());
149 DCHECK(message->has_flag(kMessageExpectsResponse)); 149 DCHECK(message->has_flag(kMessageExpectsResponse));
150 150
151 // Reserve 0 in case we want it to convey special meaning in the future. 151 // Reserve 0 in case we want it to convey special meaning in the future.
152 uint64_t request_id = next_request_id_++; 152 uint64_t request_id = next_request_id_++;
153 if (request_id == 0) 153 if (request_id == 0)
154 request_id = next_request_id_++; 154 request_id = next_request_id_++;
155 155
156 bool is_sync = message->has_flag(kMessageIsSync);
156 message->set_request_id(request_id); 157 message->set_request_id(request_id);
157 if (!connector_.Accept(message)) 158 if (!connector_.Accept(message))
158 return false; 159 return false;
159 160
160 if (!message->has_flag(kMessageIsSync)) { 161 if (!is_sync) {
161 // We assume ownership of |responder|. 162 // We assume ownership of |responder|.
162 async_responders_[request_id] = base::WrapUnique(responder); 163 async_responders_[request_id] = base::WrapUnique(responder);
163 return true; 164 return true;
164 } 165 }
165 166
166 bool response_received = false; 167 bool response_received = false;
167 std::unique_ptr<MessageReceiver> sync_responder(responder); 168 std::unique_ptr<MessageReceiver> sync_responder(responder);
168 sync_responses_.insert(std::make_pair( 169 sync_responses_.insert(std::make_pair(
169 request_id, base::WrapUnique(new SyncResponseInfo(&response_received)))); 170 request_id, base::WrapUnique(new SyncResponseInfo(&response_received))));
170 171
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 } 309 }
309 310
310 encountered_error_ = true; 311 encountered_error_ = true;
311 error_handler_.Run(); 312 error_handler_.Run();
312 } 313 }
313 314
314 // ---------------------------------------------------------------------------- 315 // ----------------------------------------------------------------------------
315 316
316 } // namespace internal 317 } // namespace internal
317 } // namespace mojo 318 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/pickle_buffer.cc ('k') | mojo/public/cpp/bindings/message.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698