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

Side by Side Diff: components/nacl/browser/nacl_process_host.cc

Issue 2151153002: Use ChannelMojo for NaCl IRT channels in non-sfi mode. Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-nacl-channel-mojo
Patch Set: rebase 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 | « no previous file | components/nacl/loader/nacl_listener.cc » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "components/nacl/browser/nacl_process_host.h" 5 #include "components/nacl/browser/nacl_process_host.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 CHECK(handle.socket.fd == -1 || handle.socket.fd != handle_.socket.fd); 247 CHECK(handle.socket.fd == -1 || handle.socket.fd != handle_.socket.fd);
248 #endif 248 #endif
249 CloseIfNecessary(); 249 CloseIfNecessary();
250 handle_ = handle; 250 handle_ = handle;
251 } 251 }
252 252
253 private: 253 private:
254 // Returns true if the given handle is closable automatically by this 254 // Returns true if the given handle is closable automatically by this
255 // class. This function is just a helper for validation. 255 // class. This function is just a helper for validation.
256 static bool IsSupportedHandle(const IPC::ChannelHandle& handle) { 256 static bool IsSupportedHandle(const IPC::ChannelHandle& handle) {
257 #if defined(OS_WIN) 257 #if defined(OS_POSIX)
258 // Only ChannelMojo is supported.
259 return handle.socket.fd == -1;
260 #elif defined(OS_WIN)
258 // On Windows, it is not supported to marshal the |pipe.handle|. 261 // On Windows, it is not supported to marshal the |pipe.handle|.
259 // In our case, we wrap a transferred ChannelHandle (or one to be 262 // In our case, we wrap a transferred ChannelHandle (or one to be
260 // transferred) via IPC, so we can assume |handle.pipe.handle| is NULL. 263 // transferred) via IPC, so we can assume |handle.pipe.handle| is NULL.
261 return handle.pipe.handle == NULL; 264 return handle.pipe.handle == NULL;
262 #else 265 #else
263 return true; 266 return true;
264 #endif 267 #endif // defined(OS_POSIX)
265 } 268 }
266 269
267 void CloseIfNecessary() { 270 void CloseIfNecessary() {
271 if (handle_.mojo_handle.is_valid())
272 handle_.mojo_handle.Close();
273
268 #if defined(OS_POSIX) 274 #if defined(OS_POSIX)
269 if (handle_.socket.auto_close) { 275 if (handle_.socket.auto_close) {
270 // Defer closing task to the ScopedFD. 276 // Defer closing task to the ScopedFD.
271 base::ScopedFD(handle_.socket.fd); 277 base::ScopedFD(handle_.socket.fd);
272 } 278 }
273 #endif 279 #endif
274 } 280 }
275 281
276 IPC::ChannelHandle handle_; 282 IPC::ChannelHandle handle_;
277 283
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 } 1033 }
1028 1034
1029 #if defined(OS_LINUX) 1035 #if defined(OS_LINUX)
1030 // static 1036 // static
1031 bool NaClProcessHost::CreateChannelHandlePair( 1037 bool NaClProcessHost::CreateChannelHandlePair(
1032 ScopedChannelHandle* channel_handle1, 1038 ScopedChannelHandle* channel_handle1,
1033 ScopedChannelHandle* channel_handle2) { 1039 ScopedChannelHandle* channel_handle2) {
1034 DCHECK(channel_handle1); 1040 DCHECK(channel_handle1);
1035 DCHECK(channel_handle2); 1041 DCHECK(channel_handle2);
1036 1042
1037 int fd1 = -1; 1043 IPC::ChannelHandle handle1;
1038 int fd2 = -1; 1044 IPC::ChannelHandle handle2;
1039 if (!IPC::SocketPair(&fd1, &fd2)) { 1045 IPC::Channel::GenerateMojoChannelHandlePair("NaCl", &handle1, &handle2);
1040 return false; 1046 channel_handle1->reset(handle1);
1041 } 1047 channel_handle2->reset(handle2);
1042 1048
1043 IPC::ChannelHandle handle = IPC::Channel::GenerateVerifiedChannelID("nacl");
1044 handle.socket = base::FileDescriptor(fd1, true);
1045 channel_handle1->reset(handle);
1046 handle.socket = base::FileDescriptor(fd2, true);
1047 channel_handle2->reset(handle);
1048 return true; 1049 return true;
1049 } 1050 }
1050 #endif 1051 #endif
1051 1052
1052 bool NaClProcessHost::StartPPAPIProxy(ScopedChannelHandle channel_handle) { 1053 bool NaClProcessHost::StartPPAPIProxy(ScopedChannelHandle channel_handle) {
1053 if (ipc_proxy_channel_.get()) { 1054 if (ipc_proxy_channel_.get()) {
1054 // Attempt to open more than 1 browser channel is not supported. 1055 // Attempt to open more than 1 browser channel is not supported.
1055 // Shut down the NaCl process. 1056 // Shut down the NaCl process.
1056 process_->GetHost()->ForceShutdown(); 1057 process_->GetHost()->ForceShutdown();
1057 return false; 1058 return false;
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1299 NaClStartDebugExceptionHandlerThread( 1300 NaClStartDebugExceptionHandlerThread(
1300 std::move(process), info, base::ThreadTaskRunnerHandle::Get(), 1301 std::move(process), info, base::ThreadTaskRunnerHandle::Get(),
1301 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, 1302 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker,
1302 weak_factory_.GetWeakPtr())); 1303 weak_factory_.GetWeakPtr()));
1303 return true; 1304 return true;
1304 } 1305 }
1305 } 1306 }
1306 #endif 1307 #endif
1307 1308
1308 } // namespace nacl 1309 } // namespace nacl
OLDNEW
« no previous file with comments | « no previous file | components/nacl/loader/nacl_listener.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698