| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // TODO(port): the ifdefs in here are a first step towards trying to determine | 5 // TODO(port): the ifdefs in here are a first step towards trying to determine |
| 6 // the correct abstraction for all the OS functionality required at this | 6 // the correct abstraction for all the OS functionality required at this |
| 7 // stage of process initialization. It should not be taken as a final | 7 // stage of process initialization. It should not be taken as a final |
| 8 // abstraction. | 8 // abstraction. |
| 9 | 9 |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 CommandLine::Init(argc, argv); | 259 CommandLine::Init(argc, argv); |
| 260 #endif | 260 #endif |
| 261 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); | 261 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); |
| 262 | 262 |
| 263 #if defined(OS_WIN) | 263 #if defined(OS_WIN) |
| 264 // Must do this before any other usage of command line! | 264 // Must do this before any other usage of command line! |
| 265 if (::IncorrectChromeHtmlArguments(parsed_command_line.command_line_string())) | 265 if (::IncorrectChromeHtmlArguments(parsed_command_line.command_line_string())) |
| 266 return 1; | 266 return 1; |
| 267 #endif | 267 #endif |
| 268 | 268 |
| 269 int browser_pid; |
| 270 std::wstring process_type = |
| 271 parsed_command_line.GetSwitchValue(switches::kProcessType); |
| 272 if (process_type.empty()) { |
| 273 browser_pid = base::GetCurrentProcId(); |
| 274 } else { |
| 275 std::wstring channel_name = |
| 276 parsed_command_line.GetSwitchValue(switches::kProcessChannelID); |
| 277 |
| 278 browser_pid = _wtoi(channel_name.c_str()); |
| 279 DCHECK(browser_pid != 0); |
| 280 } |
| 269 SetupCRT(parsed_command_line); | 281 SetupCRT(parsed_command_line); |
| 270 | 282 |
| 271 // Initialize the Chrome path provider. | 283 // Initialize the Chrome path provider. |
| 272 chrome::RegisterPathProvider(); | 284 chrome::RegisterPathProvider(); |
| 273 | 285 |
| 274 // Initialize the Stats Counters table. With this initialized, | 286 // Initialize the Stats Counters table. With this initialized, |
| 275 // the StatsViewer can be utilized to read counters outside of | 287 // the StatsViewer can be utilized to read counters outside of |
| 276 // Chrome. These lines can be commented out to effectively turn | 288 // Chrome. These lines can be commented out to effectively turn |
| 277 // counters 'off'. The table is created and exists for the life | 289 // counters 'off'. The table is created and exists for the life |
| 278 // of the process. It is not cleaned up. | 290 // of the process. It is not cleaned up. |
| 279 // TODO(port): we probably need to shut this down correctly to avoid | 291 // TODO(port): we probably need to shut this down correctly to avoid |
| 280 // leaking shared memory regions on posix platforms. | 292 // leaking shared memory regions on posix platforms. |
| 281 std::string statsfile = chrome::kStatsFilename; | 293 std::string statsfile = chrome::kStatsFilename; |
| 282 std::string pid_string = StringPrintf("-%d", base::GetCurrentProcId()); | 294 std::string pid_string = StringPrintf("-%d", browser_pid); |
| 283 statsfile += pid_string; | 295 statsfile += pid_string; |
| 284 StatsTable *stats_table = new StatsTable(statsfile, | 296 StatsTable *stats_table = new StatsTable(statsfile, |
| 285 chrome::kStatsMaxThreads, chrome::kStatsMaxCounters); | 297 chrome::kStatsMaxThreads, chrome::kStatsMaxCounters); |
| 286 StatsTable::set_current(stats_table); | 298 StatsTable::set_current(stats_table); |
| 287 | 299 |
| 288 StatsScope<StatsCounterTimer> | 300 StatsScope<StatsCounterTimer> |
| 289 startup_timer(chrome::Counters::chrome_main()); | 301 startup_timer(chrome::Counters::chrome_main()); |
| 290 | 302 |
| 291 // Enable the heap profiler as early as possible! | 303 // Enable the heap profiler as early as possible! |
| 292 EnableHeapProfiler(parsed_command_line); | 304 EnableHeapProfiler(parsed_command_line); |
| 293 | 305 |
| 294 // Enable Message Loop related state asap. | 306 // Enable Message Loop related state asap. |
| 295 if (parsed_command_line.HasSwitch(switches::kMessageLoopHistogrammer)) | 307 if (parsed_command_line.HasSwitch(switches::kMessageLoopHistogrammer)) |
| 296 MessageLoop::EnableHistogrammer(true); | 308 MessageLoop::EnableHistogrammer(true); |
| 297 | 309 |
| 298 std::wstring process_type = | |
| 299 parsed_command_line.GetSwitchValue(switches::kProcessType); | |
| 300 | |
| 301 // Checks if the sandbox is enabled in this process and initializes it if this | 310 // Checks if the sandbox is enabled in this process and initializes it if this |
| 302 // is the case. The crash handler depends on this so it has to be done before | 311 // is the case. The crash handler depends on this so it has to be done before |
| 303 // its initialization. | 312 // its initialization. |
| 304 SandboxInitWrapper sandbox_wrapper; | 313 SandboxInitWrapper sandbox_wrapper; |
| 305 #if defined(OS_WIN) | 314 #if defined(OS_WIN) |
| 306 sandbox_wrapper.SetServices(sandbox_info); | 315 sandbox_wrapper.SetServices(sandbox_info); |
| 307 #endif | 316 #endif |
| 308 sandbox_wrapper.InitializeSandbox(parsed_command_line, process_type); | 317 sandbox_wrapper.InitializeSandbox(parsed_command_line, process_type); |
| 309 | 318 |
| 310 #if defined(OS_WIN) | 319 #if defined(OS_WIN) |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 | 393 |
| 385 _Module.Term(); | 394 _Module.Term(); |
| 386 #endif | 395 #endif |
| 387 | 396 |
| 388 logging::CleanupChromeLogging(); | 397 logging::CleanupChromeLogging(); |
| 389 | 398 |
| 390 return rv; | 399 return rv; |
| 391 } | 400 } |
| 392 | 401 |
| 393 | 402 |
| OLD | NEW |