Upstream version 6.35.121.0
[platform/framework/web/crosswalk.git] / src / mojo / shell / app_child_process_host.h
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.
4
5 #ifndef MOJO_SHELL_APP_CHILD_PROCESS_HOST_H_
6 #define MOJO_SHELL_APP_CHILD_PROCESS_HOST_H_
7
8 #include "base/macros.h"
9 #include "mojo/public/bindings/remote_ptr.h"
10 #include "mojo/shell/app_child_process.mojom.h"
11 #include "mojo/shell/child_process_host.h"
12
13 namespace mojo {
14
15 namespace embedder {
16 struct ChannelInfo;
17 }
18
19 namespace shell {
20
21 // A subclass of |ChildProcessHost| to host a |TYPE_APP| child process, which
22 // runs a single app (loaded from the file system).
23 //
24 // Note: After |Start()|, this object must remain alive until the controller
25 // client's |AppCompleted()| is called.
26 class AppChildProcessHost : public ChildProcessHost,
27                             public ChildProcessHost::Delegate {
28  public:
29   AppChildProcessHost(Context* context,
30                       mojo_shell::AppChildControllerClient* controller_client);
31   virtual ~AppChildProcessHost();
32
33   mojo_shell::AppChildController* controller() {
34     return controller_.get();
35   }
36
37  private:
38   // |ChildProcessHost::Delegate| methods:
39   virtual void WillStart() OVERRIDE;
40   virtual void DidStart(bool success) OVERRIDE;
41
42   // Callback for |embedder::CreateChannel()|.
43   void DidCreateChannel(embedder::ChannelInfo* channel_info);
44
45   mojo_shell::AppChildControllerClient* const controller_client_;
46
47   RemotePtr<mojo_shell::AppChildController> controller_;
48   embedder::ChannelInfo* channel_info_;
49
50   DISALLOW_COPY_AND_ASSIGN(AppChildProcessHost);
51 };
52
53 }  // namespace shell
54 }  // namespace mojo
55
56 #endif  // MOJO_SHELL_APP_CHILD_PROCESS_HOST_H_