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

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

Issue 1607303002: Allocator cleanup: allocator_extension call directly into tcmalloc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@base_dep_alloc
Patch Set: Created 4 years, 11 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/zygote_host/zygote_host_impl_linux.h" 5 #include "content/browser/zygote_host/zygote_host_impl_linux.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <string.h> 8 #include <string.h>
9 #include <sys/socket.h> 9 #include <sys/socket.h>
10 #include <sys/stat.h> 10 #include <sys/stat.h>
11 #include <sys/types.h> 11 #include <sys/types.h>
12 #include <unistd.h> 12 #include <unistd.h>
13 13
14 #include "base/allocator/allocator_extension.h"
14 #include "base/base_switches.h" 15 #include "base/base_switches.h"
15 #include "base/command_line.h" 16 #include "base/command_line.h"
16 #include "base/environment.h" 17 #include "base/environment.h"
17 #include "base/files/file_enumerator.h" 18 #include "base/files/file_enumerator.h"
18 #include "base/files/file_util.h" 19 #include "base/files/file_util.h"
19 #include "base/files/scoped_file.h" 20 #include "base/files/scoped_file.h"
20 #include "base/linux_util.h" 21 #include "base/linux_util.h"
21 #include "base/logging.h" 22 #include "base/logging.h"
22 #include "base/macros.h" 23 #include "base/macros.h"
23 #include "base/memory/linked_ptr.h" 24 #include "base/memory/linked_ptr.h"
(...skipping 18 matching lines...) Expand all
42 #include "content/public/common/content_switches.h" 43 #include "content/public/common/content_switches.h"
43 #include "content/public/common/result_codes.h" 44 #include "content/public/common/result_codes.h"
44 #include "sandbox/linux/services/credentials.h" 45 #include "sandbox/linux/services/credentials.h"
45 #include "sandbox/linux/services/namespace_sandbox.h" 46 #include "sandbox/linux/services/namespace_sandbox.h"
46 #include "sandbox/linux/services/namespace_utils.h" 47 #include "sandbox/linux/services/namespace_utils.h"
47 #include "sandbox/linux/suid/client/setuid_sandbox_host.h" 48 #include "sandbox/linux/suid/client/setuid_sandbox_host.h"
48 #include "sandbox/linux/suid/common/sandbox.h" 49 #include "sandbox/linux/suid/common/sandbox.h"
49 #include "ui/base/ui_base_switches.h" 50 #include "ui/base/ui_base_switches.h"
50 #include "ui/gfx/switches.h" 51 #include "ui/gfx/switches.h"
51 52
52 #if defined(USE_TCMALLOC)
53 #include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h"
54 #endif
55
56 namespace content { 53 namespace content {
57 54
58 namespace { 55 namespace {
59 56
60 // Receive a fixed message on fd and return the sender's PID. 57 // Receive a fixed message on fd and return the sender's PID.
61 // Returns true if the message received matches the expected message. 58 // Returns true if the message received matches the expected message.
62 bool ReceiveFixedMessage(int fd, 59 bool ReceiveFixedMessage(int fd,
63 const char* expect_msg, 60 const char* expect_msg,
64 size_t expect_len, 61 size_t expect_len,
65 base::ProcessId* sender_pid) { 62 base::ProcessId* sender_pid) {
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 const base::FilePath kSelinuxPath("/selinux"); 474 const base::FilePath kSelinuxPath("/selinux");
478 base::FileEnumerator en(kSelinuxPath, false, base::FileEnumerator::FILES); 475 base::FileEnumerator en(kSelinuxPath, false, base::FileEnumerator::FILES);
479 bool has_selinux_files = !en.Next().empty(); 476 bool has_selinux_files = !en.Next().empty();
480 477
481 selinux = access(kSelinuxPath.value().c_str(), X_OK) == 0 && 478 selinux = access(kSelinuxPath.value().c_str(), X_OK) == 0 &&
482 has_selinux_files; 479 has_selinux_files;
483 selinux_valid = true; 480 selinux_valid = true;
484 } 481 }
485 482
486 if (use_suid_sandbox_for_adj_oom_score_ && !selinux) { 483 if (use_suid_sandbox_for_adj_oom_score_ && !selinux) {
487 #if defined(USE_TCMALLOC)
488 // If heap profiling is running, these processes are not exiting, at least 484 // If heap profiling is running, these processes are not exiting, at least
489 // on ChromeOS. The easiest thing to do is not launch them when profiling. 485 // on ChromeOS. The easiest thing to do is not launch them when profiling.
490 // TODO(stevenjb): Investigate further and fix. 486 // TODO(stevenjb): Investigate further and fix.
491 if (IsHeapProfilerRunning()) 487 if (base::allocator::IsHeapProfilerRunning())
492 return; 488 return;
493 #endif 489
494 std::vector<std::string> adj_oom_score_cmdline; 490 std::vector<std::string> adj_oom_score_cmdline;
495 adj_oom_score_cmdline.push_back(sandbox_binary_); 491 adj_oom_score_cmdline.push_back(sandbox_binary_);
496 adj_oom_score_cmdline.push_back(sandbox::kAdjustOOMScoreSwitch); 492 adj_oom_score_cmdline.push_back(sandbox::kAdjustOOMScoreSwitch);
497 adj_oom_score_cmdline.push_back(base::Int64ToString(pid)); 493 adj_oom_score_cmdline.push_back(base::Int64ToString(pid));
498 adj_oom_score_cmdline.push_back(base::IntToString(score)); 494 adj_oom_score_cmdline.push_back(base::IntToString(score));
499 495
500 base::Process sandbox_helper_process; 496 base::Process sandbox_helper_process;
501 base::LaunchOptions options; 497 base::LaunchOptions options;
502 498
503 // sandbox_helper_process is a setuid binary. 499 // sandbox_helper_process is a setuid binary.
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 } 592 }
597 593
598 if (!sandbox::Credentials::CanCreateProcessInNewUserNS()) { 594 if (!sandbox::Credentials::CanCreateProcessInNewUserNS()) {
599 return false; 595 return false;
600 } 596 }
601 597
602 return true; 598 return true;
603 } 599 }
604 600
605 } // namespace content 601 } // namespace content
OLDNEW
« base/debug/OWNERS ('K') | « chrome/browser/ui/toolbar/app_menu_model.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698