Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Unified Diff: third_party/mojo/src/mojo/edk/system/channel_manager.cc

Issue 910883002: Update mojo sdk to rev 8af2ccff2eee4bfca1043015abee30482a030b30 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Apply 9f87aeadbda22441b7d469e596f7bd7d0d73e2a8 (https://codereview.chromium.org/908973002/) Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/mojo/src/mojo/edk/system/channel_manager.cc
diff --git a/third_party/mojo/src/mojo/edk/system/channel_manager.cc b/third_party/mojo/src/mojo/edk/system/channel_manager.cc
index c2fe8a5ceda15119968932bfee000707c3818910..634accc8353b8f07ffbe7388a54b6de6bee16869 100644
--- a/third_party/mojo/src/mojo/edk/system/channel_manager.cc
+++ b/third_party/mojo/src/mojo/edk/system/channel_manager.cc
@@ -9,6 +9,9 @@
#include "base/location.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/task_runner.h"
+#include "mojo/edk/system/channel.h"
+#include "mojo/edk/system/channel_endpoint.h"
+#include "mojo/edk/system/message_pipe_dispatcher.h"
namespace mojo {
namespace system {
@@ -38,33 +41,21 @@ ChannelManager::~ChannelManager() {
ShutdownChannelHelper(map_elem.second);
}
-void ChannelManager::CreateChannelOnIOThread(
+scoped_refptr<MessagePipeDispatcher> ChannelManager::CreateChannelOnIOThread(
ChannelId channel_id,
- embedder::ScopedPlatformHandle platform_handle,
- scoped_refptr<system::ChannelEndpoint> bootstrap_channel_endpoint) {
- DCHECK_NE(channel_id, kInvalidChannelId);
- DCHECK(platform_handle.is_valid());
- DCHECK(bootstrap_channel_endpoint);
-
- // Create and initialize a |system::Channel|.
- scoped_refptr<system::Channel> channel =
- new system::Channel(platform_support_);
- channel->Init(system::RawChannel::Create(platform_handle.Pass()));
- channel->SetBootstrapEndpoint(bootstrap_channel_endpoint);
-
- {
- base::AutoLock locker(lock_);
- CHECK(channel_infos_.find(channel_id) == channel_infos_.end());
- channel_infos_[channel_id] =
- ChannelInfo(channel, base::MessageLoopProxy::current());
- }
- channel->SetChannelManager(this);
+ embedder::ScopedPlatformHandle platform_handle) {
+ scoped_refptr<system::ChannelEndpoint> bootstrap_channel_endpoint;
+ scoped_refptr<system::MessagePipeDispatcher> dispatcher =
+ system::MessagePipeDispatcher::CreateRemoteMessagePipe(
+ &bootstrap_channel_endpoint);
+ CreateChannelOnIOThreadHelper(channel_id, platform_handle.Pass(),
+ bootstrap_channel_endpoint);
+ return dispatcher;
}
-void ChannelManager::CreateChannel(
+scoped_refptr<MessagePipeDispatcher> ChannelManager::CreateChannel(
ChannelId channel_id,
embedder::ScopedPlatformHandle platform_handle,
- scoped_refptr<system::ChannelEndpoint> bootstrap_channel_endpoint,
scoped_refptr<base::TaskRunner> io_thread_task_runner,
base::Closure callback,
scoped_refptr<base::TaskRunner> callback_thread_task_runner) {
@@ -72,12 +63,17 @@ void ChannelManager::CreateChannel(
DCHECK(!callback.is_null());
// (|callback_thread_task_runner| may be null.)
+ scoped_refptr<system::ChannelEndpoint> bootstrap_channel_endpoint;
+ scoped_refptr<system::MessagePipeDispatcher> dispatcher =
+ system::MessagePipeDispatcher::CreateRemoteMessagePipe(
+ &bootstrap_channel_endpoint);
io_thread_task_runner->PostTask(
FROM_HERE,
base::Bind(&ChannelManager::CreateChannelHelper, base::Unretained(this),
channel_id, base::Passed(&platform_handle),
bootstrap_channel_endpoint, callback,
callback_thread_task_runner));
+ return dispatcher;
}
scoped_refptr<Channel> ChannelManager::GetChannel(ChannelId channel_id) const {
@@ -103,14 +99,37 @@ void ChannelManager::ShutdownChannel(ChannelId channel_id) {
ShutdownChannelHelper(channel_info);
}
+void ChannelManager::CreateChannelOnIOThreadHelper(
+ ChannelId channel_id,
+ embedder::ScopedPlatformHandle platform_handle,
+ scoped_refptr<system::ChannelEndpoint> bootstrap_channel_endpoint) {
+ DCHECK_NE(channel_id, kInvalidChannelId);
+ DCHECK(platform_handle.is_valid());
+ DCHECK(bootstrap_channel_endpoint);
+
+ // Create and initialize a |system::Channel|.
+ scoped_refptr<system::Channel> channel =
+ new system::Channel(platform_support_);
+ channel->Init(system::RawChannel::Create(platform_handle.Pass()));
+ channel->SetBootstrapEndpoint(bootstrap_channel_endpoint);
+
+ {
+ base::AutoLock locker(lock_);
+ CHECK(channel_infos_.find(channel_id) == channel_infos_.end());
+ channel_infos_[channel_id] =
+ ChannelInfo(channel, base::MessageLoopProxy::current());
+ }
+ channel->SetChannelManager(this);
+}
+
void ChannelManager::CreateChannelHelper(
ChannelId channel_id,
embedder::ScopedPlatformHandle platform_handle,
scoped_refptr<system::ChannelEndpoint> bootstrap_channel_endpoint,
base::Closure callback,
scoped_refptr<base::TaskRunner> callback_thread_task_runner) {
- CreateChannelOnIOThread(channel_id, platform_handle.Pass(),
- bootstrap_channel_endpoint);
+ CreateChannelOnIOThreadHelper(channel_id, platform_handle.Pass(),
+ bootstrap_channel_endpoint);
if (callback_thread_task_runner)
callback_thread_task_runner->PostTask(FROM_HERE, callback);
else

Powered by Google App Engine
This is Rietveld 408576698