| 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "chrome/app/chrome_main_delegate.h" | 9 #include "chrome/app/chrome_main_delegate.h" |
| 10 #include "chrome/common/features.h" | 10 #include "chrome/common/features.h" |
| 11 #include "content/public/app/content_main.h" | 11 #include "content/public/app/content_main.h" |
| 12 | 12 |
| 13 #if BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES) | 13 #if BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES) |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "chrome/app/mash/mash_runner.h" | 15 #include "chrome/app/mash/mash_runner.h" |
| 16 #include "chrome/common/channel_info.h" | 16 #include "chrome/common/channel_info.h" |
| 17 #include "components/version_info/version_info.h" | 17 #include "components/version_info/version_info.h" |
| 18 #endif | 18 #endif |
| 19 | 19 |
| 20 #if defined(OS_WIN) | 20 #if defined(OS_WIN) |
| 21 #include "base/debug/dump_without_crashing.h" | 21 #include "base/debug/dump_without_crashing.h" |
| 22 #include "base/win/win_util.h" | 22 #include "base/win/win_util.h" |
| 23 #include "chrome/common/chrome_constants.h" | 23 #include "chrome/common/chrome_constants.h" |
| 24 #include "chrome/install_static/install_details.h" | |
| 25 | 24 |
| 26 #define DLLEXPORT __declspec(dllexport) | 25 #define DLLEXPORT __declspec(dllexport) |
| 27 | 26 |
| 28 // We use extern C for the prototype DLLEXPORT to avoid C++ name mangling. | 27 // We use extern C for the prototype DLLEXPORT to avoid C++ name mangling. |
| 29 extern "C" { | 28 extern "C" { |
| 30 DLLEXPORT int __cdecl ChromeMain(HINSTANCE instance, | 29 DLLEXPORT int __cdecl ChromeMain(HINSTANCE instance, |
| 31 sandbox::SandboxInterfaceInfo* sandbox_info, | 30 sandbox::SandboxInterfaceInfo* sandbox_info, |
| 32 int64_t exe_entry_point_ticks); | 31 int64_t exe_entry_point_ticks); |
| 33 } | 32 } |
| 34 #elif defined(OS_POSIX) | 33 #elif defined(OS_POSIX) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 48 #endif | 47 #endif |
| 49 #if defined(OS_WIN) && defined(ARCH_CPU_X86_64) | 48 #if defined(OS_WIN) && defined(ARCH_CPU_X86_64) |
| 50 // VS2013 only checks the existence of FMA3 instructions, not the enabled-ness | 49 // VS2013 only checks the existence of FMA3 instructions, not the enabled-ness |
| 51 // of them at the OS level (this is fixed in VS2015). We force off usage of | 50 // of them at the OS level (this is fixed in VS2015). We force off usage of |
| 52 // FMA3 instructions in the CRT to avoid using that path and hitting illegal | 51 // FMA3 instructions in the CRT to avoid using that path and hitting illegal |
| 53 // instructions when running on CPUs that support FMA3, but OSs that don't. | 52 // instructions when running on CPUs that support FMA3, but OSs that don't. |
| 54 // See http://crbug.com/436603. | 53 // See http://crbug.com/436603. |
| 55 _set_FMA3_enable(0); | 54 _set_FMA3_enable(0); |
| 56 #endif // WIN && ARCH_CPU_X86_64 | 55 #endif // WIN && ARCH_CPU_X86_64 |
| 57 | 56 |
| 58 #if defined(OS_WIN) | |
| 59 install_static::InstallDetails::InitializeFromPrimaryModule( | |
| 60 chrome::kChromeElfDllName); | |
| 61 #endif | |
| 62 | |
| 63 ChromeMainDelegate chrome_main_delegate( | 57 ChromeMainDelegate chrome_main_delegate( |
| 64 base::TimeTicks::FromInternalValue(exe_entry_point_ticks)); | 58 base::TimeTicks::FromInternalValue(exe_entry_point_ticks)); |
| 65 content::ContentMainParams params(&chrome_main_delegate); | 59 content::ContentMainParams params(&chrome_main_delegate); |
| 66 | 60 |
| 67 #if defined(OS_WIN) | 61 #if defined(OS_WIN) |
| 68 // The process should crash when going through abnormal termination. | 62 // The process should crash when going through abnormal termination. |
| 69 base::win::SetShouldCrashOnProcessDetach(true); | 63 base::win::SetShouldCrashOnProcessDetach(true); |
| 70 base::win::SetAbortBehaviorForCrashReporting(); | 64 base::win::SetAbortBehaviorForCrashReporting(); |
| 71 params.instance = instance; | 65 params.instance = instance; |
| 72 params.sandbox_info = sandbox_info; | 66 params.sandbox_info = sandbox_info; |
| 73 | 67 |
| 74 // SetDumpWithoutCrashingFunction must be passed the DumpProcess function | 68 // SetDumpWithoutCrashingFunction must be passed the DumpProcess function |
| 75 // from chrome_elf and not from the DLL in order for DumpWithoutCrashing to | 69 // from the EXE and not from the DLL in order for DumpWithoutCrashing to |
| 76 // function correctly. | 70 // function correctly. |
| 77 typedef void (__cdecl *DumpProcessFunction)(); | 71 typedef void (__cdecl *DumpProcessFunction)(); |
| 78 DumpProcessFunction DumpProcess = reinterpret_cast<DumpProcessFunction>( | 72 DumpProcessFunction DumpProcess = reinterpret_cast<DumpProcessFunction>( |
| 79 ::GetProcAddress(::GetModuleHandle(chrome::kChromeElfDllName), | 73 ::GetProcAddress(::GetModuleHandle(chrome::kChromeElfDllName), |
| 80 "DumpProcessWithoutCrash")); | 74 "DumpProcessWithoutCrash")); |
| 81 CHECK(DumpProcess); | 75 CHECK(DumpProcess); |
| 82 base::debug::SetDumpWithoutCrashingFunction(DumpProcess); | 76 base::debug::SetDumpWithoutCrashingFunction(DumpProcess); |
| 83 | |
| 84 // Verify that chrome_elf and this module (chrome.dll and chrome_child.dll) | |
| 85 // have the same version. | |
| 86 if (install_static::InstallDetails::Get().VersionMismatch()) | |
| 87 base::debug::DumpWithoutCrashing(); | |
| 88 #else | 77 #else |
| 89 params.argc = argc; | 78 params.argc = argc; |
| 90 params.argv = argv; | 79 params.argv = argv; |
| 91 #endif | 80 #endif |
| 92 | 81 |
| 93 #if BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES) | 82 #if BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES) |
| 94 #if !defined(OS_WIN) | 83 #if !defined(OS_WIN) |
| 95 base::CommandLine::Init(params.argc, params.argv); | 84 base::CommandLine::Init(params.argc, params.argv); |
| 96 #endif | 85 #endif |
| 97 | 86 |
| 98 version_info::Channel channel = chrome::GetChannel(); | 87 version_info::Channel channel = chrome::GetChannel(); |
| 99 if (channel == version_info::Channel::CANARY || | 88 if (channel == version_info::Channel::CANARY || |
| 100 channel == version_info::Channel::UNKNOWN) { | 89 channel == version_info::Channel::UNKNOWN) { |
| 101 const base::CommandLine& command_line = | 90 const base::CommandLine& command_line = |
| 102 *base::CommandLine::ForCurrentProcess(); | 91 *base::CommandLine::ForCurrentProcess(); |
| 103 if (command_line.HasSwitch("mash")) | 92 if (command_line.HasSwitch("mash")) |
| 104 return MashMain(); | 93 return MashMain(); |
| 105 } | 94 } |
| 106 #endif // BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES) | 95 #endif // BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES) |
| 107 | 96 |
| 108 int rv = content::ContentMain(params); | 97 int rv = content::ContentMain(params); |
| 109 | 98 |
| 110 #if defined(OS_WIN) | 99 #if defined(OS_WIN) |
| 111 base::win::SetShouldCrashOnProcessDetach(false); | 100 base::win::SetShouldCrashOnProcessDetach(false); |
| 112 #endif | 101 #endif |
| 113 | 102 |
| 114 return rv; | 103 return rv; |
| 115 } | 104 } |
| OLD | NEW |