OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/edk/system/routed_raw_channel.h" | 5 #include "mojo/edk/system/routed_raw_channel.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "mojo/edk/embedder/embedder_internal.h" | 9 #include "mojo/edk/embedder/embedder_internal.h" |
10 | 10 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 memcpy(&msg->message[0], message_view.main_buffer(), | 125 memcpy(&msg->message[0], message_view.main_buffer(), |
126 message_view.total_size()); | 126 message_view.total_size()); |
127 msg->handles = platform_handles.Pass(); | 127 msg->handles = platform_handles.Pass(); |
128 pending_messages_.push_back(msg.Pass()); | 128 pending_messages_.push_back(msg.Pass()); |
129 } | 129 } |
130 } | 130 } |
131 | 131 |
132 void RoutedRawChannel::OnError(Error error) { | 132 void RoutedRawChannel::OnError(Error error) { |
133 DCHECK(internal::g_io_thread_task_runner->RunsTasksOnCurrentThread()); | 133 DCHECK(internal::g_io_thread_task_runner->RunsTasksOnCurrentThread()); |
134 | 134 |
135 channel_->Shutdown(); | 135 // This needs to match non-multiplexed MessagePipeDispatcher's destruction of |
136 channel_ = nullptr; | 136 // the channel only when read errors occur. |
| 137 if (error != ERROR_WRITE) { |
| 138 channel_->Shutdown(); |
| 139 channel_ = nullptr; |
| 140 } |
| 141 |
137 if (routes_.empty()) { | 142 if (routes_.empty()) { |
138 delete this; | 143 delete this; |
139 return; | 144 return; |
140 } | 145 } |
141 | 146 |
142 for (auto it = routes_.begin(); it != routes_.end();) { | 147 for (auto it = routes_.begin(); it != routes_.end();) { |
143 // Handle the delegate calling RemoveRoute in this call. | 148 // Handle the delegate calling RemoveRoute in this call. |
144 auto cur_it = it++; | 149 auto cur_it = it++; |
145 cur_it->second->OnError(error); | 150 cur_it->second->OnError(error); |
146 } | 151 } |
147 } | 152 } |
148 | 153 |
149 } // namespace edk | 154 } // namespace edk |
150 } // namespace mojo | 155 } // namespace mojo |
OLD | NEW |