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

Unified Diff: content/browser/browser_main_loop.cc

Issue 22836004: Chrome tracing for system-wide performance stats. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@asvalue
Patch Set: changed GetCurrent to Sample Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/browser_main_loop.cc
diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc
index 4194aa859c5d79ef18468597fc3f05492a1f4eed..4a2c299c2da2e933aca13f2ba9436c481f6dd597 100644
--- a/content/browser/browser_main_loop.cc
+++ b/content/browser/browser_main_loop.cc
@@ -7,12 +7,10 @@
#include "base/bind.h"
#include "base/command_line.h"
#include "base/debug/trace_event.h"
-#include "base/file_util.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/histogram.h"
-#include "base/path_service.h"
#include "base/pending_task.h"
#include "base/power_monitor/power_monitor.h"
#include "base/power_monitor/power_monitor_device_source.h"
@@ -22,6 +20,7 @@
#include "base/system_monitor/system_monitor.h"
#include "base/threading/thread_restrictions.h"
#include "base/timer/hi_res_timer_manager.h"
+#include "base/debug/trace_event_system_stats_monitor.h"
#include "content/browser/browser_thread_impl.h"
#include "content/browser/device_orientation/device_motion_service.h"
#include "content/browser/download/save_file_manager.h"
@@ -123,54 +122,48 @@ void SetupSandbox(const CommandLine& parsed_command_line) {
TRACE_EVENT0("startup", "SetupSandbox");
// TODO(evanm): move this into SandboxWrapper; I'm just trying to move this
// code en masse out of chrome_main for now.
- base::FilePath sandbox_binary;
- bool env_chrome_devel_sandbox_set = false;
+ const char* sandbox_binary = NULL;
struct stat st;
+ // In Chromium branded builds, developers can set an environment variable to
+ // use the development sandbox. See
+ // http://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment
+ if (stat(base::kProcSelfExe, &st) == 0 && st.st_uid == getuid())
+ sandbox_binary = getenv("CHROME_DEVEL_SANDBOX");
+
+#if defined(LINUX_SANDBOX_PATH)
+ if (!sandbox_binary)
+ sandbox_binary = LINUX_SANDBOX_PATH;
+#endif
+
const bool want_setuid_sandbox =
!parsed_command_line.HasSwitch(switches::kNoSandbox) &&
!parsed_command_line.HasSwitch(switches::kDisableSetuidSandbox);
if (want_setuid_sandbox) {
- base::FilePath exe_dir;
- if (PathService::Get(base::DIR_EXE, &exe_dir)) {
- base::FilePath sandbox_candidate = exe_dir.AppendASCII("chrome-sandbox");
- if (base::PathExists(sandbox_candidate))
- sandbox_binary = sandbox_candidate;
- }
-
- // In user-managed builds, including development builds, an environment
- // variable is required to enable the sandbox. See
- // http://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment
- if (sandbox_binary.empty() &&
- stat(base::kProcSelfExe, &st) == 0 && st.st_uid == getuid()) {
- const char* devel_sandbox_path = getenv("CHROME_DEVEL_SANDBOX");
- if (devel_sandbox_path) {
- env_chrome_devel_sandbox_set = true;
- sandbox_binary = base::FilePath(devel_sandbox_path);
- }
- }
-
static const char no_suid_error[] = "Running without the SUID sandbox! See "
"https://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment "
"for more information on developing with the sandbox on.";
- if (sandbox_binary.empty()) {
- if (!env_chrome_devel_sandbox_set) {
- // This needs to be fatal. Talk to security@chromium.org if you feel
- // otherwise.
- LOG(FATAL) << no_suid_error;
- }
-
- // TODO(jln): an empty CHROME_DEVEL_SANDBOX environment variable (as
- // opposed to a non existing one) is not fatal yet. This is needed
- // because of existing bots and scripts. Fix it (crbug.com/245376).
- LOG(ERROR) << no_suid_error;
+ if (!sandbox_binary) {
+ // This needs to be fatal. Talk to security@chromium.org if you feel
+ // otherwise.
+ LOG(FATAL) << no_suid_error;
}
+ // TODO(jln): an empty CHROME_DEVEL_SANDBOX environment variable (as
+ // opposed to a non existing one) is not fatal yet. This is needed because
+ // of existing bots and scripts. Fix it (crbug.com/245376).
+ if (sandbox_binary && *sandbox_binary == '\0')
+ LOG(ERROR) << no_suid_error;
+ }
+
+ std::string sandbox_cmd;
+ if (want_setuid_sandbox && sandbox_binary) {
+ sandbox_cmd = sandbox_binary;
}
// Tickle the sandbox host and zygote host so they fork now.
- RenderSandboxHostLinux::GetInstance()->Init(sandbox_binary.value());
- ZygoteHostImpl::GetInstance()->Init(sandbox_binary.value());
+ RenderSandboxHostLinux::GetInstance()->Init(sandbox_cmd);
+ ZygoteHostImpl::GetInstance()->Init(sandbox_cmd);
}
#endif
@@ -489,6 +482,8 @@ void BrowserMainLoop::MainMessageLoopStart() {
base::MessageLoop::current()->AddTaskObserver(memory_observer_.get());
}
+ system_stats_monitor_.reset(new base::debug::TraceEventSystemStatsMonitor(
+ base::MessageLoop::current()->message_loop_proxy()));
#if defined(TCMALLOC_TRACE_MEMORY_SUPPORTED)
trace_memory_controller_.reset(new base::debug::TraceMemoryController(
base::MessageLoop::current()->message_loop_proxy(),
@@ -694,6 +689,7 @@ void BrowserMainLoop::ShutdownThreadsAndCleanUp() {
parts_->PostMainMessageLoopRun();
trace_memory_controller_.reset();
+ system_stats_monitor_.reset();
#if !defined(OS_IOS)
// Destroying the GpuProcessHostUIShims on the UI thread posts a task to
« base/debug/trace_event_system_stats_monitor.cc ('K') | « content/browser/browser_main_loop.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698