| 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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 | 238 |
| 239 // The exit manager is in charge of calling the dtors of singleton objects. | 239 // The exit manager is in charge of calling the dtors of singleton objects. |
| 240 base::AtExitManager exit_manager; | 240 base::AtExitManager exit_manager; |
| 241 | 241 |
| 242 // We need this pool for all the objects created before we get to the | 242 // We need this pool for all the objects created before we get to the |
| 243 // event loop, but we don't want to leave them hanging around until the | 243 // event loop, but we don't want to leave them hanging around until the |
| 244 // app quits. Each "main" needs to flush this pool right before it goes into | 244 // app quits. Each "main" needs to flush this pool right before it goes into |
| 245 // its main event loop to get rid of the cruft. | 245 // its main event loop to get rid of the cruft. |
| 246 base::ScopedNSAutoreleasePool autorelease_pool; | 246 base::ScopedNSAutoreleasePool autorelease_pool; |
| 247 | 247 |
| 248 #if defined(OS_LINUX) | |
| 249 // gtk_init() can change |argc| and |argv| and thus must be called before | |
| 250 // CommandLine::Init(). | |
| 251 // TODO(estade): we should make a copy of |argv| instead of const_casting | |
| 252 // it. | |
| 253 gtk_init(&argc, const_cast<char***>(&argv)); | |
| 254 #endif | |
| 255 | |
| 256 // Initialize the command line. | 248 // Initialize the command line. |
| 257 #if defined(OS_WIN) | 249 #if defined(OS_WIN) |
| 258 CommandLine::Init(0, NULL); | 250 CommandLine::Init(0, NULL); |
| 259 #else | 251 #else |
| 260 CommandLine::Init(argc, argv); | 252 CommandLine::Init(argc, argv); |
| 261 #endif | 253 #endif |
| 262 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); | 254 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); |
| 263 | 255 |
| 264 #if defined(OS_WIN) | 256 #if defined(OS_WIN) |
| 265 // Must do this before any other usage of command line! | 257 // Must do this before any other usage of command line! |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 rv = RendererMain(main_params); | 363 rv = RendererMain(main_params); |
| 372 } else if (process_type == switches::kPluginProcess) { | 364 } else if (process_type == switches::kPluginProcess) { |
| 373 #if defined(OS_WIN) | 365 #if defined(OS_WIN) |
| 374 rv = PluginMain(main_params); | 366 rv = PluginMain(main_params); |
| 375 #endif | 367 #endif |
| 376 } else if (process_type == switches::kWorkerProcess) { | 368 } else if (process_type == switches::kWorkerProcess) { |
| 377 #if defined(OS_WIN) | 369 #if defined(OS_WIN) |
| 378 rv = WorkerMain(main_params); | 370 rv = WorkerMain(main_params); |
| 379 #endif | 371 #endif |
| 380 } else if (process_type.empty()) { | 372 } else if (process_type.empty()) { |
| 373 #if defined(OS_LINUX) |
| 374 // gtk_init() can change |argc| and |argv|, but nobody else uses them. |
| 375 gtk_init(&argc, const_cast<char***>(&argv)); |
| 376 #endif |
| 377 |
| 381 ScopedOleInitializer ole_initializer; | 378 ScopedOleInitializer ole_initializer; |
| 382 rv = BrowserMain(main_params); | 379 rv = BrowserMain(main_params); |
| 383 } else { | 380 } else { |
| 384 NOTREACHED() << "Unknown process type"; | 381 NOTREACHED() << "Unknown process type"; |
| 385 } | 382 } |
| 386 | 383 |
| 387 if (!process_type.empty()) { | 384 if (!process_type.empty()) { |
| 388 ResourceBundle::CleanupSharedInstance(); | 385 ResourceBundle::CleanupSharedInstance(); |
| 389 } | 386 } |
| 390 | 387 |
| 391 #if defined(OS_WIN) | 388 #if defined(OS_WIN) |
| 392 #ifdef _CRTDBG_MAP_ALLOC | 389 #ifdef _CRTDBG_MAP_ALLOC |
| 393 _CrtDumpMemoryLeaks(); | 390 _CrtDumpMemoryLeaks(); |
| 394 #endif // _CRTDBG_MAP_ALLOC | 391 #endif // _CRTDBG_MAP_ALLOC |
| 395 | 392 |
| 396 _Module.Term(); | 393 _Module.Term(); |
| 397 #endif | 394 #endif |
| 398 | 395 |
| 399 logging::CleanupChromeLogging(); | 396 logging::CleanupChromeLogging(); |
| 400 | 397 |
| 401 return rv; | 398 return rv; |
| 402 } | 399 } |
| 403 | 400 |
| 404 | 401 |
| OLD | NEW |