Index: mojo/embedder/channel_init.h |
diff --git a/mojo/embedder/channel_init.h b/mojo/embedder/channel_init.h |
index d06332f1db68f45c91af2ef6de76160eb9c078b6..00337c5f0043a9befdfb67ed83d5e7962296f4e8 100644 |
--- a/mojo/embedder/channel_init.h |
+++ b/mojo/embedder/channel_init.h |
@@ -23,8 +23,8 @@ struct ChannelInfo; |
namespace embedder { |
-// ChannelInit handle creation (and destruction) of the mojo channel. It is |
-// expected that this class is created and destroyed on the main thread. |
+// |ChannelInit| handles creation (and destruction) of the Mojo channel. It is |
+// not thread-safe, but may be used on any single thread (with a |MessageLoop|). |
class MOJO_SYSTEM_IMPL_EXPORT ChannelInit { |
public: |
ChannelInit(); |
@@ -36,9 +36,14 @@ class MOJO_SYSTEM_IMPL_EXPORT ChannelInit { |
base::PlatformFile file, |
scoped_refptr<base::TaskRunner> io_thread_task_runner); |
+ // Notifies the channel that we (hence it) will soon be destroyed. |
+ void WillDestroySoon(); |
+ |
private: |
- // Invoked on the main thread once the channel has been established. |
- static void OnCreatedChannel(base::WeakPtr<ChannelInit> host, |
+ // Invoked on the thread on which this object lives once the channel has been |
+ // established. (This is a static method that takes a weak pointer to self, |
+ // since we want to destroy the channel even if we're destroyed.) |
+ static void OnCreatedChannel(base::WeakPtr<ChannelInit> self, |
scoped_refptr<base::TaskRunner> io_thread, |
embedder::ChannelInfo* channel); |