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/master_connection_manager.h" | 5 #include "mojo/edk/system/master_connection_manager.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> |
8 | 9 |
9 #include "base/bind.h" | 10 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
11 #include "base/location.h" | 12 #include "base/location.h" |
12 #include "base/logging.h" | 13 #include "base/logging.h" |
13 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
14 #include "base/synchronization/waitable_event.h" | 15 #include "base/synchronization/waitable_event.h" |
15 #include "mojo/edk/embedder/master_process_delegate.h" | 16 #include "mojo/edk/embedder/master_process_delegate.h" |
16 #include "mojo/edk/embedder/platform_channel_pair.h" | 17 #include "mojo/edk/embedder/platform_channel_pair.h" |
17 #include "mojo/edk/embedder/platform_handle.h" | 18 #include "mojo/edk/embedder/platform_handle.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 bytes = &data; | 178 bytes = &data; |
178 } | 179 } |
179 break; | 180 break; |
180 } | 181 } |
181 default: | 182 default: |
182 LOG(ERROR) << "Invalid message subtype " << message_view.subtype(); | 183 LOG(ERROR) << "Invalid message subtype " << message_view.subtype(); |
183 FatalError(); // WARNING: This destroys us. | 184 FatalError(); // WARNING: This destroys us. |
184 return; | 185 return; |
185 } | 186 } |
186 | 187 |
187 scoped_ptr<MessageInTransit> response(new MessageInTransit( | 188 std::unique_ptr<MessageInTransit> response(new MessageInTransit( |
188 MessageInTransit::Type::CONNECTION_MANAGER_ACK, | 189 MessageInTransit::Type::CONNECTION_MANAGER_ACK, |
189 ConnectionManagerResultToMessageInTransitSubtype(result), num_bytes, | 190 ConnectionManagerResultToMessageInTransitSubtype(result), num_bytes, |
190 bytes)); | 191 bytes)); |
191 | 192 |
192 if (result == Result::SUCCESS_CONNECT_NEW_CONNECTION) { | 193 if (result == Result::SUCCESS_CONNECT_NEW_CONNECTION) { |
193 DCHECK_EQ(message_view.subtype(), | 194 DCHECK_EQ(message_view.subtype(), |
194 MessageInTransit::Subtype::CONNECTION_MANAGER_CONNECT); | 195 MessageInTransit::Subtype::CONNECTION_MANAGER_CONNECT); |
195 DCHECK(platform_handle.is_valid()); | 196 DCHECK(platform_handle.is_valid()); |
196 embedder::ScopedPlatformHandleVectorPtr platform_handles( | 197 embedder::ScopedPlatformHandleVectorPtr platform_handles( |
197 new embedder::PlatformHandleVector()); | 198 new embedder::PlatformHandleVector()); |
198 platform_handles->push_back(platform_handle.release()); | 199 platform_handles->push_back(platform_handle.release()); |
199 response->SetTransportData(util::MakeUnique<TransportData>( | 200 response->SetTransportData(util::MakeUnique<TransportData>( |
200 platform_handles.Pass(), | 201 platform_handles.Pass(), |
201 raw_channel_->GetSerializedPlatformHandleSize())); | 202 raw_channel_->GetSerializedPlatformHandleSize())); |
202 } else { | 203 } else { |
203 DCHECK(!platform_handle.is_valid()); | 204 DCHECK(!platform_handle.is_valid()); |
204 } | 205 } |
205 | 206 |
206 if (!raw_channel_->WriteMessage(response.Pass())) { | 207 if (!raw_channel_->WriteMessage(std::move(response))) { |
207 LOG(ERROR) << "WriteMessage failed"; | 208 LOG(ERROR) << "WriteMessage failed"; |
208 FatalError(); // WARNING: This destroys us. | 209 FatalError(); // WARNING: This destroys us. |
209 return; | 210 return; |
210 } | 211 } |
211 } | 212 } |
212 | 213 |
213 void MasterConnectionManager::Helper::OnError(Error /*error*/) { | 214 void MasterConnectionManager::Helper::OnError(Error /*error*/) { |
214 // Every error (read or write) is fatal (for that particular connection). Read | 215 // Every error (read or write) is fatal (for that particular connection). Read |
215 // errors are fatal since no more commands will be received from that | 216 // errors are fatal since no more commands will be received from that |
216 // connection. Write errors are fatal since it is no longer possible to send | 217 // connection. Write errors are fatal since it is no longer possible to send |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 } | 737 } |
737 | 738 |
738 void MasterConnectionManager::AssertOnPrivateThread() const { | 739 void MasterConnectionManager::AssertOnPrivateThread() const { |
739 // This should only be called after |Init()| and before |Shutdown()|. | 740 // This should only be called after |Init()| and before |Shutdown()|. |
740 DCHECK(private_thread_.message_loop()); | 741 DCHECK(private_thread_.message_loop()); |
741 DCHECK_EQ(base::MessageLoop::current(), private_thread_.message_loop()); | 742 DCHECK_EQ(base::MessageLoop::current(), private_thread_.message_loop()); |
742 } | 743 } |
743 | 744 |
744 } // namespace system | 745 } // namespace system |
745 } // namespace mojo | 746 } // namespace mojo |
OLD | NEW |