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

Unified Diff: content/common/mojo/mojo_channel_init.h

Issue 195993010: Adds the ability for the renderer to create the mojo channel (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use_mojo Created 6 years, 9 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 | « content/common/mojo/OWNERS ('k') | content/common/mojo/mojo_channel_init.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/mojo/mojo_channel_init.h
diff --git a/content/common/mojo/mojo_channel_init.h b/content/common/mojo/mojo_channel_init.h
new file mode 100644
index 0000000000000000000000000000000000000000..56c62304c5567fdbee29f9ccc74bcdb5e99cacf1
--- /dev/null
+++ b/content/common/mojo/mojo_channel_init.h
@@ -0,0 +1,72 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_COMMON_MOJO_MOJO_CHANNEL_INIT_H_
+#define CONTENT_COMMON_MOJO_MOJO_CHANNEL_INIT_H_
+
+#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
+#include "base/platform_file.h"
+#include "content/common/content_export.h"
+#include "mojo/public/system/core_cpp.h"
+
+namespace base {
+class MessageLoopProxy;
+class TaskRunner;
+}
+
+namespace mojo {
+namespace embedder {
+struct ChannelInfo;
+}
+}
+
+namespace content {
+
+// MojoChannelInit handle creation (and destruction) of the mojo channel. It is
+// expected that this class is created and destroyed on the main thread.
+class CONTENT_EXPORT MojoChannelInit {
+ public:
+ MojoChannelInit();
+ ~MojoChannelInit();
+
+ // Inits the channel. This takes ownership of |file|.
+ void Init(base::PlatformFile file,
+ scoped_refptr<base::TaskRunner> io_thread_task_runner);
+
+ bool is_handle_valid() const { return bootstrap_message_pipe_.is_valid(); }
+
+ private:
+ // Invoked on the IO thread once the channel has been established.
+ static void OnCreatedChannelOnIOThread(
+ base::WeakPtr<MojoChannelInit> host,
+ scoped_refptr<base::TaskRunner> main_thread,
+ scoped_refptr<base::TaskRunner> io_thread,
+ mojo::embedder::ChannelInfo* channel);
+
+ // Invoked on the main thread once the channel has been established.
+ static void OnCreatedChannelOnMainThread(
+ base::WeakPtr<MojoChannelInit> host,
+ scoped_refptr<base::TaskRunner> io_thread,
+ mojo::embedder::ChannelInfo* channel);
+
+ // Thread where this object lives.
+ scoped_refptr<base::TaskRunner> main_thread_;
+
+ scoped_refptr<base::TaskRunner> io_thread_task_runner_;
+
+ // If non-null the channel has been established.
+ mojo::embedder::ChannelInfo* channel_info_;
+
+ // The handle from channel creation.
+ mojo::ScopedHandle bootstrap_message_pipe_;
+
+ base::WeakPtrFactory<MojoChannelInit> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(MojoChannelInit);
+};
+
+} // namespace content
+
+#endif // CONTENT_COMMON_MOJO_MOJO_CHANNEL_INIT_H_
« no previous file with comments | « content/common/mojo/OWNERS ('k') | content/common/mojo/mojo_channel_init.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698