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

Unified Diff: mojo/edk/embedder/embedder.cc

Issue 899993002: Add a thread-safe CreateChannel method to ChannelManager. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: 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
« no previous file with comments | « no previous file | mojo/edk/embedder/embedder_unittest.cc » ('j') | mojo/edk/system/channel_manager.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/embedder/embedder.cc
diff --git a/mojo/edk/embedder/embedder.cc b/mojo/edk/embedder/embedder.cc
index 1b3fabda47214e7522f37efdea0d4c47f95f096f..ef32a32597bc4cf20c757095ec74eda5b7fa30d1 100644
--- a/mojo/edk/embedder/embedder.cc
+++ b/mojo/edk/embedder/embedder.cc
@@ -47,26 +47,6 @@ system::ChannelId MakeChannelId() {
return static_cast<system::ChannelId>(-new_counter_value);
}
-// Helper for |CreateChannel()|. Called on the channel creation thread.
-void CreateChannelHelper(
- ScopedPlatformHandle platform_handle,
- scoped_ptr<ChannelInfo> channel_info,
- scoped_refptr<system::ChannelEndpoint> channel_endpoint,
- DidCreateChannelCallback callback,
- scoped_refptr<base::TaskRunner> callback_thread_task_runner) {
- channel_info->channel_id = MakeChannelId();
- internal::g_channel_manager->CreateChannelOnIOThread(
- channel_info->channel_id, platform_handle.Pass(), channel_endpoint);
-
- // Hand the channel back to the embedder.
- if (callback_thread_task_runner) {
- callback_thread_task_runner->PostTask(
- FROM_HERE, base::Bind(callback, channel_info.release()));
- } else {
- callback.Run(channel_info.release());
- }
-}
-
} // namespace
namespace internal {
@@ -139,11 +119,12 @@ ScopedMessagePipeHandle CreateChannel(
scoped_ptr<ChannelInfo> channel_info(new ChannelInfo());
if (rv.is_valid()) {
- io_thread_task_runner->PostTask(
- FROM_HERE,
- base::Bind(&CreateChannelHelper, base::Passed(&platform_handle),
- base::Passed(&channel_info), channel_endpoint, callback,
- callback_thread_task_runner));
+ channel_info->channel_id = MakeChannelId();
+ internal::g_channel_manager->CreateChannel(
+ channel_info->channel_id, platform_handle.Pass(), channel_endpoint,
+ io_thread_task_runner,
+ base::Bind(callback, base::Unretained(channel_info.release())),
+ callback_thread_task_runner);
} else {
(callback_thread_task_runner ? callback_thread_task_runner
: io_thread_task_runner)
« no previous file with comments | « no previous file | mojo/edk/embedder/embedder_unittest.cc » ('j') | mojo/edk/system/channel_manager.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698