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

Side by Side Diff: content/browser/zygote_host/zygote_host_impl_linux.cc

Issue 49843002: cros: Remove unused low memory margin code from sandbox and zygote (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
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/zygote_host/zygote_host_impl_linux.h" 5 #include "content/browser/zygote_host/zygote_host_impl_linux.h"
6 6
7 #include <sys/socket.h> 7 #include <sys/socket.h>
8 #include <sys/stat.h> 8 #include <sys/stat.h>
9 #include <sys/types.h> 9 #include <sys/types.h>
10 #include <unistd.h> 10 #include <unistd.h>
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 &sandbox_helper_process)) { 400 &sandbox_helper_process)) {
401 base::EnsureProcessGetsReaped(sandbox_helper_process); 401 base::EnsureProcessGetsReaped(sandbox_helper_process);
402 } 402 }
403 } else if (!using_suid_sandbox_) { 403 } else if (!using_suid_sandbox_) {
404 if (!base::AdjustOOMScore(pid, score)) 404 if (!base::AdjustOOMScore(pid, score))
405 PLOG(ERROR) << "Failed to adjust OOM score of renderer with pid " << pid; 405 PLOG(ERROR) << "Failed to adjust OOM score of renderer with pid " << pid;
406 } 406 }
407 } 407 }
408 #endif 408 #endif
409 409
410 void ZygoteHostImpl::AdjustLowMemoryMargin(int64 margin_mb) {
411 #if defined(OS_CHROMEOS)
412 // You can't change the low memory margin unless you're root. Because of this,
413 // we can't set the low memory margin from the browser process.
414 // So, we use the SUID binary to change it for us.
415 if (using_suid_sandbox_) {
416 #if defined(USE_TCMALLOC)
417 // If heap profiling is running, these processes are not exiting, at least
418 // on ChromeOS. The easiest thing to do is not launch them when profiling.
419 // TODO(stevenjb): Investigate further and fix.
420 if (IsHeapProfilerRunning())
421 return;
422 #endif
423 std::vector<std::string> adj_low_mem_commandline;
424 adj_low_mem_commandline.push_back(sandbox_binary_);
425 adj_low_mem_commandline.push_back(sandbox::kAdjustLowMemMarginSwitch);
426 adj_low_mem_commandline.push_back(base::Int64ToString(margin_mb));
427
428 base::ProcessHandle sandbox_helper_process;
429 if (base::LaunchProcess(adj_low_mem_commandline, base::LaunchOptions(),
430 &sandbox_helper_process)) {
431 base::EnsureProcessGetsReaped(sandbox_helper_process);
432 } else {
433 LOG(ERROR) << "Unable to run suid sandbox to set low memory margin.";
434 }
435 }
436 // Don't adjust memory margin if we're not running with the sandbox: this
437 // isn't very common, and not doing it has little impact.
438 #else
439 // Low memory notification is currently only implemented on ChromeOS.
440 NOTREACHED() << "AdjustLowMemoryMargin not implemented";
441 #endif // defined(OS_CHROMEOS)
442 }
443
444
445 void ZygoteHostImpl::EnsureProcessTerminated(pid_t process) { 410 void ZygoteHostImpl::EnsureProcessTerminated(pid_t process) {
446 DCHECK(init_); 411 DCHECK(init_);
447 Pickle pickle; 412 Pickle pickle;
448 413
449 pickle.WriteInt(kZygoteCommandReap); 414 pickle.WriteInt(kZygoteCommandReap);
450 pickle.WriteInt(process); 415 pickle.WriteInt(process);
451 if (!SendMessage(pickle, NULL)) 416 if (!SendMessage(pickle, NULL))
452 LOG(ERROR) << "Failed to send Reap message to zygote"; 417 LOG(ERROR) << "Failed to send Reap message to zygote";
453 } 418 }
454 419
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 return RenderSandboxHostLinux::GetInstance()->pid(); 472 return RenderSandboxHostLinux::GetInstance()->pid();
508 } 473 }
509 474
510 int ZygoteHostImpl::GetSandboxStatus() const { 475 int ZygoteHostImpl::GetSandboxStatus() const {
511 if (have_read_sandbox_status_word_) 476 if (have_read_sandbox_status_word_)
512 return sandbox_status_; 477 return sandbox_status_;
513 return 0; 478 return 0;
514 } 479 }
515 480
516 } // namespace content 481 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/zygote_host/zygote_host_impl_linux.h ('k') | content/public/browser/zygote_host_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698