Updating XTBs based on .GRDs from branch master
[chromium-blink-merge.git] / chrome / app / chrome_main.cc
blob360b7e5def0c4a6700bf22110fe0ef2a7d5f356f
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
3 // found in the LICENSE file.
5 #include "chrome/app/chrome_main_delegate.h"
7 #include "content/public/app/content_main.h"
9 #if defined(OS_WIN)
10 #include "base/debug/dump_without_crashing.h"
11 #include "base/win/win_util.h"
12 #include "chrome/common/chrome_constants.h"
14 #define DLLEXPORT __declspec(dllexport)
16 // We use extern C for the prototype DLLEXPORT to avoid C++ name mangling.
17 extern "C" {
18 DLLEXPORT int __cdecl ChromeMain(HINSTANCE instance,
19 sandbox::SandboxInterfaceInfo* sandbox_info);
21 #elif defined(OS_POSIX)
22 extern "C" {
23 __attribute__((visibility("default")))
24 int ChromeMain(int argc, const char** argv);
26 #endif
28 #if defined(OS_WIN)
29 DLLEXPORT int __cdecl ChromeMain(HINSTANCE instance,
30 sandbox::SandboxInterfaceInfo* sandbox_info) {
31 #elif defined(OS_POSIX)
32 int ChromeMain(int argc, const char** argv) {
33 #endif
34 #if defined(OS_WIN) && defined(ARCH_CPU_X86_64)
35 // VS2013 only checks the existence of FMA3 instructions, not the enabled-ness
36 // of them at the OS level (this is fixed in VS2015). We force off usage of
37 // FMA3 instructions in the CRT to avoid using that path and hitting illegal
38 // instructions when running on CPUs that support FMA3, but OSs that don't.
39 // See http://crbug.com/436603.
40 _set_FMA3_enable(0);
41 #endif // WIN && ARCH_CPU_X86_64
43 ChromeMainDelegate chrome_main_delegate;
44 content::ContentMainParams params(&chrome_main_delegate);
46 #if defined(OS_WIN)
47 // The process should crash when going through abnormal termination.
48 base::win::SetShouldCrashOnProcessDetach(true);
49 base::win::SetAbortBehaviorForCrashReporting();
50 params.instance = instance;
51 params.sandbox_info = sandbox_info;
53 // SetDumpWithoutCrashingFunction must be passed the DumpProcess function
54 // from the EXE and not from the DLL in order for DumpWithoutCrashing to
55 // function correctly.
56 typedef void (__cdecl *DumpProcessFunction)();
57 DumpProcessFunction DumpProcess = reinterpret_cast<DumpProcessFunction>(
58 ::GetProcAddress(::GetModuleHandle(chrome::kBrowserProcessExecutableName),
59 "DumpProcessWithoutCrash"));
60 base::debug::SetDumpWithoutCrashingFunction(DumpProcess);
61 #else
62 params.argc = argc;
63 params.argv = argv;
64 #endif
66 int rv = content::ContentMain(params);
68 #if defined(OS_WIN)
69 base::win::SetShouldCrashOnProcessDetach(false);
70 #endif
72 return rv;