Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: content/browser/mojo/mojo_application_host.cc

Issue 236813002: Move Mojo channel initialization closer to IPC::Channel setup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more missing deps Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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 #include "content/browser/mojo/mojo_application_host.h"
6
7 #include "content/common/mojo/mojo_messages.h"
8 #include "content/public/browser/browser_thread.h"
9 #include "ipc/ipc_sender.h"
10 #include "mojo/embedder/platform_channel_pair.h"
11
12 namespace content {
13 namespace {
14
15 base::PlatformFile PlatformFileFromScopedPlatformHandle(
16 mojo::embedder::ScopedPlatformHandle handle) {
17 #if defined(OS_POSIX)
18 return handle.release().fd;
19 #elif defined(OS_WIN)
20 return handle.release().handle;
21 #endif
22 }
23
24 } // namespace
25
26 MojoApplicationHost::MojoApplicationHost() : did_activate_(false) {
27 }
28
29 MojoApplicationHost::~MojoApplicationHost() {
30 }
31
32 bool MojoApplicationHost::Init() {
33 DCHECK(shell_client_.is_null()) << "Already initialized!";
34
35 mojo::embedder::PlatformChannelPair channel_pair;
36
37 mojo::ScopedMessagePipeHandle message_pipe = channel_init_.Init(
38 PlatformFileFromScopedPlatformHandle(channel_pair.PassServerHandle()),
39 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
40 if (!message_pipe.is_valid())
41 return false;
42
43 // Forward this to the client once we know its process handle.
44 client_handle_ = channel_pair.PassClientHandle();
45
46 // TODO(darin): Provide a Shell implementation
47 shell_client_.reset(
48 mojo::ScopedShellClientHandle::From(message_pipe.Pass()), NULL);
49
50 return true;
51 }
52
53 bool MojoApplicationHost::Activate(IPC::Sender* sender,
54 base::ProcessHandle process_handle) {
55 DCHECK(!did_activate_);
56 DCHECK(client_handle_.is_valid());
57
58 base::PlatformFile client_file =
59 PlatformFileFromScopedPlatformHandle(client_handle_.Pass());
60 did_activate_ = sender->Send(new MojoMsg_Activate(
61 IPC::GetFileHandleForProcess(client_file, process_handle, true)));
62 return did_activate_;
63 }
64
65 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/mojo/mojo_application_host.h ('k') | content/browser/renderer_host/render_process_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698