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

Side by Side Diff: content/common/mojo/channel_init.cc

Issue 1676913002: [mojo] Delete third_party/mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: let's try that again Created 4 years, 10 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
« no previous file with comments | « content/common/mojo/channel_init.h ('k') | content/content.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/common/mojo/channel_init.h" 5 #include "content/common/mojo/channel_init.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/task_runner.h" 15 #include "base/task_runner.h"
16 #include "base/thread_task_runner_handle.h" 16 #include "base/thread_task_runner_handle.h"
17 #include "mojo/edk/embedder/embedder.h" 17 #include "mojo/edk/embedder/embedder.h"
18 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h"
19 18
20 namespace content { 19 namespace content {
21 20
22 ChannelInit::ChannelInit() : channel_info_(nullptr), weak_factory_(this) {} 21 ChannelInit::ChannelInit() {}
23 22
24 ChannelInit::~ChannelInit() { 23 ChannelInit::~ChannelInit() {}
25 if (channel_info_)
26 mojo::embedder::DestroyChannel(channel_info_,
27 base::Bind(&base::DoNothing), nullptr);
28 }
29 24
30 mojo::ScopedMessagePipeHandle ChannelInit::Init( 25 mojo::ScopedMessagePipeHandle ChannelInit::Init(
31 base::PlatformFile file, 26 base::PlatformFile file,
32 scoped_refptr<base::TaskRunner> io_thread_task_runner) { 27 scoped_refptr<base::TaskRunner> io_thread_task_runner) {
33 scoped_ptr<IPC::ScopedIPCSupport> ipc_support( 28 ipc_support_.reset(new IPC::ScopedIPCSupport(io_thread_task_runner));
34 new IPC::ScopedIPCSupport(io_thread_task_runner)); 29 return mojo::edk::CreateMessagePipe(
35 if (base::CommandLine::ForCurrentProcess()->HasSwitch("use-new-edk")) { 30 mojo::edk::ScopedPlatformHandle(mojo::edk::PlatformHandle(file)));
36 ipc_support_ = std::move(ipc_support);
37 return mojo::edk::CreateMessagePipe(
38 mojo::edk::ScopedPlatformHandle(mojo::edk::PlatformHandle(file)));
39 } else {
40 return mojo::embedder::CreateChannel(
41 mojo::embedder::ScopedPlatformHandle(
42 mojo::embedder::PlatformHandle(file)),
43 base::Bind(&ChannelInit::OnCreatedChannel, weak_factory_.GetWeakPtr(),
44 base::Passed(&ipc_support)),
45 base::ThreadTaskRunnerHandle::Get());
46 }
47 }
48
49 void ChannelInit::WillDestroySoon() {
50 if (channel_info_)
51 mojo::embedder::WillDestroyChannelSoon(channel_info_);
52 }
53
54 // static
55 void ChannelInit::OnCreatedChannel(
56 base::WeakPtr<ChannelInit> self,
57 scoped_ptr<IPC::ScopedIPCSupport> ipc_support,
58 mojo::embedder::ChannelInfo* channel) {
59 // If |self| was already destroyed, shut the channel down.
60 if (!self) {
61 mojo::embedder::DestroyChannel(channel,
62 base::Bind(&base::DoNothing), nullptr);
63 return;
64 }
65
66 DCHECK(!self->channel_info_);
67 self->channel_info_ = channel;
68 self->ipc_support_ = std::move(ipc_support);
69 } 31 }
70 32
71 } // namespace content 33 } // namespace content
OLDNEW
« no previous file with comments | « content/common/mojo/channel_init.h ('k') | content/content.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698