Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / content / browser / mojo / mojo_application_host.h
blob27a43f89c2dcd0db5c3df11a8d22fa046a3609c4
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/process/process_handle.h"
9 #include "content/common/mojo/service_registry_impl.h"
10 #include "mojo/embedder/channel_init.h"
11 #include "mojo/embedder/scoped_platform_handle.h"
13 namespace IPC {
14 class Sender;
17 namespace content {
19 // MojoApplicationHost represents the code needed on the browser side to setup
20 // a child process as a Mojo application via Chrome IPC. The child process
21 // should use MojoApplication to handle messages generated by an instance of
22 // MojoApplicationHost. MojoApplicationHost makes the ServiceRegistry interface
23 // available so that child-provided services can be invoked.
24 class MojoApplicationHost {
25 public:
26 MojoApplicationHost();
27 virtual ~MojoApplicationHost();
29 // Two-phase initialization:
30 // 1- Init makes service_registry() available synchronously.
31 // 2- Activate establishes the actual connection to the peer process.
32 bool Init();
33 bool Activate(IPC::Sender* sender, base::ProcessHandle process_handle);
35 void WillDestroySoon();
37 bool did_activate() const { return did_activate_; }
39 ServiceRegistry* service_registry() { return &service_registry_; }
41 private:
42 mojo::embedder::ChannelInit channel_init_;
43 mojo::embedder::ScopedPlatformHandle client_handle_;
45 bool did_activate_;
47 ServiceRegistryImpl service_registry_;
49 DISALLOW_COPY_AND_ASSIGN(MojoApplicationHost);
52 } // namespace content
54 #endif // CONTENT_BROWSER_MOJO_MOJO_APPLICATION_HOST_H_