Blink roll 25b6bd3a7a131ffe68d809546ad1a20707915cdc:3a503f41ae42e5b79cfcd2ff10e65afde...
[chromium-blink-merge.git] / content / browser / mojo / mojo_application_host.h
blob1825b3eab55f2444c3e7dddceb7ebee4cc8b2885
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_MOJO_MOJO_APPLICATION_HOST_H_
6 #define CONTENT_BROWSER_MOJO_MOJO_APPLICATION_HOST_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/process/process_handle.h"
10 #include "content/common/mojo/service_registry_impl.h"
11 #include "mojo/edk/embedder/channel_init.h"
12 #include "mojo/edk/embedder/scoped_platform_handle.h"
14 #if defined(OS_ANDROID)
15 #include "content/browser/mojo/service_registry_android.h"
16 #endif
18 namespace IPC {
19 class Sender;
22 namespace content {
24 // MojoApplicationHost represents the code needed on the browser side to setup
25 // a child process as a Mojo application via Chrome IPC. The child process
26 // should use MojoApplication to handle messages generated by an instance of
27 // MojoApplicationHost. MojoApplicationHost makes the ServiceRegistry interface
28 // available so that child-provided services can be invoked.
29 class MojoApplicationHost {
30 public:
31 MojoApplicationHost();
32 virtual ~MojoApplicationHost();
34 // Two-phase initialization:
35 // 1- Init makes service_registry() available synchronously.
36 // 2- Activate establishes the actual connection to the peer process.
37 bool Init();
38 void Activate(IPC::Sender* sender, base::ProcessHandle process_handle);
40 void WillDestroySoon();
42 ServiceRegistry* service_registry() { return &service_registry_; }
44 private:
45 mojo::embedder::ChannelInit channel_init_;
46 mojo::embedder::ScopedPlatformHandle client_handle_;
48 bool did_activate_;
50 ServiceRegistryImpl service_registry_;
52 #if defined(OS_ANDROID)
53 scoped_ptr<ServiceRegistryAndroid> service_registry_android_;
54 #endif
56 DISALLOW_COPY_AND_ASSIGN(MojoApplicationHost);
59 } // namespace content
61 #endif // CONTENT_BROWSER_MOJO_MOJO_APPLICATION_HOST_H_