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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 166 |
167 channel_info->channel->Shutdown(); | 167 channel_info->channel->Shutdown(); |
168 delete channel_info; | 168 delete channel_info; |
169 } | 169 } |
170 | 170 |
171 // TODO(vtl): Write tests for this. | 171 // TODO(vtl): Write tests for this. |
172 void DestroyChannel(ChannelInfo* channel_info) { | 172 void DestroyChannel(ChannelInfo* channel_info) { |
173 DCHECK(channel_info); | 173 DCHECK(channel_info); |
174 DCHECK(channel_info->io_thread_task_runner); | 174 DCHECK(channel_info->io_thread_task_runner); |
175 | 175 |
| 176 if (!channel_info->channel) { |
| 177 // Presumably, |Init()| on the channel failed. |
| 178 return; |
| 179 } |
| 180 |
| 181 channel_info->channel->WillShutdownSoon(); |
176 channel_info->io_thread_task_runner->PostTask( | 182 channel_info->io_thread_task_runner->PostTask( |
177 FROM_HERE, base::Bind(&DestroyChannelOnIOThread, channel_info)); | 183 FROM_HERE, base::Bind(&DestroyChannelOnIOThread, channel_info)); |
178 } | 184 } |
179 | 185 |
| 186 void WillDestroyChannelSoon(ChannelInfo* channel_info) { |
| 187 DCHECK(channel_info); |
| 188 channel_info->channel->WillShutdownSoon(); |
| 189 } |
| 190 |
180 MojoResult CreatePlatformHandleWrapper( | 191 MojoResult CreatePlatformHandleWrapper( |
181 ScopedPlatformHandle platform_handle, | 192 ScopedPlatformHandle platform_handle, |
182 MojoHandle* platform_handle_wrapper_handle) { | 193 MojoHandle* platform_handle_wrapper_handle) { |
183 DCHECK(platform_handle_wrapper_handle); | 194 DCHECK(platform_handle_wrapper_handle); |
184 | 195 |
185 scoped_refptr<system::Dispatcher> dispatcher( | 196 scoped_refptr<system::Dispatcher> dispatcher( |
186 new system::PlatformHandleDispatcher(platform_handle.Pass())); | 197 new system::PlatformHandleDispatcher(platform_handle.Pass())); |
187 | 198 |
188 system::Core* core = system::entrypoints::GetCore(); | 199 system::Core* core = system::entrypoints::GetCore(); |
189 DCHECK(core); | 200 DCHECK(core); |
(...skipping 24 matching lines...) Expand all Loading... |
214 | 225 |
215 *platform_handle = | 226 *platform_handle = |
216 static_cast<system::PlatformHandleDispatcher*>(dispatcher.get()) | 227 static_cast<system::PlatformHandleDispatcher*>(dispatcher.get()) |
217 ->PassPlatformHandle() | 228 ->PassPlatformHandle() |
218 .Pass(); | 229 .Pass(); |
219 return MOJO_RESULT_OK; | 230 return MOJO_RESULT_OK; |
220 } | 231 } |
221 | 232 |
222 } // namespace embedder | 233 } // namespace embedder |
223 } // namespace mojo | 234 } // namespace mojo |
OLD | NEW |