summaryrefslogtreecommitdiffstats
path: root/mojo/shell/app_child_process_host.h
blob: 451fd7e68cc2f849424c84f3d033aed4d31d7951 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef SHELL_APP_CHILD_PROCESS_HOST_H_
#define SHELL_APP_CHILD_PROCESS_HOST_H_

#include <stdint.h>

#include "base/macros.h"
#include "mojo/edk/embedder/channel_info_forward.h"
#include "mojo/shell/app_child_process.mojom.h"
#include "mojo/shell/child_process_host.h"

namespace mojo {
namespace shell {

// A subclass of |ChildProcessHost| to host an app child process, which runs a
// single app (loaded from the file system).
//
// Note: After |Start()|, |StartApp| must be called and this object must
// remained alive until the |on_app_complete| callback is called.
class AppChildProcessHost : public ChildProcessHost {
 public:
  explicit AppChildProcessHost(Context* context);
  ~AppChildProcessHost() override;

  // See |AppChildController|:
  void StartApp(const String& app_path,
                bool clean_app_path,
                InterfaceRequest<Application> application_request,
                const AppChildController::StartAppCallback& on_app_complete);
  void ExitNow(int32_t exit_code);

  // |ChildProcessHost| methods:
  void WillStart() override;
  void DidStart(bool success) override;

 private:
  // Callback for |embedder::CreateChannel()|.
  void DidCreateChannel(embedder::ChannelInfo* channel_info);

  void AppCompleted(int32_t result);

  AppChildControllerPtr controller_;
  embedder::ChannelInfo* channel_info_;
  AppChildController::StartAppCallback on_app_complete_;

  DISALLOW_COPY_AND_ASSIGN(AppChildProcessHost);
};

}  // namespace shell
}  // namespace mojo

#endif  // SHELL_APP_CHILD_PROCESS_HOST_H_