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" |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 // Create and initialize a |system::Channel|. | 38 // Create and initialize a |system::Channel|. |
39 channel_info->channel = new system::Channel(); | 39 channel_info->channel = new system::Channel(); |
40 bool success = channel_info->channel->Init( | 40 bool success = channel_info->channel->Init( |
41 system::RawChannel::Create(platform_handle.Pass())); | 41 system::RawChannel::Create(platform_handle.Pass())); |
42 DCHECK(success); | 42 DCHECK(success); |
43 | 43 |
44 // Attach the message pipe endpoint. | 44 // Attach the message pipe endpoint. |
45 system::MessageInTransit::EndpointId endpoint_id = | 45 system::MessageInTransit::EndpointId endpoint_id = |
46 channel_info->channel->AttachMessagePipeEndpoint(message_pipe, 1); | 46 channel_info->channel->AttachMessagePipeEndpoint(message_pipe, 1); |
| 47 // We shouldn't get |kInvalidEndpointId| here -- since |CreateChannel()| is |
| 48 // responsible for the local endpoint, and won't close it. |
47 DCHECK_EQ(endpoint_id, system::Channel::kBootstrapEndpointId); | 49 DCHECK_EQ(endpoint_id, system::Channel::kBootstrapEndpointId); |
48 success = channel_info->channel->RunMessagePipeEndpoint( | 50 success = channel_info->channel->RunMessagePipeEndpoint( |
49 system::Channel::kBootstrapEndpointId, | 51 system::Channel::kBootstrapEndpointId, |
50 system::Channel::kBootstrapEndpointId); | 52 system::Channel::kBootstrapEndpointId); |
51 DCHECK(success); // This shouldn't fail. | 53 DCHECK(success); // This shouldn't fail. |
52 | 54 |
53 // Hand the channel back to the embedder. | 55 // Hand the channel back to the embedder. |
54 if (callback_thread_task_runner) { | 56 if (callback_thread_task_runner) { |
55 callback_thread_task_runner->PostTask(FROM_HERE, | 57 callback_thread_task_runner->PostTask(FROM_HERE, |
56 base::Bind(callback, | 58 base::Bind(callback, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 91 |
90 void DestroyChannelOnIOThread(ChannelInfo* channel_info) { | 92 void DestroyChannelOnIOThread(ChannelInfo* channel_info) { |
91 DCHECK(channel_info); | 93 DCHECK(channel_info); |
92 DCHECK(channel_info->channel.get()); | 94 DCHECK(channel_info->channel.get()); |
93 channel_info->channel->Shutdown(); | 95 channel_info->channel->Shutdown(); |
94 delete channel_info; | 96 delete channel_info; |
95 } | 97 } |
96 | 98 |
97 } // namespace embedder | 99 } // namespace embedder |
98 } // namespace mojo | 100 } // namespace mojo |
OLD | NEW |