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

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

Issue 989703002: Add support for backgrounding processes on the Mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased on tot, rewrapped backgrounging in an experiment. Created 5 years, 8 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 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/child_process_launcher.h" 5 #include "content/browser/child_process_launcher.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/metrics/field_trial.h"
12 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
13 #include "base/process/process.h" 14 #include "base/process/process.h"
14 #include "base/profiler/scoped_tracker.h" 15 #include "base/profiler/scoped_tracker.h"
15 #include "base/synchronization/lock.h" 16 #include "base/synchronization/lock.h"
16 #include "base/threading/thread.h" 17 #include "base/threading/thread.h"
17 #include "content/public/browser/content_browser_client.h" 18 #include "content/public/browser/content_browser_client.h"
18 #include "content/public/common/content_descriptors.h" 19 #include "content/public/common/content_descriptors.h"
19 #include "content/public/common/content_switches.h" 20 #include "content/public/common/content_switches.h"
20 #include "content/public/common/result_codes.h" 21 #include "content/public/common/result_codes.h"
21 #include "content/public/common/sandboxed_process_launcher_delegate.h" 22 #include "content/public/common/sandboxed_process_launcher_delegate.h"
23 #include "content/shell/common/shell_switches.h"
Avi (use Gerrit) 2015/04/16 02:46:20 This is the wrong file; you mean content/public/co
shrike 2015/04/16 17:31:32 Hi Avi, (not sure how I didn't fire up the trybot
22 24
23 #if defined(OS_WIN) 25 #if defined(OS_WIN)
24 #include "base/files/file_path.h" 26 #include "base/files/file_path.h"
25 #include "content/common/sandbox_win.h" 27 #include "content/common/sandbox_win.h"
26 #include "content/public/common/sandbox_init.h" 28 #include "content/public/common/sandbox_init.h"
27 #elif defined(OS_MACOSX) 29 #elif defined(OS_MACOSX)
28 #include "content/browser/bootstrap_sandbox_mac.h" 30 #include "content/browser/bootstrap_sandbox_mac.h"
29 #include "content/browser/mach_broker_mac.h" 31 #include "content/browser/mach_broker_mac.h"
30 #include "sandbox/mac/bootstrap_sandbox.h" 32 #include "sandbox/mac/bootstrap_sandbox.h"
31 #elif defined(OS_ANDROID) 33 #elif defined(OS_ANDROID)
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 } else 264 } else
263 #endif // !OS_MACOSX 265 #endif // !OS_MACOSX
264 base::EnsureProcessTerminated(process.Pass()); 266 base::EnsureProcessTerminated(process.Pass());
265 #endif // OS_POSIX 267 #endif // OS_POSIX
266 #endif // defined(OS_ANDROID) 268 #endif // defined(OS_ANDROID)
267 } 269 }
268 270
269 void SetProcessBackgroundedOnLauncherThread(base::Process process, 271 void SetProcessBackgroundedOnLauncherThread(base::Process process,
270 bool background) { 272 bool background) {
271 DCHECK_CURRENTLY_ON(BrowserThread::PROCESS_LAUNCHER); 273 DCHECK_CURRENTLY_ON(BrowserThread::PROCESS_LAUNCHER);
274 #if defined(OS_MACOSX)
275 const std::string trial_group_name =
276 base::FieldTrialList::FindFullName("BackgroundMacRendererProcesses");
gab 2015/04/16 13:18:13 As mentioned offline, I think we should use the sa
shrike 2015/04/21 20:55:48 Done.
277 bool allow_background_renderers =
278 base::CommandLine::ForCurrentProcess()->HasSwitch(
gab 2015/04/16 18:42:42 Don't need a command-line switch either, it comes
shrike 2015/04/21 20:55:48 Done.
279 switches::kBackgroundMacRendererProcesses);
280 if (allow_background_renderers || trial_group_name == "Allow") {
281 MachBroker* broker = MachBroker::GetInstance();
282 process.SetProcessBackgrounded(broker->TaskForPid(process.Pid()),
283 background);
284 }
285 #else
272 process.SetProcessBackgrounded(background); 286 process.SetProcessBackgrounded(background);
287 #endif // defined(OS_MACOSX)
273 #if defined(OS_ANDROID) 288 #if defined(OS_ANDROID)
274 SetChildProcessInForeground(process.Handle(), !background); 289 SetChildProcessInForeground(process.Handle(), !background);
275 #endif 290 #endif
276 } 291 }
277 292
278 } // anonymous namespace 293 } // anonymous namespace
279 294
280 ChildProcessLauncher::ChildProcessLauncher( 295 ChildProcessLauncher::ChildProcessLauncher(
281 SandboxedProcessLauncherDelegate* delegate, 296 SandboxedProcessLauncherDelegate* delegate,
282 base::CommandLine* cmd_line, 297 base::CommandLine* cmd_line,
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 } 508 }
494 509
495 ChildProcessLauncher::Client* ChildProcessLauncher::ReplaceClientForTest( 510 ChildProcessLauncher::Client* ChildProcessLauncher::ReplaceClientForTest(
496 Client* client) { 511 Client* client) {
497 Client* ret = client_; 512 Client* ret = client_;
498 client_ = client; 513 client_ = client;
499 return ret; 514 return ret;
500 } 515 }
501 516
502 } // namespace content 517 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698