| 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 { |
| 11 namespace internal { | 11 namespace internal { |
| 12 | 12 |
| 13 // ---------------------------------------------------------------------------- | 13 // ---------------------------------------------------------------------------- |
| 14 | 14 |
| 15 Connector::Connector(ScopedMessagePipeHandle message_pipe, | 15 Connector::Connector(ScopedMessagePipeHandle message_pipe, |
| 16 const MojoAsyncWaiter* waiter) | 16 const MojoAsyncWaiter* waiter) |
| 17 : error_handler_(nullptr), | 17 : waiter_(waiter), |
| 18 waiter_(waiter), | |
| 19 message_pipe_(message_pipe.Pass()), | 18 message_pipe_(message_pipe.Pass()), |
| 20 incoming_receiver_(nullptr), | 19 incoming_receiver_(nullptr), |
| 21 async_wait_id_(0), | 20 async_wait_id_(0), |
| 22 error_(false), | 21 error_(false), |
| 23 drop_writes_(false), | 22 drop_writes_(false), |
| 24 enforce_errors_from_incoming_receiver_(true), | 23 enforce_errors_from_incoming_receiver_(true), |
| 25 destroyed_flag_(nullptr) { | 24 destroyed_flag_(nullptr) { |
| 26 // Even though we don't have an incoming receiver, we still want to monitor | 25 // Even though we don't have an incoming receiver, we still want to monitor |
| 27 // the message pipe to know if is closed or encounters an error. | 26 // the message pipe to know if is closed or encounters an error. |
| 28 WaitToReadMore(); | 27 WaitToReadMore(); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 if (!async_wait_id_) | 190 if (!async_wait_id_) |
| 192 return; | 191 return; |
| 193 | 192 |
| 194 waiter_->CancelWait(async_wait_id_); | 193 waiter_->CancelWait(async_wait_id_); |
| 195 async_wait_id_ = 0; | 194 async_wait_id_ = 0; |
| 196 } | 195 } |
| 197 | 196 |
| 198 void Connector::NotifyError() { | 197 void Connector::NotifyError() { |
| 199 error_ = true; | 198 error_ = true; |
| 200 CloseMessagePipe(); | 199 CloseMessagePipe(); |
| 201 if (error_handler_) | 200 connection_error_handler_.Run(); |
| 202 error_handler_->OnConnectionError(); | |
| 203 } | 201 } |
| 204 | 202 |
| 205 } // namespace internal | 203 } // namespace internal |
| 206 } // namespace mojo | 204 } // namespace mojo |
| OLD | NEW |