| 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 "chrome/app/chrome_main_delegate.h" | 5 #include "chrome/app/chrome_main_delegate.h" |
| 6 | 6 |
| 7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/cpu.h" | 9 #include "base/cpu.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 CHECK(process_type.empty()) << "Unable to get the user data directory " | 381 CHECK(process_type.empty()) << "Unable to get the user data directory " |
| 382 << "for process type: " << process_type; | 382 << "for process type: " << process_type; |
| 383 } | 383 } |
| 384 | 384 |
| 385 // Append the fallback user data directory to the commandline. Otherwise, | 385 // Append the fallback user data directory to the commandline. Otherwise, |
| 386 // child or service processes will attempt to use the invalid directory. | 386 // child or service processes will attempt to use the invalid directory. |
| 387 if (specified_directory_was_invalid) | 387 if (specified_directory_was_invalid) |
| 388 command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir); | 388 command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir); |
| 389 } | 389 } |
| 390 | 390 |
| 391 #if !defined(OS_ANDROID) |
| 392 void InitLogging(const std::string& process_type) { |
| 393 logging::OldFileDeletionState file_state = |
| 394 logging::APPEND_TO_OLD_LOG_FILE; |
| 395 if (process_type.empty()) { |
| 396 file_state = logging::DELETE_OLD_LOG_FILE; |
| 397 } |
| 398 const base::CommandLine& command_line = |
| 399 *base::CommandLine::ForCurrentProcess(); |
| 400 logging::InitChromeLogging(command_line, file_state); |
| 401 } |
| 402 #endif |
| 403 |
| 391 } // namespace | 404 } // namespace |
| 392 | 405 |
| 393 ChromeMainDelegate::ChromeMainDelegate() { | 406 ChromeMainDelegate::ChromeMainDelegate() { |
| 394 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) | 407 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) |
| 395 // Record the startup process creation time on supported platforms. | 408 // Record the startup process creation time on supported platforms. |
| 396 startup_metric_utils::RecordStartupProcessCreationTime( | 409 startup_metric_utils::RecordStartupProcessCreationTime( |
| 397 base::CurrentProcessInfo::CreationTime()); | 410 base::CurrentProcessInfo::CreationTime()); |
| 398 #endif | 411 #endif |
| 399 | 412 |
| 400 // On Android the main entry point time is the time when the Java code starts. | 413 // On Android the main entry point time is the time when the Java code starts. |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 InitializeUserDataDir(); | 668 InitializeUserDataDir(); |
| 656 | 669 |
| 657 // Register component_updater PathProvider after DIR_USER_DATA overidden by | 670 // Register component_updater PathProvider after DIR_USER_DATA overidden by |
| 658 // command line flags. Maybe move the chrome PathProvider down here also? | 671 // command line flags. Maybe move the chrome PathProvider down here also? |
| 659 component_updater::RegisterPathProvider(chrome::DIR_USER_DATA); | 672 component_updater::RegisterPathProvider(chrome::DIR_USER_DATA); |
| 660 | 673 |
| 661 // Enable Message Loop related state asap. | 674 // Enable Message Loop related state asap. |
| 662 if (command_line.HasSwitch(switches::kMessageLoopHistogrammer)) | 675 if (command_line.HasSwitch(switches::kMessageLoopHistogrammer)) |
| 663 base::MessageLoop::EnableHistogrammer(true); | 676 base::MessageLoop::EnableHistogrammer(true); |
| 664 | 677 |
| 665 #if !defined(OS_ANDROID) | 678 #if !defined(OS_ANDROID) && !defined(OS_WIN) |
| 666 // Android does InitLogging when library is loaded. Skip here. | 679 // Android does InitLogging when library is loaded. Skip here. |
| 667 logging::OldFileDeletionState file_state = | 680 // For windows we call InitLogging when the sandbox is initialized. |
| 668 logging::APPEND_TO_OLD_LOG_FILE; | 681 InitLogging(process_type); |
| 669 if (process_type.empty()) { | |
| 670 file_state = logging::DELETE_OLD_LOG_FILE; | |
| 671 } | |
| 672 logging::InitChromeLogging(command_line, file_state); | |
| 673 #endif | 682 #endif |
| 674 | 683 |
| 675 #if defined(OS_WIN) | 684 #if defined(OS_WIN) |
| 676 // TODO(zturner): Throbber icons are still stored in chrome.dll, this can be | 685 // TODO(zturner): Throbber icons are still stored in chrome.dll, this can be |
| 677 // killed once those are merged into resources.pak. See | 686 // killed once those are merged into resources.pak. See |
| 678 // GlassBrowserFrameView::InitThrobberIcons() and http://crbug.com/368327. | 687 // GlassBrowserFrameView::InitThrobberIcons() and http://crbug.com/368327. |
| 679 ui::SetResourcesDataDLL(_AtlBaseModule.GetResourceInstance()); | 688 ui::SetResourcesDataDLL(_AtlBaseModule.GetResourceInstance()); |
| 680 #endif | 689 #endif |
| 681 | 690 |
| 682 if (SubprocessNeedsResourceBundle(process_type)) { | 691 if (SubprocessNeedsResourceBundle(process_type)) { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 crash_keys::SetSwitchesFromCommandLine(&command_line); | 782 crash_keys::SetSwitchesFromCommandLine(&command_line); |
| 774 } | 783 } |
| 775 | 784 |
| 776 void ChromeMainDelegate::SandboxInitialized(const std::string& process_type) { | 785 void ChromeMainDelegate::SandboxInitialized(const std::string& process_type) { |
| 777 // Note: If you are adding a new process type below, be sure to adjust the | 786 // Note: If you are adding a new process type below, be sure to adjust the |
| 778 // AdjustLinuxOOMScore function too. | 787 // AdjustLinuxOOMScore function too. |
| 779 #if defined(OS_LINUX) | 788 #if defined(OS_LINUX) |
| 780 AdjustLinuxOOMScore(process_type); | 789 AdjustLinuxOOMScore(process_type); |
| 781 #endif | 790 #endif |
| 782 #if defined(OS_WIN) | 791 #if defined(OS_WIN) |
| 792 InitLogging(process_type); |
| 783 SuppressWindowsErrorDialogs(); | 793 SuppressWindowsErrorDialogs(); |
| 784 #endif | 794 #endif |
| 785 | 795 |
| 786 #if defined(CHROME_MULTIPLE_DLL_CHILD) || !defined(CHROME_MULTIPLE_DLL_BROWSER) | 796 #if defined(CHROME_MULTIPLE_DLL_CHILD) || !defined(CHROME_MULTIPLE_DLL_BROWSER) |
| 787 #if !defined(DISABLE_NACL) | 797 #if !defined(DISABLE_NACL) |
| 788 ChromeContentClient::SetNaClEntryFunctions( | 798 ChromeContentClient::SetNaClEntryFunctions( |
| 789 nacl_plugin::PPP_GetInterface, | 799 nacl_plugin::PPP_GetInterface, |
| 790 nacl_plugin::PPP_InitializeModule, | 800 nacl_plugin::PPP_InitializeModule, |
| 791 nacl_plugin::PPP_ShutdownModule); | 801 nacl_plugin::PPP_ShutdownModule); |
| 792 #endif | 802 #endif |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 case version_info::Channel::CANARY: | 955 case version_info::Channel::CANARY: |
| 946 return true; | 956 return true; |
| 947 case version_info::Channel::DEV: | 957 case version_info::Channel::DEV: |
| 948 case version_info::Channel::BETA: | 958 case version_info::Channel::BETA: |
| 949 case version_info::Channel::STABLE: | 959 case version_info::Channel::STABLE: |
| 950 default: | 960 default: |
| 951 // Don't enable instrumentation. | 961 // Don't enable instrumentation. |
| 952 return false; | 962 return false; |
| 953 } | 963 } |
| 954 } | 964 } |
| OLD | NEW |