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

Unified Diff: mojo/edk/system/channel_manager.h

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 | « mojo/edk/embedder/embedder_unittest.cc ('k') | mojo/edk/system/channel_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/channel_manager.h
diff --git a/mojo/edk/system/channel_manager.h b/mojo/edk/system/channel_manager.h
index 122c456a4abc69576ca4d3f20df6d15f2a0fce79..35a4f27446ce99f350c4c5abd36500fa0afbb457 100644
--- a/mojo/edk/system/channel_manager.h
+++ b/mojo/edk/system/channel_manager.h
@@ -11,11 +11,14 @@
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/synchronization/lock.h"
-#include "base/task_runner.h"
#include "mojo/edk/embedder/scoped_platform_handle.h"
#include "mojo/edk/system/channel.h"
#include "mojo/edk/system/channel_info.h"
+namespace base {
+class TaskRunner;
+}
+
namespace mojo {
namespace embedder {
@@ -46,13 +49,31 @@ class MOJO_SYSTEM_IMPL_EXPORT ChannelManager {
// TODO(vtl): Currently, this should be called on any I/O thread (which will
// become the new channel's "channel thread"). Eventually, the channel manager
// will have an assigned I/O thread, on which this must be called.
- // TODO(vtl): Maybe this should return a message pipe dispatcher (for the
+ // TODO(vtl): Probably this should return a message pipe dispatcher (for the
// bootstrap message pipe) instead.
void CreateChannelOnIOThread(
ChannelId channel_id,
embedder::ScopedPlatformHandle platform_handle,
scoped_refptr<system::ChannelEndpoint> bootstrap_channel_endpoint);
+ // Like |CreateChannelOnIOThread()|, but may be called from any thread. On
+ // completion, will call |callback| ("on" |io_thread_task_runner| if
+ // |callback_thread_task_runner| is null else by posting to using
yzshen1 2015/02/04 21:21:06 nit: using is not needed.
+ // |callback_thread_task_runner|). Note: This will always post a task to the
+ // I/O thread, even if |io_thread_task_runner| is the task runner for the
+ // current thread.
+ // TODO(vtl): The |io_thread_task_runner| argument is temporary (we should use
+ // the channel manager's I/O thread).
+ // TODO(vtl): Probably this should return a message pipe dispatcher (for the
+ // bootstrap message pipe) instead.
+ void 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);
+
// Gets the |Channel| with the given ID (which must exist).
scoped_refptr<Channel> GetChannel(ChannelId channel_id) const;
@@ -71,6 +92,13 @@ class MOJO_SYSTEM_IMPL_EXPORT ChannelManager {
void ShutdownChannel(ChannelId channel_id);
private:
+ void 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);
+
embedder::PlatformSupport* const platform_support_;
// Note: |Channel| methods should not be called under |lock_|.
« no previous file with comments | « mojo/edk/embedder/embedder_unittest.cc ('k') | mojo/edk/system/channel_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698