summaryrefslogtreecommitdiff
path: root/chromium/content/child/mojo/mojo_application.h
blob: 5c207f2ccd56ddc778b526a12b96ebf5cc0b8265 (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
// 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 CONTENT_CHILD_MOJO_MOJO_APPLICATION_H_
#define CONTENT_CHILD_MOJO_MOJO_APPLICATION_H_

#include "content/common/mojo/channel_init.h"
#include "content/common/mojo/service_registry_impl.h"
#include "ipc/ipc_platform_file.h"

namespace base {
class SequencedTaskRunner;
}

namespace IPC {
class Message;
}

namespace content {

// MojoApplication represents the code needed to setup a child process as a
// Mojo application via Chrome IPC. Instantiate MojoApplication and call its
// OnMessageReceived method to give it a shot at handling Chrome IPC messages.
// It makes the ServiceRegistry interface available.
class MojoApplication {
 public:
  explicit MojoApplication(
      scoped_refptr<base::SequencedTaskRunner> io_task_runner);
  virtual ~MojoApplication();

  bool OnMessageReceived(const IPC::Message& msg);

  ServiceRegistry* service_registry() { return &service_registry_; }

 private:
  void OnActivate(const IPC::PlatformFileForTransit& file);

  scoped_refptr<base::SequencedTaskRunner> io_task_runner_;

  ChannelInit channel_init_;

  ServiceRegistryImpl service_registry_;

  DISALLOW_COPY_AND_ASSIGN(MojoApplication);
};

}  // namespace content

#endif  // CONTENT_CHILD_MOJO_MOJO_APPLICATION_H_