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

Side by Side Diff: ipc/ipc_channel_factory.cc

Issue 2047233002: Support using a Mojo message pipe in a ChannelHandle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-handle-attachemnt-public-api
Patch Set: comments Created 4 years, 5 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 | « ipc/ipc_channel_common.cc ('k') | ipc/ipc_channel_handle.h » ('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 2014 The Chromium Authors. All rights reserved. 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 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 "base/macros.h" 5 #include "base/macros.h"
6 #include "base/memory/ptr_util.h" 6 #include "base/memory/ptr_util.h"
7 #include "ipc/ipc_channel_factory.h" 7 #include "ipc/ipc_channel_factory.h"
8 #include "ipc/ipc_channel_mojo.h"
8 9
9 namespace IPC { 10 namespace IPC {
10 11
11 namespace { 12 namespace {
12 13
13 class PlatformChannelFactory : public ChannelFactory { 14 class PlatformChannelFactory : public ChannelFactory {
14 public: 15 public:
15 PlatformChannelFactory(ChannelHandle handle, Channel::Mode mode) 16 PlatformChannelFactory(ChannelHandle handle, Channel::Mode mode)
16 : handle_(handle), mode_(mode) {} 17 : handle_(handle), mode_(mode) {}
17 18
18 std::string GetName() const override { 19 std::string GetName() const override {
19 return handle_.name; 20 return handle_.name;
20 } 21 }
21 22
22 std::unique_ptr<Channel> BuildChannel(Listener* listener) override { 23 std::unique_ptr<Channel> BuildChannel(Listener* listener) override {
24 if (handle_.mojo_handle.is_valid()) {
25 return ChannelMojo::Create(
26 mojo::ScopedMessagePipeHandle(handle_.mojo_handle), mode_, listener);
27 }
23 return Channel::Create(handle_, mode_, listener); 28 return Channel::Create(handle_, mode_, listener);
24 } 29 }
25 30
26 private: 31 private:
27 ChannelHandle handle_; 32 ChannelHandle handle_;
28 Channel::Mode mode_; 33 Channel::Mode mode_;
29 34
30 DISALLOW_COPY_AND_ASSIGN(PlatformChannelFactory); 35 DISALLOW_COPY_AND_ASSIGN(PlatformChannelFactory);
31 }; 36 };
32 37
33 } // namespace 38 } // namespace
34 39
35 // static 40 // static
36 std::unique_ptr<ChannelFactory> ChannelFactory::Create( 41 std::unique_ptr<ChannelFactory> ChannelFactory::Create(
37 const ChannelHandle& handle, 42 const ChannelHandle& handle,
38 Channel::Mode mode) { 43 Channel::Mode mode) {
39 return base::WrapUnique(new PlatformChannelFactory(handle, mode)); 44 return base::WrapUnique(new PlatformChannelFactory(handle, mode));
40 } 45 }
41 46
42 } // namespace IPC 47 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/ipc_channel_common.cc ('k') | ipc/ipc_channel_handle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698