| 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/edk/system/channel_manager.h" | 5 #include "mojo/edk/system/channel_manager.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 void ChannelManager::Shutdown( | 72 void ChannelManager::Shutdown( |
| 73 const base::Closure& callback, | 73 const base::Closure& callback, |
| 74 scoped_refptr<base::TaskRunner> callback_thread_task_runner) { | 74 scoped_refptr<base::TaskRunner> callback_thread_task_runner) { |
| 75 bool ok = io_thread_task_runner_->PostTask( | 75 bool ok = io_thread_task_runner_->PostTask( |
| 76 FROM_HERE, | 76 FROM_HERE, |
| 77 base::Bind(&ChannelManager::ShutdownHelper, base::Unretained(this), | 77 base::Bind(&ChannelManager::ShutdownHelper, base::Unretained(this), |
| 78 callback, callback_thread_task_runner)); | 78 callback, callback_thread_task_runner)); |
| 79 DCHECK(ok); | 79 DCHECK(ok); |
| 80 } | 80 } |
| 81 | 81 |
| 82 scoped_refptr<MessagePipeDispatcher> ChannelManager::CreateChannelOnIOThread( | 82 RefPtr<MessagePipeDispatcher> ChannelManager::CreateChannelOnIOThread( |
| 83 ChannelId channel_id, | 83 ChannelId channel_id, |
| 84 embedder::ScopedPlatformHandle platform_handle) { | 84 embedder::ScopedPlatformHandle platform_handle) { |
| 85 RefPtr<ChannelEndpoint> bootstrap_channel_endpoint; | 85 RefPtr<ChannelEndpoint> bootstrap_channel_endpoint; |
| 86 scoped_refptr<MessagePipeDispatcher> dispatcher = | 86 auto dispatcher = MessagePipeDispatcher::CreateRemoteMessagePipe( |
| 87 MessagePipeDispatcher::CreateRemoteMessagePipe( | 87 &bootstrap_channel_endpoint); |
| 88 &bootstrap_channel_endpoint); | |
| 89 CreateChannelOnIOThreadHelper(channel_id, platform_handle.Pass(), | 88 CreateChannelOnIOThreadHelper(channel_id, platform_handle.Pass(), |
| 90 std::move(bootstrap_channel_endpoint)); | 89 std::move(bootstrap_channel_endpoint)); |
| 91 return dispatcher; | 90 return dispatcher; |
| 92 } | 91 } |
| 93 | 92 |
| 94 RefPtr<Channel> ChannelManager::CreateChannelWithoutBootstrapOnIOThread( | 93 RefPtr<Channel> ChannelManager::CreateChannelWithoutBootstrapOnIOThread( |
| 95 ChannelId channel_id, | 94 ChannelId channel_id, |
| 96 embedder::ScopedPlatformHandle platform_handle) { | 95 embedder::ScopedPlatformHandle platform_handle) { |
| 97 return CreateChannelOnIOThreadHelper(channel_id, platform_handle.Pass(), | 96 return CreateChannelOnIOThreadHelper(channel_id, platform_handle.Pass(), |
| 98 nullptr); | 97 nullptr); |
| 99 } | 98 } |
| 100 | 99 |
| 101 scoped_refptr<MessagePipeDispatcher> ChannelManager::CreateChannel( | 100 RefPtr<MessagePipeDispatcher> ChannelManager::CreateChannel( |
| 102 ChannelId channel_id, | 101 ChannelId channel_id, |
| 103 embedder::ScopedPlatformHandle platform_handle, | 102 embedder::ScopedPlatformHandle platform_handle, |
| 104 const base::Closure& callback, | 103 const base::Closure& callback, |
| 105 scoped_refptr<base::TaskRunner> callback_thread_task_runner) { | 104 scoped_refptr<base::TaskRunner> callback_thread_task_runner) { |
| 106 DCHECK(!callback.is_null()); | 105 DCHECK(!callback.is_null()); |
| 107 // (|callback_thread_task_runner| may be null.) | 106 // (|callback_thread_task_runner| may be null.) |
| 108 | 107 |
| 109 RefPtr<ChannelEndpoint> bootstrap_channel_endpoint; | 108 RefPtr<ChannelEndpoint> bootstrap_channel_endpoint; |
| 110 scoped_refptr<MessagePipeDispatcher> dispatcher = | 109 auto dispatcher = MessagePipeDispatcher::CreateRemoteMessagePipe( |
| 111 MessagePipeDispatcher::CreateRemoteMessagePipe( | 110 &bootstrap_channel_endpoint); |
| 112 &bootstrap_channel_endpoint); | |
| 113 bool ok = io_thread_task_runner_->PostTask( | 111 bool ok = io_thread_task_runner_->PostTask( |
| 114 FROM_HERE, | 112 FROM_HERE, |
| 115 base::Bind(&ChannelManager::CreateChannelHelper, base::Unretained(this), | 113 base::Bind(&ChannelManager::CreateChannelHelper, base::Unretained(this), |
| 116 channel_id, base::Passed(&platform_handle), | 114 channel_id, base::Passed(&platform_handle), |
| 117 base::Passed(&bootstrap_channel_endpoint), callback, | 115 base::Passed(&bootstrap_channel_endpoint), callback, |
| 118 callback_thread_task_runner)); | 116 callback_thread_task_runner)); |
| 119 DCHECK(ok); | 117 DCHECK(ok); |
| 120 return dispatcher; | 118 return dispatcher; |
| 121 } | 119 } |
| 122 | 120 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 if (callback_thread_task_runner) { | 205 if (callback_thread_task_runner) { |
| 208 bool ok = callback_thread_task_runner->PostTask(FROM_HERE, callback); | 206 bool ok = callback_thread_task_runner->PostTask(FROM_HERE, callback); |
| 209 DCHECK(ok); | 207 DCHECK(ok); |
| 210 } else { | 208 } else { |
| 211 callback.Run(); | 209 callback.Run(); |
| 212 } | 210 } |
| 213 } | 211 } |
| 214 | 212 |
| 215 } // namespace system | 213 } // namespace system |
| 216 } // namespace mojo | 214 } // namespace mojo |
| OLD | NEW |