ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / content / child / mojo / mojo_application.cc
blobf896dc69a49dd7526ff8a1d277aaa84c92f21a98
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 #include "content/child/mojo/mojo_application.h"
7 #include "content/child/child_process.h"
8 #include "content/common/application_setup.mojom.h"
9 #include "content/common/mojo/channel_init.h"
10 #include "content/common/mojo/mojo_messages.h"
11 #include "ipc/ipc_message.h"
12 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_ptr.h"
14 namespace content {
16 MojoApplication::MojoApplication() {
19 MojoApplication::~MojoApplication() {
22 bool MojoApplication::OnMessageReceived(const IPC::Message& msg) {
23 bool handled = true;
24 IPC_BEGIN_MESSAGE_MAP(MojoApplication, msg)
25 IPC_MESSAGE_HANDLER(MojoMsg_Activate, OnActivate)
26 IPC_MESSAGE_UNHANDLED(handled = false)
27 IPC_END_MESSAGE_MAP()
28 return handled;
31 void MojoApplication::OnActivate(
32 const IPC::PlatformFileForTransit& file) {
33 #if defined(OS_POSIX)
34 base::PlatformFile handle = file.fd;
35 #elif defined(OS_WIN)
36 base::PlatformFile handle = file;
37 #endif
38 scoped_refptr<base::TaskRunner> io_task_runner =
39 ChannelInit::GetSingleProcessIOTaskRunner();
40 if (!io_task_runner) {
41 io_task_runner = ChildProcess::current()->io_message_loop_proxy();
43 DCHECK(io_task_runner);
45 mojo::ScopedMessagePipeHandle message_pipe =
46 channel_init_.Init(handle, io_task_runner);
47 DCHECK(message_pipe.is_valid());
49 ApplicationSetupPtr application_setup;
50 application_setup.Bind(message_pipe.Pass());
52 mojo::ServiceProviderPtr services;
53 mojo::ServiceProviderPtr exposed_services;
54 service_registry_.Bind(GetProxy(&exposed_services));
55 application_setup->ExchangeServiceProviders(GetProxy(&services),
56 exposed_services.Pass());
57 service_registry_.BindRemoteServiceProvider(services.Pass());
60 } // namespace content