| 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 "mojo/public/cpp/bindings/error_handler.h" | 7 #include "mojo/public/cpp/bindings/error_handler.h" |
| 8 #include "mojo/public/cpp/environment/logging.h" | 8 #include "mojo/public/cpp/environment/logging.h" |
| 9 | 9 |
| 10 namespace mojo { | 10 namespace mojo { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 void Connector::CloseMessagePipe() { | 38 void Connector::CloseMessagePipe() { |
| 39 CancelWait(); | 39 CancelWait(); |
| 40 Close(message_pipe_.Pass()); | 40 Close(message_pipe_.Pass()); |
| 41 } | 41 } |
| 42 | 42 |
| 43 ScopedMessagePipeHandle Connector::PassMessagePipe() { | 43 ScopedMessagePipeHandle Connector::PassMessagePipe() { |
| 44 CancelWait(); | 44 CancelWait(); |
| 45 return message_pipe_.Pass(); | 45 return message_pipe_.Pass(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 bool Connector::WaitForIncomingMessage() { | 48 bool Connector::WaitForIncomingMessage(MojoDeadline deadline) { |
| 49 if (error_) | 49 if (error_) |
| 50 return false; | 50 return false; |
| 51 | 51 |
| 52 MojoResult rv = Wait(message_pipe_.get(), | 52 MojoResult rv = |
| 53 MOJO_HANDLE_SIGNAL_READABLE, | 53 Wait(message_pipe_.get(), MOJO_HANDLE_SIGNAL_READABLE, deadline, nullptr); |
| 54 MOJO_DEADLINE_INDEFINITE, | 54 if (rv == MOJO_RESULT_SHOULD_WAIT) |
| 55 nullptr); | 55 return false; |
| 56 if (rv != MOJO_RESULT_OK) { | 56 if (rv != MOJO_RESULT_OK) { |
| 57 NotifyError(); | 57 NotifyError(); |
| 58 return false; | 58 return false; |
| 59 } | 59 } |
| 60 mojo_ignore_result(ReadSingleMessage(&rv)); | 60 mojo_ignore_result(ReadSingleMessage(&rv)); |
| 61 return (rv == MOJO_RESULT_OK); | 61 return (rv == MOJO_RESULT_OK); |
| 62 } | 62 } |
| 63 | 63 |
| 64 bool Connector::Accept(Message* message) { | 64 bool Connector::Accept(Message* message) { |
| 65 MOJO_CHECK(message_pipe_.is_valid()); | 65 MOJO_CHECK(message_pipe_.is_valid()); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 | 198 |
| 199 void Connector::NotifyError() { | 199 void Connector::NotifyError() { |
| 200 error_ = true; | 200 error_ = true; |
| 201 CancelWait(); | 201 CancelWait(); |
| 202 if (error_handler_) | 202 if (error_handler_) |
| 203 error_handler_->OnConnectionError(); | 203 error_handler_->OnConnectionError(); |
| 204 } | 204 } |
| 205 | 205 |
| 206 } // namespace internal | 206 } // namespace internal |
| 207 } // namespace mojo | 207 } // namespace mojo |
| OLD | NEW |