| OLD | NEW |
| 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/sync_dispatcher.h" | 5 #include "mojo/public/cpp/bindings/sync_dispatcher.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include "mojo/public/cpp/bindings/message.h" | 9 #include "mojo/public/cpp/bindings/message.h" |
| 10 | 10 |
| 11 namespace mojo { | 11 namespace mojo { |
| 12 | 12 |
| 13 bool WaitForMessageAndDispatch(MessagePipeHandle handle, | 13 bool WaitForMessageAndDispatch(MessagePipeHandle handle, |
| 14 MessageReceiver* receiver) { | 14 MessageReceiver* receiver) { |
| 15 while (true) { | 15 while (true) { |
| 16 bool result; | 16 bool result; |
| 17 MojoResult rv = ReadAndDispatchMessage(handle, receiver, &result); | 17 MojoResult rv = ReadAndDispatchMessage(handle, receiver, &result); |
| 18 if (rv == MOJO_RESULT_OK) | 18 if (rv == MOJO_RESULT_OK) |
| 19 return result; | 19 return result; |
| 20 if (rv == MOJO_RESULT_SHOULD_WAIT) | 20 if (rv == MOJO_RESULT_SHOULD_WAIT) |
| 21 rv = Wait(handle, MOJO_WAIT_FLAG_READABLE, MOJO_DEADLINE_INDEFINITE); | 21 rv = Wait(handle, MOJO_WAIT_FLAG_READABLE, MOJO_DEADLINE_INDEFINITE); |
| 22 if (rv != MOJO_RESULT_OK) | 22 if (rv != MOJO_RESULT_OK) |
| 23 return false; | 23 return false; |
| 24 } | 24 } |
| 25 } | 25 } |
| 26 | 26 |
| 27 } // namespace mojo | 27 } // namespace mojo |
| OLD | NEW |