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 "mojo/embedder/embedder.h" | 5 #include "mojo/embedder/embedder.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "mojo/embedder/platform_support.h" | 11 #include "mojo/embedder/platform_support.h" |
12 #include "mojo/system/channel.h" | 12 #include "mojo/system/channel.h" |
| 13 #include "mojo/system/channel_endpoint.h" |
13 #include "mojo/system/core.h" | 14 #include "mojo/system/core.h" |
14 #include "mojo/system/entrypoints.h" | 15 #include "mojo/system/entrypoints.h" |
15 #include "mojo/system/message_in_transit.h" | 16 #include "mojo/system/message_in_transit.h" |
16 #include "mojo/system/message_pipe.h" | 17 #include "mojo/system/message_pipe.h" |
17 #include "mojo/system/message_pipe_dispatcher.h" | 18 #include "mojo/system/message_pipe_dispatcher.h" |
18 #include "mojo/system/platform_handle_dispatcher.h" | 19 #include "mojo/system/platform_handle_dispatcher.h" |
19 #include "mojo/system/raw_channel.h" | 20 #include "mojo/system/raw_channel.h" |
20 | 21 |
21 namespace mojo { | 22 namespace mojo { |
22 namespace embedder { | 23 namespace embedder { |
(...skipping 28 matching lines...) Expand all Loading... |
51 // This is very unusual (e.g., maybe |platform_handle| was invalid or we | 52 // This is very unusual (e.g., maybe |platform_handle| was invalid or we |
52 // reached some system resource limit). | 53 // reached some system resource limit). |
53 LOG(ERROR) << "Channel::Init() failed"; | 54 LOG(ERROR) << "Channel::Init() failed"; |
54 // Return null, since |Shutdown()| shouldn't be called in this case. | 55 // Return null, since |Shutdown()| shouldn't be called in this case. |
55 return scoped_refptr<system::Channel>(); | 56 return scoped_refptr<system::Channel>(); |
56 } | 57 } |
57 // Once |Init()| has succeeded, we have to return |channel| (since | 58 // Once |Init()| has succeeded, we have to return |channel| (since |
58 // |Shutdown()| will have to be called on it). | 59 // |Shutdown()| will have to be called on it). |
59 | 60 |
60 // Attach the message pipe endpoint. | 61 // Attach the message pipe endpoint. |
61 system::MessageInTransit::EndpointId endpoint_id = | 62 system::MessageInTransit::EndpointId endpoint_id = channel->AttachEndpoint( |
62 channel->AttachMessagePipeEndpoint(message_pipe, 1); | 63 make_scoped_refptr(new system::ChannelEndpoint(message_pipe.get(), 1))); |
63 if (endpoint_id == system::MessageInTransit::kInvalidEndpointId) { | 64 if (endpoint_id == system::MessageInTransit::kInvalidEndpointId) { |
64 // This means that, e.g., the other endpoint of the message pipe was closed | 65 // This means that, e.g., the other endpoint of the message pipe was closed |
65 // first. But it's not necessarily an error per se. | 66 // first. But it's not necessarily an error per se. |
66 DVLOG(2) << "Channel::AttachMessagePipeEndpoint() failed"; | 67 DVLOG(2) << "Channel::AttachEndpoint() failed"; |
67 return channel; | 68 return channel; |
68 } | 69 } |
69 CHECK_EQ(endpoint_id, system::Channel::kBootstrapEndpointId); | 70 CHECK_EQ(endpoint_id, system::Channel::kBootstrapEndpointId); |
70 | 71 |
71 if (!channel->RunMessagePipeEndpoint(system::Channel::kBootstrapEndpointId, | 72 if (!channel->RunMessagePipeEndpoint(system::Channel::kBootstrapEndpointId, |
72 system::Channel::kBootstrapEndpointId)) { | 73 system::Channel::kBootstrapEndpointId)) { |
73 // Currently, there's no reason for this to fail. | 74 // Currently, there's no reason for this to fail. |
74 NOTREACHED() << "Channel::RunMessagePipeEndpoint() failed"; | 75 NOTREACHED() << "Channel::RunMessagePipeEndpoint() failed"; |
75 return channel; | 76 return channel; |
76 } | 77 } |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 | 232 |
232 *platform_handle = | 233 *platform_handle = |
233 static_cast<system::PlatformHandleDispatcher*>(dispatcher.get()) | 234 static_cast<system::PlatformHandleDispatcher*>(dispatcher.get()) |
234 ->PassPlatformHandle() | 235 ->PassPlatformHandle() |
235 .Pass(); | 236 .Pass(); |
236 return MOJO_RESULT_OK; | 237 return MOJO_RESULT_OK; |
237 } | 238 } |
238 | 239 |
239 } // namespace embedder | 240 } // namespace embedder |
240 } // namespace mojo | 241 } // namespace mojo |
OLD | NEW |