| 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 "ipc/mojo/ipc_channel_mojo.h" | 5 #include "ipc/mojo/ipc_channel_mojo.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "ipc/ipc_listener.h" | 10 #include "ipc/ipc_listener.h" |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 control_reader_.reset(); | 168 control_reader_.reset(); |
| 169 message_reader_.reset(); | 169 message_reader_.reset(); |
| 170 channel_info_.reset(); | 170 channel_info_.reset(); |
| 171 } | 171 } |
| 172 | 172 |
| 173 void ChannelMojo::OnConnected(mojo::ScopedMessagePipeHandle pipe) { | 173 void ChannelMojo::OnConnected(mojo::ScopedMessagePipeHandle pipe) { |
| 174 message_reader_ = | 174 message_reader_ = |
| 175 make_scoped_ptr(new internal::MessageReader(pipe.Pass(), this)); | 175 make_scoped_ptr(new internal::MessageReader(pipe.Pass(), this)); |
| 176 | 176 |
| 177 for (size_t i = 0; i < pending_messages_.size(); ++i) { | 177 for (size_t i = 0; i < pending_messages_.size(); ++i) { |
| 178 message_reader_->Send(make_scoped_ptr(pending_messages_[i])); | 178 bool sent = message_reader_->Send(make_scoped_ptr(pending_messages_[i])); |
| 179 pending_messages_[i] = NULL; | 179 pending_messages_[i] = NULL; |
| 180 if (!sent) { |
| 181 pending_messages_.clear(); |
| 182 listener_->OnChannelError(); |
| 183 return; |
| 184 } |
| 180 } | 185 } |
| 181 | 186 |
| 182 pending_messages_.clear(); | 187 pending_messages_.clear(); |
| 183 | 188 |
| 184 listener_->OnChannelConnected(GetPeerPID()); | 189 listener_->OnChannelConnected(GetPeerPID()); |
| 185 } | 190 } |
| 186 | 191 |
| 187 void ChannelMojo::OnPipeClosed(internal::MessagePipeReader* reader) { | 192 void ChannelMojo::OnPipeClosed(internal::MessagePipeReader* reader) { |
| 188 Close(); | 193 Close(); |
| 189 } | 194 } |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 handles->push_back(wrapped_handle); | 285 handles->push_back(wrapped_handle); |
| 281 } | 286 } |
| 282 } | 287 } |
| 283 | 288 |
| 284 return MOJO_RESULT_OK; | 289 return MOJO_RESULT_OK; |
| 285 } | 290 } |
| 286 | 291 |
| 287 #endif // defined(OS_POSIX) && !defined(OS_NACL) | 292 #endif // defined(OS_POSIX) && !defined(OS_NACL) |
| 288 | 293 |
| 289 } // namespace IPC | 294 } // namespace IPC |
| OLD | NEW |