OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "remoting/host/ipc_util.h" | 5 #include "remoting/host/ipc_util.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/files/file.h" | 9 #include "base/files/file.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "base/win/scoped_handle.h" | 14 #include "base/win/scoped_handle.h" |
15 #include "base/win/win_util.h" | 15 #include "base/win/win_util.h" |
| 16 #include "ipc/attachment_broker.h" |
16 #include "ipc/ipc_channel.h" | 17 #include "ipc/ipc_channel.h" |
17 #include "ipc/ipc_channel_proxy.h" | 18 #include "ipc/ipc_channel_proxy.h" |
18 #include "remoting/host/win/security_descriptor.h" | 19 #include "remoting/host/win/security_descriptor.h" |
19 | 20 |
20 using base::win::ScopedHandle; | 21 using base::win::ScopedHandle; |
21 | 22 |
22 namespace remoting { | 23 namespace remoting { |
23 | 24 |
24 // Pipe name prefix used by Chrome IPC channels to convert a channel name into | 25 // Pipe name prefix used by Chrome IPC channels to convert a channel name into |
25 // a pipe name. | 26 // a pipe name. |
(...skipping 23 matching lines...) Expand all Loading... |
49 // Generate a unique name for the channel. | 50 // Generate a unique name for the channel. |
50 std::string channel_name = IPC::Channel::GenerateUniqueRandomChannelID(); | 51 std::string channel_name = IPC::Channel::GenerateUniqueRandomChannelID(); |
51 | 52 |
52 // Create the server end of the channel. | 53 // Create the server end of the channel. |
53 ScopedHandle pipe; | 54 ScopedHandle pipe; |
54 if (!CreateIpcChannel(channel_name, security_descriptor, &pipe)) { | 55 if (!CreateIpcChannel(channel_name, security_descriptor, &pipe)) { |
55 return false; | 56 return false; |
56 } | 57 } |
57 | 58 |
58 // Wrap the pipe into an IPC channel. | 59 // Wrap the pipe into an IPC channel. |
59 std::unique_ptr<IPC::ChannelProxy> server = IPC::ChannelProxy::Create( | 60 std::unique_ptr<IPC::ChannelProxy> server( |
60 IPC::ChannelHandle(pipe.Get()), IPC::Channel::MODE_SERVER, listener, | 61 new IPC::ChannelProxy(listener, io_task_runner)); |
61 io_task_runner); | 62 IPC::AttachmentBroker::GetGlobal()->RegisterCommunicationChannel( |
| 63 server.get(), io_task_runner); |
| 64 server->Init(IPC::ChannelHandle(pipe.Get()), IPC::Channel::MODE_SERVER, |
| 65 true); |
62 | 66 |
63 // Convert the channel name to the pipe name. | 67 // Convert the channel name to the pipe name. |
64 std::string pipe_name(kChromePipeNamePrefix); | 68 std::string pipe_name(kChromePipeNamePrefix); |
65 pipe_name.append(channel_name); | 69 pipe_name.append(channel_name); |
66 | 70 |
67 SECURITY_ATTRIBUTES security_attributes = {0}; | 71 SECURITY_ATTRIBUTES security_attributes = {0}; |
68 security_attributes.nLength = sizeof(security_attributes); | 72 security_attributes.nLength = sizeof(security_attributes); |
69 security_attributes.lpSecurityDescriptor = nullptr; | 73 security_attributes.lpSecurityDescriptor = nullptr; |
70 security_attributes.bInheritHandle = TRUE; | 74 security_attributes.bInheritHandle = TRUE; |
71 | 75 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 PLOG(ERROR) | 130 PLOG(ERROR) |
127 << "Failed to create the server end of the Chromoting IPC channel"; | 131 << "Failed to create the server end of the Chromoting IPC channel"; |
128 return false; | 132 return false; |
129 } | 133 } |
130 | 134 |
131 *pipe_out = std::move(pipe); | 135 *pipe_out = std::move(pipe); |
132 return true; | 136 return true; |
133 } | 137 } |
134 | 138 |
135 } // namespace remoting | 139 } // namespace remoting |
OLD | NEW |