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"
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.
18 DLLEXPORT
int __cdecl
ChromeMain(HINSTANCE instance
,
19 sandbox::SandboxInterfaceInfo
* sandbox_info
);
21 #elif defined(OS_POSIX)
23 __attribute__((visibility("default")))
24 int ChromeMain(int argc
, const char** argv
);
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
) {
34 ChromeMainDelegate chrome_main_delegate
;
35 content::ContentMainParams
params(&chrome_main_delegate
);
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
);
57 int rv
= content::ContentMain(params
);
60 base::win::SetShouldCrashOnProcessDetach(false);