OLD | NEW |
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/browser_main_loop.h" | 5 #include "content/browser/browser_main_loop.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/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 128 |
129 // One of the linux specific headers defines this as a macro. | 129 // One of the linux specific headers defines this as a macro. |
130 #ifdef DestroyAll | 130 #ifdef DestroyAll |
131 #undef DestroyAll | 131 #undef DestroyAll |
132 #endif | 132 #endif |
133 | 133 |
134 namespace content { | 134 namespace content { |
135 namespace { | 135 namespace { |
136 | 136 |
137 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) | 137 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
138 void SetupSandbox(const CommandLine& parsed_command_line) { | 138 void SetupSandbox(const base::CommandLine& parsed_command_line) { |
139 TRACE_EVENT0("startup", "SetupSandbox"); | 139 TRACE_EVENT0("startup", "SetupSandbox"); |
140 base::FilePath sandbox_binary; | 140 base::FilePath sandbox_binary; |
141 | 141 |
142 scoped_ptr<sandbox::SetuidSandboxClient> setuid_sandbox_client( | 142 scoped_ptr<sandbox::SetuidSandboxClient> setuid_sandbox_client( |
143 sandbox::SetuidSandboxClient::Create()); | 143 sandbox::SetuidSandboxClient::Create()); |
144 | 144 |
145 const bool want_setuid_sandbox = | 145 const bool want_setuid_sandbox = |
146 !parsed_command_line.HasSwitch(switches::kNoSandbox) && | 146 !parsed_command_line.HasSwitch(switches::kNoSandbox) && |
147 !parsed_command_line.HasSwitch(switches::kDisableSetuidSandbox) && | 147 !parsed_command_line.HasSwitch(switches::kDisableSetuidSandbox) && |
148 !setuid_sandbox_client->IsDisabledViaEnvironment(); | 148 !setuid_sandbox_client->IsDisabledViaEnvironment(); |
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1128 TracingControllerAndroid::GenerateTracingFilePath(&trace_file); | 1128 TracingControllerAndroid::GenerateTracingFilePath(&trace_file); |
1129 #else | 1129 #else |
1130 // Default to saving the startup trace into the current dir. | 1130 // Default to saving the startup trace into the current dir. |
1131 trace_file = base::FilePath().AppendASCII("chrometrace.log"); | 1131 trace_file = base::FilePath().AppendASCII("chrometrace.log"); |
1132 #endif | 1132 #endif |
1133 } | 1133 } |
1134 | 1134 |
1135 return trace_file; | 1135 return trace_file; |
1136 } | 1136 } |
1137 | 1137 |
1138 void BrowserMainLoop::InitStartupTracing(const CommandLine& command_line) { | 1138 void BrowserMainLoop::InitStartupTracing( |
| 1139 const base::CommandLine& command_line) { |
1139 DCHECK(is_tracing_startup_); | 1140 DCHECK(is_tracing_startup_); |
1140 | 1141 |
1141 startup_trace_file_ = GetStartupTraceFileName(parsed_command_line_); | 1142 startup_trace_file_ = GetStartupTraceFileName(parsed_command_line_); |
1142 | 1143 |
1143 std::string delay_str = command_line.GetSwitchValueASCII( | 1144 std::string delay_str = command_line.GetSwitchValueASCII( |
1144 switches::kTraceStartupDuration); | 1145 switches::kTraceStartupDuration); |
1145 int delay_secs = 5; | 1146 int delay_secs = 5; |
1146 if (!delay_str.empty() && !base::StringToInt(delay_str, &delay_secs)) { | 1147 if (!delay_str.empty() && !base::StringToInt(delay_str, &delay_secs)) { |
1147 DLOG(WARNING) << "Could not parse --" << switches::kTraceStartupDuration | 1148 DLOG(WARNING) << "Could not parse --" << switches::kTraceStartupDuration |
1148 << "=" << delay_str << " defaulting to 5 (secs)"; | 1149 << "=" << delay_str << " defaulting to 5 (secs)"; |
1149 delay_secs = 5; | 1150 delay_secs = 5; |
1150 } | 1151 } |
1151 | 1152 |
1152 startup_trace_timer_.Start(FROM_HERE, | 1153 startup_trace_timer_.Start(FROM_HERE, |
1153 base::TimeDelta::FromSeconds(delay_secs), | 1154 base::TimeDelta::FromSeconds(delay_secs), |
1154 this, | 1155 this, |
1155 &BrowserMainLoop::EndStartupTracing); | 1156 &BrowserMainLoop::EndStartupTracing); |
1156 } | 1157 } |
1157 | 1158 |
1158 void BrowserMainLoop::EndStartupTracing() { | 1159 void BrowserMainLoop::EndStartupTracing() { |
1159 is_tracing_startup_ = false; | 1160 is_tracing_startup_ = false; |
1160 TracingController::GetInstance()->DisableRecording( | 1161 TracingController::GetInstance()->DisableRecording( |
1161 startup_trace_file_, base::Bind(&OnStoppedStartupTracing)); | 1162 startup_trace_file_, base::Bind(&OnStoppedStartupTracing)); |
1162 } | 1163 } |
1163 | 1164 |
1164 } // namespace content | 1165 } // namespace content |
OLD | NEW |