Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / content / child / mojo / mojo_application.h
blob5c207f2ccd56ddc778b526a12b96ebf5cc0b8265
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_CHILD_MOJO_MOJO_APPLICATION_H_
6 #define CONTENT_CHILD_MOJO_MOJO_APPLICATION_H_
8 #include "content/common/mojo/channel_init.h"
9 #include "content/common/mojo/service_registry_impl.h"
10 #include "ipc/ipc_platform_file.h"
12 namespace base {
13 class SequencedTaskRunner;
16 namespace IPC {
17 class Message;
20 namespace content {
22 // MojoApplication represents the code needed to setup a child process as a
23 // Mojo application via Chrome IPC. Instantiate MojoApplication and call its
24 // OnMessageReceived method to give it a shot at handling Chrome IPC messages.
25 // It makes the ServiceRegistry interface available.
26 class MojoApplication {
27 public:
28 explicit MojoApplication(
29 scoped_refptr<base::SequencedTaskRunner> io_task_runner);
30 virtual ~MojoApplication();
32 bool OnMessageReceived(const IPC::Message& msg);
34 ServiceRegistry* service_registry() { return &service_registry_; }
36 private:
37 void OnActivate(const IPC::PlatformFileForTransit& file);
39 scoped_refptr<base::SequencedTaskRunner> io_task_runner_;
41 ChannelInit channel_init_;
43 ServiceRegistryImpl service_registry_;
45 DISALLOW_COPY_AND_ASSIGN(MojoApplication);
48 } // namespace content
50 #endif // CONTENT_CHILD_MOJO_MOJO_APPLICATION_H_