OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 |
OLD | NEW |