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

Side by Side Diff: content/child/child_thread_impl.cc

Issue 1893313003: [mojo] Use a pipe path to initialise Mojo in elevated utility processes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 7 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
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 "content/child/child_thread_impl.h" 5 #include "content/child/child_thread_impl.h"
6 6
7 #include <signal.h> 7 #include <signal.h>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 #include "ipc/attachment_broker.h" 60 #include "ipc/attachment_broker.h"
61 #include "ipc/attachment_broker_unprivileged.h" 61 #include "ipc/attachment_broker_unprivileged.h"
62 #include "ipc/ipc_logging.h" 62 #include "ipc/ipc_logging.h"
63 #include "ipc/ipc_platform_file.h" 63 #include "ipc/ipc_platform_file.h"
64 #include "ipc/ipc_switches.h" 64 #include "ipc/ipc_switches.h"
65 #include "ipc/ipc_sync_channel.h" 65 #include "ipc/ipc_sync_channel.h"
66 #include "ipc/ipc_sync_message_filter.h" 66 #include "ipc/ipc_sync_message_filter.h"
67 #include "ipc/mojo/ipc_channel_mojo.h" 67 #include "ipc/mojo/ipc_channel_mojo.h"
68 #include "ipc/mojo/scoped_ipc_support.h" 68 #include "ipc/mojo/scoped_ipc_support.h"
69 #include "mojo/edk/embedder/embedder.h" 69 #include "mojo/edk/embedder/embedder.h"
70 #include "mojo/edk/embedder/named_platform_channel_pair.h"
70 #include "mojo/edk/embedder/platform_channel_pair.h" 71 #include "mojo/edk/embedder/platform_channel_pair.h"
71 72
72 #if defined(OS_POSIX) 73 #if defined(OS_POSIX)
73 #include "base/posix/global_descriptors.h" 74 #include "base/posix/global_descriptors.h"
74 #include "content/public/common/content_descriptors.h" 75 #include "content/public/common/content_descriptors.h"
75 #endif 76 #endif
76 77
77 using tracked_objects::ThreadData; 78 using tracked_objects::ThreadData;
78 79
79 namespace content { 80 namespace content {
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 223
223 closure_.Run(); 224 closure_.Run();
224 } 225 }
225 226
226 base::LazyInstance<QuitClosure> g_quit_closure = LAZY_INSTANCE_INITIALIZER; 227 base::LazyInstance<QuitClosure> g_quit_closure = LAZY_INSTANCE_INITIALIZER;
227 #endif 228 #endif
228 229
229 void InitializeMojoIPCChannel() { 230 void InitializeMojoIPCChannel() {
230 mojo::edk::ScopedPlatformHandle platform_channel; 231 mojo::edk::ScopedPlatformHandle platform_channel;
231 #if defined(OS_WIN) 232 #if defined(OS_WIN)
232 platform_channel = 233 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
233 mojo::edk::PlatformChannelPair::PassClientHandleFromParentProcess( 234 mojo::edk::PlatformChannelPair::kMojoPlatformChannelHandleSwitch)) {
ncarter (slow) 2016/05/11 00:14:23 The layering here feels little awkward -- content
Anand Mistry (off Chromium) 2016/05/11 04:15:20 Hm. I agree that the switch should be moved to con
ncarter (slow) 2016/05/11 16:06:07 Follow-on CL is totally fine.
234 *base::CommandLine::ForCurrentProcess()); 235 platform_channel =
236 mojo::edk::PlatformChannelPair::PassClientHandleFromParentProcess(
237 *base::CommandLine::ForCurrentProcess());
238 } else {
239 // If this process is elevated, it will have a pipe path passed on the
240 // command line.
241 platform_channel =
242 mojo::edk::NamedPlatformChannelPair::PassClientHandleFromParentProcess(
243 *base::CommandLine::ForCurrentProcess());
244 }
235 #elif defined(OS_POSIX) 245 #elif defined(OS_POSIX)
236 platform_channel.reset(mojo::edk::PlatformHandle( 246 platform_channel.reset(mojo::edk::PlatformHandle(
237 base::GlobalDescriptors::GetInstance()->Get(kMojoIPCChannel))); 247 base::GlobalDescriptors::GetInstance()->Get(kMojoIPCChannel)));
238 #endif 248 #endif
239 // Mojo isn't supported on all child process types. 249 // Mojo isn't supported on all child process types.
240 // TODO(crbug.com/604282): Support Mojo in the remaining processes. 250 // TODO(crbug.com/604282): Support Mojo in the remaining processes.
241 if (!platform_channel.is_valid()) 251 if (!platform_channel.is_valid())
242 return; 252 return;
243 mojo::edk::SetParentPipeHandle(std::move(platform_channel)); 253 mojo::edk::SetParentPipeHandle(std::move(platform_channel));
244 } 254 }
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 void ChildThreadImpl::EnsureConnected() { 731 void ChildThreadImpl::EnsureConnected() {
722 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; 732 VLOG(0) << "ChildThreadImpl::EnsureConnected()";
723 base::Process::Current().Terminate(0, false); 733 base::Process::Current().Terminate(0, false);
724 } 734 }
725 735
726 bool ChildThreadImpl::IsInBrowserProcess() const { 736 bool ChildThreadImpl::IsInBrowserProcess() const {
727 return browser_process_io_runner_; 737 return browser_process_io_runner_;
728 } 738 }
729 739
730 } // namespace content 740 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698