summaryrefslogtreecommitdiffstats
path: root/mojo/common
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-23 18:36:44 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-23 18:36:44 +0000
commit1a8abcd89ed65e236433e081c72aee0336782e19 (patch)
tree1783ead2c39dfe00e6755f08b4ec432da49c3c46 /mojo/common
parentb682464d884a69481d16179f66f463bf2702bb5e (diff)
downloadchromium_src-1a8abcd89ed65e236433e081c72aee0336782e19.zip
chromium_src-1a8abcd89ed65e236433e081c72aee0336782e19.tar.gz
chromium_src-1a8abcd89ed65e236433e081c72aee0336782e19.tar.bz2
Move Mojo channel initialization closer to IPC::Channel setup
This CL introduces two new content classes: - MojoApplicationHost encapsulates what's needed to host a Mojo App using Chrome IPC to bootstrap. - MojoApplication represents what's needed to be a Mojo App using Chrome IPC to bootstrap. The RenderProcess and RenderProcessHost interfaces are replaced with WebUISetup and WebUISetupClient interfaces. This way the interface is more specific to the service of setting up WebUI. WebUISetupClient is empty and uninteresting. RenderProcessHostImpl no longer deals with WebUI setup. That is all done directly by RenderViewHostImpl by talking to the WebUISetup service. Service names get defined in content/common/mojo/mojo_service_names.{h,cc}. R=sky@chromium.org, tsepez@chromium.org Review URL: https://codereview.chromium.org/236813002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@265693 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo/common')
-rw-r--r--mojo/common/channel_init.cc (renamed from mojo/common/mojo_channel_init.cc)18
-rw-r--r--mojo/common/channel_init.h (renamed from mojo/common/mojo_channel_init.h)37
2 files changed, 24 insertions, 31 deletions
diff --git a/mojo/common/mojo_channel_init.cc b/mojo/common/channel_init.cc
index 96190f9..7eef2ae 100644
--- a/mojo/common/mojo_channel_init.cc
+++ b/mojo/common/channel_init.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "mojo/common/mojo_channel_init.h"
+#include "mojo/common/channel_init.h"
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
@@ -11,13 +11,12 @@
namespace mojo {
namespace common {
-MojoChannelInit::MojoChannelInit()
+ChannelInit::ChannelInit()
: channel_info_(NULL),
weak_factory_(this) {
}
-MojoChannelInit::~MojoChannelInit() {
- bootstrap_message_pipe_.reset();
+ChannelInit::~ChannelInit() {
if (channel_info_) {
io_thread_task_runner_->PostTask(
FROM_HERE,
@@ -25,23 +24,24 @@ MojoChannelInit::~MojoChannelInit() {
}
}
-void MojoChannelInit::Init(
+mojo::ScopedMessagePipeHandle ChannelInit::Init(
base::PlatformFile file,
scoped_refptr<base::TaskRunner> io_thread_task_runner) {
DCHECK(!io_thread_task_runner_.get()); // Should only init once.
io_thread_task_runner_ = io_thread_task_runner;
- bootstrap_message_pipe_ = mojo::embedder::CreateChannel(
+ mojo::ScopedMessagePipeHandle message_pipe = mojo::embedder::CreateChannel(
mojo::embedder::ScopedPlatformHandle(
mojo::embedder::PlatformHandle(file)),
io_thread_task_runner,
- base::Bind(&MojoChannelInit::OnCreatedChannel, weak_factory_.GetWeakPtr(),
+ base::Bind(&ChannelInit::OnCreatedChannel, weak_factory_.GetWeakPtr(),
io_thread_task_runner),
base::MessageLoop::current()->message_loop_proxy()).Pass();
+ return message_pipe.Pass();
}
// static
-void MojoChannelInit::OnCreatedChannel(
- base::WeakPtr<MojoChannelInit> host,
+void ChannelInit::OnCreatedChannel(
+ base::WeakPtr<ChannelInit> host,
scoped_refptr<base::TaskRunner> io_thread,
embedder::ChannelInfo* channel) {
// By the time we get here |host| may have been destroyed. If so, shutdown the
diff --git a/mojo/common/mojo_channel_init.h b/mojo/common/channel_init.h
index 8fa0094..ca134cb 100644
--- a/mojo/common/mojo_channel_init.h
+++ b/mojo/common/channel_init.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef MOJO_COMMON_MOJO_CHANNEL_INIT_H_
-#define MOJO_COMMON_MOJO_CHANNEL_INIT_H_
+#ifndef MOJO_COMMON_CHANNEL_INIT_H_
+#define MOJO_COMMON_CHANNEL_INIT_H_
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
@@ -23,27 +23,23 @@ struct ChannelInfo;
namespace common {
-// MojoChannelInit handle creation (and destruction) of the mojo channel. It is
+// ChannelInit handle creation (and destruction) of the mojo channel. It is
// expected that this class is created and destroyed on the main thread.
-class MOJO_COMMON_EXPORT MojoChannelInit {
+class MOJO_COMMON_EXPORT ChannelInit {
public:
- MojoChannelInit();
- ~MojoChannelInit();
+ ChannelInit();
+ ~ChannelInit();
- // 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(); }
-
- mojo::ScopedMessagePipeHandle bootstrap_message_pipe() {
- return bootstrap_message_pipe_.Pass();
- }
+ // Initializes the channel. This takes ownership of |file|. Returns the
+ // primordial MessagePipe for the channel.
+ mojo::ScopedMessagePipeHandle Init(
+ base::PlatformFile file,
+ scoped_refptr<base::TaskRunner> io_thread_task_runner);
private:
// Invoked on the main thread once the channel has been established.
static void OnCreatedChannel(
- base::WeakPtr<MojoChannelInit> host,
+ base::WeakPtr<ChannelInit> host,
scoped_refptr<base::TaskRunner> io_thread,
embedder::ChannelInfo* channel);
@@ -52,15 +48,12 @@ class MOJO_COMMON_EXPORT MojoChannelInit {
// If non-null the channel has been established.
embedder::ChannelInfo* channel_info_;
- // The handle from channel creation.
- mojo::ScopedMessagePipeHandle bootstrap_message_pipe_;
-
- base::WeakPtrFactory<MojoChannelInit> weak_factory_;
+ base::WeakPtrFactory<ChannelInit> weak_factory_;
- DISALLOW_COPY_AND_ASSIGN(MojoChannelInit);
+ DISALLOW_COPY_AND_ASSIGN(ChannelInit);
};
} // namespace common
} // namespace mojo
-#endif // MOJO_COMMON_MOJO_CHANNEL_INIT_H_
+#endif // MOJO_COMMON_CHANNEL_INIT_H_