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

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: Fix nits. 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"
Avi (use Gerrit) 2015/04/21 20:59:45 Do you need this include?
shrike 2015/04/21 21:08:33 No - removed.
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/21 20:59:45 You still need to remove this line.
shrike 2015/04/21 21:08:33 There was an existing ../content_switches.h includ
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 MachBroker* broker = MachBroker::GetInstance();
276 process.SetProcessBackgrounded(broker->TaskForPid(process.Pid()), background);
277 #else
272 process.SetProcessBackgrounded(background); 278 process.SetProcessBackgrounded(background);
279 #endif // defined(OS_MACOSX)
273 #if defined(OS_ANDROID) 280 #if defined(OS_ANDROID)
274 SetChildProcessInForeground(process.Handle(), !background); 281 SetChildProcessInForeground(process.Handle(), !background);
275 #endif 282 #endif
276 } 283 }
277 284
278 } // anonymous namespace 285 } // anonymous namespace
279 286
280 ChildProcessLauncher::ChildProcessLauncher( 287 ChildProcessLauncher::ChildProcessLauncher(
281 SandboxedProcessLauncherDelegate* delegate, 288 SandboxedProcessLauncherDelegate* delegate,
282 base::CommandLine* cmd_line, 289 base::CommandLine* cmd_line,
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 } 500 }
494 501
495 ChildProcessLauncher::Client* ChildProcessLauncher::ReplaceClientForTest( 502 ChildProcessLauncher::Client* ChildProcessLauncher::ReplaceClientForTest(
496 Client* client) { 503 Client* client) {
497 Client* ret = client_; 504 Client* ret = client_;
498 client_ = client; 505 client_ = client;
499 return ret; 506 return ret;
500 } 507 }
501 508
502 } // namespace content 509 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698