summaryrefslogtreecommitdiffstats
path: root/content/browser
diff options
context:
space:
mode:
authorrockot <rockot@chromium.org>2016-01-26 11:23:21 -0800
committerCommit bot <commit-bot@chromium.org>2016-01-26 19:24:14 +0000
commitce69a049f1b705b0bb3d7e61d31908dfc8d968b2 (patch)
tree75c84ddedf1da7935ca7c452cf93496ee1a9de6d /content/browser
parent8337dd27609c3aa4713b27cd1ffbb586fdab217f (diff)
downloadchromium_src-ce69a049f1b705b0bb3d7e61d31908dfc8d968b2.zip
chromium_src-ce69a049f1b705b0bb3d7e61d31908dfc8d968b2.tar.gz
chromium_src-ce69a049f1b705b0bb3d7e61d31908dfc8d968b2.tar.bz2
[mojo] Ports EDK
One Big CL to land the new EDK implementation based on Ports. BUG=577688 Review URL: https://codereview.chromium.org/1585493002 Cr-Commit-Position: refs/heads/master@{#371556}
Diffstat (limited to 'content/browser')
-rw-r--r--content/browser/mojo/mojo_application_host.cc25
-rw-r--r--content/browser/mojo/mojo_application_host.h6
2 files changed, 21 insertions, 10 deletions
diff --git a/content/browser/mojo/mojo_application_host.cc b/content/browser/mojo/mojo_application_host.cc
index 12895d5..1f568ef 100644
--- a/content/browser/mojo/mojo_application_host.cc
+++ b/content/browser/mojo/mojo_application_host.cc
@@ -50,7 +50,7 @@ class ApplicationSetupImpl : public ApplicationSetup {
} // namespace
MojoApplicationHost::MojoApplicationHost()
- : did_activate_(false) {
+ : did_activate_(false), weak_factory_(this) {
#if defined(OS_ANDROID)
service_registry_android_.reset(
new ServiceRegistryAndroid(&service_registry_));
@@ -74,18 +74,15 @@ bool MojoApplicationHost::Init() {
->task_runner();
}
- mojo::ScopedMessagePipeHandle message_pipe = channel_init_.Init(
- PlatformFileFromScopedPlatformHandle(channel_pair.PassServerHandle()),
- io_task_runner);
- if (!message_pipe.is_valid())
- return false;
-
// Forward this to the client once we know its process handle.
client_handle_ = channel_pair.PassClientHandle();
- application_setup_.reset(new ApplicationSetupImpl(
- &service_registry_,
- mojo::MakeRequest<ApplicationSetup>(std::move(message_pipe))));
+ channel_init_.Init(
+ PlatformFileFromScopedPlatformHandle(channel_pair.PassServerHandle()),
+ io_task_runner,
+ base::Bind(&MojoApplicationHost::OnMessagePipeCreated,
+ weak_factory_.GetWeakPtr()));
+
return true;
}
@@ -109,4 +106,12 @@ void MojoApplicationHost::OverrideIOTaskRunnerForTest(
io_task_runner_override_ = io_task_runner;
}
+void MojoApplicationHost::OnMessagePipeCreated(
+ mojo::ScopedMessagePipeHandle pipe) {
+ DCHECK(pipe.is_valid());
+ application_setup_.reset(new ApplicationSetupImpl(
+ &service_registry_,
+ mojo::MakeRequest<ApplicationSetup>(std::move(pipe))));
+}
+
} // namespace content
diff --git a/content/browser/mojo/mojo_application_host.h b/content/browser/mojo/mojo_application_host.h
index 0ed8ec9..82dcb64 100644
--- a/content/browser/mojo/mojo_application_host.h
+++ b/content/browser/mojo/mojo_application_host.h
@@ -7,11 +7,13 @@
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "base/process/process_handle.h"
#include "build/build_config.h"
#include "content/common/application_setup.mojom.h"
#include "content/common/mojo/channel_init.h"
#include "content/common/mojo/service_registry_impl.h"
+#include "mojo/public/cpp/system/message_pipe.h"
#include "third_party/mojo/src/mojo/edk/embedder/scoped_platform_handle.h"
#if defined(OS_ANDROID)
@@ -54,6 +56,8 @@ class CONTENT_EXPORT MojoApplicationHost {
scoped_refptr<base::TaskRunner> io_task_runner);
private:
+ void OnMessagePipeCreated(mojo::ScopedMessagePipeHandle pipe);
+
ChannelInit channel_init_;
mojo::embedder::ScopedPlatformHandle client_handle_;
@@ -68,6 +72,8 @@ class CONTENT_EXPORT MojoApplicationHost {
scoped_ptr<ServiceRegistryAndroid> service_registry_android_;
#endif
+ base::WeakPtrFactory<MojoApplicationHost> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(MojoApplicationHost);
};