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

Side by Side Diff: content/browser/browser_child_process_host_impl.cc

Issue 2019973002: [mojo-edk] Bind a child token to child launches and port reservations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 6 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/browser/browser_child_process_host_impl.h" 5 #include "content/browser/browser_child_process_host_impl.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/dump_without_crashing.h" 10 #include "base/debug/dump_without_crashing.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 void NotifyProcessKilled(const ChildProcessData& data, int exit_code) { 75 void NotifyProcessKilled(const ChildProcessData& data, int exit_code) {
76 FOR_EACH_OBSERVER(BrowserChildProcessObserver, g_observers.Get(), 76 FOR_EACH_OBSERVER(BrowserChildProcessObserver, g_observers.Get(),
77 BrowserChildProcessKilled(data, exit_code)); 77 BrowserChildProcessKilled(data, exit_code));
78 } 78 }
79 79
80 } // namespace 80 } // namespace
81 81
82 BrowserChildProcessHost* BrowserChildProcessHost::Create( 82 BrowserChildProcessHost* BrowserChildProcessHost::Create(
83 content::ProcessType process_type, 83 content::ProcessType process_type,
84 BrowserChildProcessHostDelegate* delegate) { 84 BrowserChildProcessHostDelegate* delegate) {
85 return new BrowserChildProcessHostImpl(process_type, delegate); 85 return new BrowserChildProcessHostImpl(
86 process_type, delegate, mojo::edk::GenerateRandomToken());
87 }
88
89 BrowserChildProcessHost* BrowserChildProcessHost::Create(
90 content::ProcessType process_type,
91 BrowserChildProcessHostDelegate* delegate,
92 const std::string& mojo_child_token) {
93 return new BrowserChildProcessHostImpl(
94 process_type, delegate, mojo_child_token);
86 } 95 }
87 96
88 BrowserChildProcessHost* BrowserChildProcessHost::FromID(int child_process_id) { 97 BrowserChildProcessHost* BrowserChildProcessHost::FromID(int child_process_id) {
89 DCHECK_CURRENTLY_ON(BrowserThread::IO); 98 DCHECK_CURRENTLY_ON(BrowserThread::IO);
90 BrowserChildProcessHostImpl::BrowserChildProcessList* process_list = 99 BrowserChildProcessHostImpl::BrowserChildProcessList* process_list =
91 g_child_process_list.Pointer(); 100 g_child_process_list.Pointer();
92 for (BrowserChildProcessHostImpl* host : *process_list) { 101 for (BrowserChildProcessHostImpl* host : *process_list) {
93 if (host->GetData().id == child_process_id) 102 if (host->GetData().id == child_process_id)
94 return host; 103 return host;
95 } 104 }
(...skipping 21 matching lines...) Expand all
117 126
118 // static 127 // static
119 void BrowserChildProcessHostImpl::RemoveObserver( 128 void BrowserChildProcessHostImpl::RemoveObserver(
120 BrowserChildProcessObserver* observer) { 129 BrowserChildProcessObserver* observer) {
121 // TODO(phajdan.jr): Check thread after fixing http://crbug.com/167126. 130 // TODO(phajdan.jr): Check thread after fixing http://crbug.com/167126.
122 g_observers.Get().RemoveObserver(observer); 131 g_observers.Get().RemoveObserver(observer);
123 } 132 }
124 133
125 BrowserChildProcessHostImpl::BrowserChildProcessHostImpl( 134 BrowserChildProcessHostImpl::BrowserChildProcessHostImpl(
126 content::ProcessType process_type, 135 content::ProcessType process_type,
127 BrowserChildProcessHostDelegate* delegate) 136 BrowserChildProcessHostDelegate* delegate,
137 const std::string& mojo_child_token)
128 : data_(process_type), 138 : data_(process_type),
129 delegate_(delegate), 139 delegate_(delegate),
140 mojo_child_token_(mojo_child_token),
130 power_monitor_message_broadcaster_(this), 141 power_monitor_message_broadcaster_(this),
131 is_channel_connected_(false), 142 is_channel_connected_(false),
132 notify_child_disconnected_(false) { 143 notify_child_disconnected_(false) {
133 data_.id = ChildProcessHostImpl::GenerateChildProcessUniqueId(); 144 data_.id = ChildProcessHostImpl::GenerateChildProcessUniqueId();
134 145
135 #if USE_ATTACHMENT_BROKER 146 #if USE_ATTACHMENT_BROKER
136 // Construct the privileged attachment broker early in the life cycle of a 147 // Construct the privileged attachment broker early in the life cycle of a
137 // child process. This ensures that when a test is being run in one of the 148 // child process. This ensures that when a test is being run in one of the
138 // single process modes, the global attachment broker is the privileged 149 // single process modes, the global attachment broker is the privileged
139 // attachment broker, rather than an unprivileged attachment broker. 150 // attachment broker, rather than an unprivileged attachment broker.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 }; 233 };
223 cmd_line->CopySwitchesFrom(browser_command_line, kForwardSwitches, 234 cmd_line->CopySwitchesFrom(browser_command_line, kForwardSwitches,
224 arraysize(kForwardSwitches)); 235 arraysize(kForwardSwitches));
225 236
226 notify_child_disconnected_ = true; 237 notify_child_disconnected_ = true;
227 child_process_.reset(new ChildProcessLauncher( 238 child_process_.reset(new ChildProcessLauncher(
228 delegate, 239 delegate,
229 cmd_line, 240 cmd_line,
230 data_.id, 241 data_.id,
231 this, 242 this,
243 mojo_child_token_,
232 terminate_on_shutdown)); 244 terminate_on_shutdown));
233 } 245 }
234 246
235 const ChildProcessData& BrowserChildProcessHostImpl::GetData() const { 247 const ChildProcessData& BrowserChildProcessHostImpl::GetData() const {
236 DCHECK_CURRENTLY_ON(BrowserThread::IO); 248 DCHECK_CURRENTLY_ON(BrowserThread::IO);
237 return data_; 249 return data_;
238 } 250 }
239 251
240 ChildProcessHost* BrowserChildProcessHostImpl::GetHost() const { 252 ChildProcessHost* BrowserChildProcessHostImpl::GetHost() const {
241 DCHECK_CURRENTLY_ON(BrowserThread::IO); 253 DCHECK_CURRENTLY_ON(BrowserThread::IO);
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 471
460 #if defined(OS_WIN) 472 #if defined(OS_WIN)
461 473
462 void BrowserChildProcessHostImpl::OnObjectSignaled(HANDLE object) { 474 void BrowserChildProcessHostImpl::OnObjectSignaled(HANDLE object) {
463 OnChildDisconnected(); 475 OnChildDisconnected();
464 } 476 }
465 477
466 #endif 478 #endif
467 479
468 } // namespace content 480 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_child_process_host_impl.h ('k') | content/browser/child_process_launcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698