Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Side by Side Diff: chrome/app/chrome_main.cc

Issue 2422643002: Windows install_static refactor. (Closed)
Patch Set: sync to position 431863 Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
24 25
25 #define DLLEXPORT __declspec(dllexport) 26 #define DLLEXPORT __declspec(dllexport)
26 27
27 // We use extern C for the prototype DLLEXPORT to avoid C++ name mangling. 28 // We use extern C for the prototype DLLEXPORT to avoid C++ name mangling.
28 extern "C" { 29 extern "C" {
29 DLLEXPORT int __cdecl ChromeMain(HINSTANCE instance, 30 DLLEXPORT int __cdecl ChromeMain(HINSTANCE instance,
30 sandbox::SandboxInterfaceInfo* sandbox_info, 31 sandbox::SandboxInterfaceInfo* sandbox_info,
31 int64_t exe_entry_point_ticks); 32 int64_t exe_entry_point_ticks);
32 } 33 }
33 #elif defined(OS_POSIX) 34 #elif defined(OS_POSIX)
(...skipping 13 matching lines...) Expand all
47 #endif 48 #endif
48 #if defined(OS_WIN) && defined(ARCH_CPU_X86_64) 49 #if defined(OS_WIN) && defined(ARCH_CPU_X86_64)
49 // VS2013 only checks the existence of FMA3 instructions, not the enabled-ness 50 // VS2013 only checks the existence of FMA3 instructions, not the enabled-ness
50 // of them at the OS level (this is fixed in VS2015). We force off usage of 51 // of them at the OS level (this is fixed in VS2015). We force off usage of
51 // FMA3 instructions in the CRT to avoid using that path and hitting illegal 52 // FMA3 instructions in the CRT to avoid using that path and hitting illegal
52 // instructions when running on CPUs that support FMA3, but OSs that don't. 53 // instructions when running on CPUs that support FMA3, but OSs that don't.
53 // See http://crbug.com/436603. 54 // See http://crbug.com/436603.
54 _set_FMA3_enable(0); 55 _set_FMA3_enable(0);
55 #endif // WIN && ARCH_CPU_X86_64 56 #endif // WIN && ARCH_CPU_X86_64
56 57
58 #if defined(OS_WIN)
59 install_static::InstallDetails::InitializeFromPrimaryModule(
60 chrome::kChromeElfDllName);
61 #endif
62
57 ChromeMainDelegate chrome_main_delegate( 63 ChromeMainDelegate chrome_main_delegate(
58 base::TimeTicks::FromInternalValue(exe_entry_point_ticks)); 64 base::TimeTicks::FromInternalValue(exe_entry_point_ticks));
59 content::ContentMainParams params(&chrome_main_delegate); 65 content::ContentMainParams params(&chrome_main_delegate);
60 66
61 #if defined(OS_WIN) 67 #if defined(OS_WIN)
62 // The process should crash when going through abnormal termination. 68 // The process should crash when going through abnormal termination.
63 base::win::SetShouldCrashOnProcessDetach(true); 69 base::win::SetShouldCrashOnProcessDetach(true);
64 base::win::SetAbortBehaviorForCrashReporting(); 70 base::win::SetAbortBehaviorForCrashReporting();
65 params.instance = instance; 71 params.instance = instance;
66 params.sandbox_info = sandbox_info; 72 params.sandbox_info = sandbox_info;
67 73
68 // SetDumpWithoutCrashingFunction must be passed the DumpProcess function 74 // SetDumpWithoutCrashingFunction must be passed the DumpProcess function
69 // from the EXE and not from the DLL in order for DumpWithoutCrashing to 75 // from chrome_elf and not from the DLL in order for DumpWithoutCrashing to
70 // function correctly. 76 // function correctly.
71 typedef void (__cdecl *DumpProcessFunction)(); 77 typedef void (__cdecl *DumpProcessFunction)();
72 DumpProcessFunction DumpProcess = reinterpret_cast<DumpProcessFunction>( 78 DumpProcessFunction DumpProcess = reinterpret_cast<DumpProcessFunction>(
73 ::GetProcAddress(::GetModuleHandle(chrome::kChromeElfDllName), 79 ::GetProcAddress(::GetModuleHandle(chrome::kChromeElfDllName),
74 "DumpProcessWithoutCrash")); 80 "DumpProcessWithoutCrash"));
75 CHECK(DumpProcess); 81 CHECK(DumpProcess);
76 base::debug::SetDumpWithoutCrashingFunction(DumpProcess); 82 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();
77 #else 88 #else
78 params.argc = argc; 89 params.argc = argc;
79 params.argv = argv; 90 params.argv = argv;
80 #endif 91 #endif
81 92
82 #if BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES) 93 #if BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES)
83 #if !defined(OS_WIN) 94 #if !defined(OS_WIN)
84 base::CommandLine::Init(params.argc, params.argv); 95 base::CommandLine::Init(params.argc, params.argv);
85 #endif 96 #endif
86 97
87 version_info::Channel channel = chrome::GetChannel(); 98 version_info::Channel channel = chrome::GetChannel();
88 if (channel == version_info::Channel::CANARY || 99 if (channel == version_info::Channel::CANARY ||
89 channel == version_info::Channel::UNKNOWN) { 100 channel == version_info::Channel::UNKNOWN) {
90 const base::CommandLine& command_line = 101 const base::CommandLine& command_line =
91 *base::CommandLine::ForCurrentProcess(); 102 *base::CommandLine::ForCurrentProcess();
92 if (command_line.HasSwitch("mash")) 103 if (command_line.HasSwitch("mash"))
93 return MashMain(); 104 return MashMain();
94 } 105 }
95 #endif // BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES) 106 #endif // BUILDFLAG(ENABLE_PACKAGE_MASH_SERVICES)
96 107
97 int rv = content::ContentMain(params); 108 int rv = content::ContentMain(params);
98 109
99 #if defined(OS_WIN) 110 #if defined(OS_WIN)
100 base::win::SetShouldCrashOnProcessDetach(false); 111 base::win::SetShouldCrashOnProcessDetach(false);
101 #endif 112 #endif
102 113
103 return rv; 114 return rv;
104 } 115 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698