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

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

Issue 1576603002: Makes bindings work with nested message loops (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 | 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/connector.h" 5 #include "mojo/public/cpp/bindings/lib/connector.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 CHECK(!paused_); 224 CHECK(!paused_);
225 225
226 bool receiver_result = false; 226 bool receiver_result = false;
227 227
228 // Detect if |this| was destroyed during message dispatch. Allow for the 228 // Detect if |this| was destroyed during message dispatch. Allow for the
229 // possibility of re-entering ReadMore() through message dispatch. 229 // possibility of re-entering ReadMore() through message dispatch.
230 bool was_destroyed_during_dispatch = false; 230 bool was_destroyed_during_dispatch = false;
231 bool* previous_destroyed_flag = destroyed_flag_; 231 bool* previous_destroyed_flag = destroyed_flag_;
232 destroyed_flag_ = &was_destroyed_during_dispatch; 232 destroyed_flag_ = &was_destroyed_during_dispatch;
233 233
234 MojoResult rv = ReadAndDispatchMessage( 234 Message message;
235 message_pipe_.get(), incoming_receiver_, &receiver_result); 235 const MojoResult rv = ReadMessage(message_pipe_.get(), &message);
236 if (read_result) 236 *read_result = rv;
237 *read_result = rv; 237
238 if (rv == MOJO_RESULT_OK) {
239 // Dispatching the message may spin in a nested message loop. To ensure we
240 // continue dispatching messages when this happens start listening for
241 // messagse now.
242 if (!async_wait_id_)
243 WaitToReadMore();
yzshen1 2016/01/09 00:26:30 Could you please add a TODO for evaluating the per
sky 2016/01/11 16:10:35 Done.
244 receiver_result =
245 incoming_receiver_ && incoming_receiver_->Accept(&message);
246 }
238 247
239 if (was_destroyed_during_dispatch) { 248 if (was_destroyed_during_dispatch) {
240 if (previous_destroyed_flag) 249 if (previous_destroyed_flag)
241 *previous_destroyed_flag = true; // Propagate flag. 250 *previous_destroyed_flag = true; // Propagate flag.
242 return false; 251 return false;
243 } 252 }
253
244 destroyed_flag_ = previous_destroyed_flag; 254 destroyed_flag_ = previous_destroyed_flag;
245 255
246 if (rv == MOJO_RESULT_SHOULD_WAIT) 256 if (rv == MOJO_RESULT_SHOULD_WAIT)
247 return true; 257 return true;
248 258
249 if (rv != MOJO_RESULT_OK) { 259 if (rv != MOJO_RESULT_OK) {
250 HandleError(rv != MOJO_RESULT_FAILED_PRECONDITION, false); 260 HandleError(rv != MOJO_RESULT_FAILED_PRECONDITION, false);
251 return false; 261 return false;
252 } 262 }
253 263
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 if (!paused_) 330 if (!paused_)
321 WaitToReadMore(); 331 WaitToReadMore();
322 } else { 332 } else {
323 error_ = true; 333 error_ = true;
324 connection_error_handler_.Run(); 334 connection_error_handler_.Run();
325 } 335 }
326 } 336 }
327 337
328 } // namespace internal 338 } // namespace internal
329 } // namespace mojo 339 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | mojo/public/cpp/bindings/lib/message.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698