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

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
« no previous file with comments | « content/browser/utility_process_host_impl_browsertest.cc ('k') | mojo/edk/embedder/BUILD.gn » ('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 "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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 #include "ipc/attachment_broker.h" 59 #include "ipc/attachment_broker.h"
60 #include "ipc/attachment_broker_unprivileged.h" 60 #include "ipc/attachment_broker_unprivileged.h"
61 #include "ipc/ipc_logging.h" 61 #include "ipc/ipc_logging.h"
62 #include "ipc/ipc_platform_file.h" 62 #include "ipc/ipc_platform_file.h"
63 #include "ipc/ipc_switches.h" 63 #include "ipc/ipc_switches.h"
64 #include "ipc/ipc_sync_channel.h" 64 #include "ipc/ipc_sync_channel.h"
65 #include "ipc/ipc_sync_message_filter.h" 65 #include "ipc/ipc_sync_message_filter.h"
66 #include "ipc/mojo/ipc_channel_mojo.h" 66 #include "ipc/mojo/ipc_channel_mojo.h"
67 #include "ipc/mojo/scoped_ipc_support.h" 67 #include "ipc/mojo/scoped_ipc_support.h"
68 #include "mojo/edk/embedder/embedder.h" 68 #include "mojo/edk/embedder/embedder.h"
69 #include "mojo/edk/embedder/named_platform_channel_pair.h"
69 #include "mojo/edk/embedder/platform_channel_pair.h" 70 #include "mojo/edk/embedder/platform_channel_pair.h"
70 71
71 #if defined(OS_POSIX) 72 #if defined(OS_POSIX)
72 #include "base/posix/global_descriptors.h" 73 #include "base/posix/global_descriptors.h"
73 #include "content/public/common/content_descriptors.h" 74 #include "content/public/common/content_descriptors.h"
74 #endif 75 #endif
75 76
76 using tracked_objects::ThreadData; 77 using tracked_objects::ThreadData;
77 78
78 namespace content { 79 namespace content {
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 222
222 closure_.Run(); 223 closure_.Run();
223 } 224 }
224 225
225 base::LazyInstance<QuitClosure> g_quit_closure = LAZY_INSTANCE_INITIALIZER; 226 base::LazyInstance<QuitClosure> g_quit_closure = LAZY_INSTANCE_INITIALIZER;
226 #endif 227 #endif
227 228
228 void InitializeMojoIPCChannel() { 229 void InitializeMojoIPCChannel() {
229 mojo::edk::ScopedPlatformHandle platform_channel; 230 mojo::edk::ScopedPlatformHandle platform_channel;
230 #if defined(OS_WIN) 231 #if defined(OS_WIN)
231 platform_channel = 232 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
232 mojo::edk::PlatformChannelPair::PassClientHandleFromParentProcess( 233 mojo::edk::PlatformChannelPair::kMojoPlatformChannelHandleSwitch)) {
233 *base::CommandLine::ForCurrentProcess()); 234 platform_channel =
235 mojo::edk::PlatformChannelPair::PassClientHandleFromParentProcess(
236 *base::CommandLine::ForCurrentProcess());
237 } else {
238 // If this process is elevated, it will have a pipe path passed on the
239 // command line.
240 platform_channel =
241 mojo::edk::NamedPlatformChannelPair::PassClientHandleFromParentProcess(
242 *base::CommandLine::ForCurrentProcess());
243 }
234 #elif defined(OS_POSIX) 244 #elif defined(OS_POSIX)
235 platform_channel.reset(mojo::edk::PlatformHandle( 245 platform_channel.reset(mojo::edk::PlatformHandle(
236 base::GlobalDescriptors::GetInstance()->Get(kMojoIPCChannel))); 246 base::GlobalDescriptors::GetInstance()->Get(kMojoIPCChannel)));
237 #endif 247 #endif
238 // Mojo isn't supported on all child process types. 248 // Mojo isn't supported on all child process types.
239 // TODO(crbug.com/604282): Support Mojo in the remaining processes. 249 // TODO(crbug.com/604282): Support Mojo in the remaining processes.
240 if (!platform_channel.is_valid()) 250 if (!platform_channel.is_valid())
241 return; 251 return;
242 mojo::edk::SetParentPipeHandle(std::move(platform_channel)); 252 mojo::edk::SetParentPipeHandle(std::move(platform_channel));
243 } 253 }
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 void ChildThreadImpl::EnsureConnected() { 743 void ChildThreadImpl::EnsureConnected() {
734 VLOG(0) << "ChildThreadImpl::EnsureConnected()"; 744 VLOG(0) << "ChildThreadImpl::EnsureConnected()";
735 base::Process::Current().Terminate(0, false); 745 base::Process::Current().Terminate(0, false);
736 } 746 }
737 747
738 bool ChildThreadImpl::IsInBrowserProcess() const { 748 bool ChildThreadImpl::IsInBrowserProcess() const {
739 return static_cast<bool>(browser_process_io_runner_); 749 return static_cast<bool>(browser_process_io_runner_);
740 } 750 }
741 751
742 } // namespace content 752 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/utility_process_host_impl_browsertest.cc ('k') | mojo/edk/embedder/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698