Roll src/third_party/skia b3eb687:c6f3e2c
[chromium-blink-merge.git] / chrome / app / chrome_main.cc
blob80cd0fb2f8944215f40ee84c89adb23b886750cc
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 ChromeMainDelegate chrome_main_delegate;
35 content::ContentMainParams params(&chrome_main_delegate);
37 #if defined(OS_WIN)
38 // The process should crash when going through abnormal termination.
39 base::win::SetShouldCrashOnProcessDetach(true);
40 base::win::SetAbortBehaviorForCrashReporting();
41 params.instance = instance;
42 params.sandbox_info = sandbox_info;
44 // SetDumpWithoutCrashingFunction must be passed the DumpProcess function
45 // from the EXE and not from the DLL in order for DumpWithoutCrashing to
46 // function correctly.
47 typedef void (__cdecl *DumpProcessFunction)();
48 DumpProcessFunction DumpProcess = reinterpret_cast<DumpProcessFunction>(
49 ::GetProcAddress(::GetModuleHandle(chrome::kBrowserProcessExecutableName),
50 "DumpProcessWithoutCrash"));
51 base::debug::SetDumpWithoutCrashingFunction(DumpProcess);
52 #else
53 params.argc = argc;
54 params.argv = argv;
55 #endif
57 int rv = content::ContentMain(params);
59 #if defined(OS_WIN)
60 base::win::SetShouldCrashOnProcessDetach(false);
61 #endif
63 return rv;