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

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

Issue 1475213004: Revert of Crashpad Windows: Use the Crashpad client instead of Breakpad on Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « chrome/app/chrome_crash_reporter_client.cc ('k') | chrome/app/chrome_main_delegate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <windows.h> 5 #include <windows.h>
6 #include <malloc.h> 6 #include <malloc.h>
7 #include <shellscalingapi.h> 7 #include <shellscalingapi.h>
8 #include <tchar.h> 8 #include <tchar.h>
9 9
10 #include <algorithm>
11 #include <string> 10 #include <string>
12 11
13 #include "base/at_exit.h" 12 #include "base/at_exit.h"
14 #include "base/command_line.h" 13 #include "base/command_line.h"
15 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
16 #include "base/logging.h" 15 #include "base/logging.h"
17 #include "base/strings/utf_string_conversions.h"
18 #include "base/time/time.h" 16 #include "base/time/time.h"
19 #include "base/win/windows_version.h" 17 #include "base/win/windows_version.h"
20 #include "chrome/app/main_dll_loader_win.h" 18 #include "chrome/app/main_dll_loader_win.h"
21 #include "chrome/browser/chrome_process_finder_win.h" 19 #include "chrome/browser/chrome_process_finder_win.h"
22 #include "chrome/browser/policy/policy_path_parser.h" 20 #include "chrome/browser/policy/policy_path_parser.h"
23 #include "chrome/common/chrome_paths_internal.h" 21 #include "chrome/common/chrome_paths_internal.h"
24 #include "chrome/common/chrome_switches.h" 22 #include "chrome/common/chrome_switches.h"
25 #include "chrome_elf/chrome_elf_main.h" 23 #include "chrome_elf/chrome_elf_main.h"
26 #include "components/startup_metric_utils/browser/startup_metric_utils.h" 24 #include "components/startup_metric_utils/browser/startup_metric_utils.h"
27 #include "content/public/common/content_switches.h"
28 #include "content/public/common/result_codes.h" 25 #include "content/public/common/result_codes.h"
29 #include "third_party/crashpad/crashpad/handler/handler_main.h"
30 #include "ui/gfx/win/dpi.h" 26 #include "ui/gfx/win/dpi.h"
31 27
32 namespace { 28 namespace {
33 // List of switches that it's safe to rendezvous early with. Fast start should 29 // List of switches that it's safe to rendezvous early with. Fast start should
34 // not be done if a command line contains a switch not in this set. 30 // not be done if a command line contains a switch not in this set.
35 // Note this is currently stored as a list of two because it's probably faster 31 // Note this is currently stored as a list of two because it's probably faster
36 // to iterate over this small array than building a map for constant time 32 // to iterate over this small array than building a map for constant time
37 // lookups. 33 // lookups.
38 const char* const kFastStartSwitches[] = { 34 const char* const kFastStartSwitches[] = {
39 switches::kProfileDirectory, 35 switches::kProfileDirectory,
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // Only needed on XP but harmless on other Windows flavors. 114 // Only needed on XP but harmless on other Windows flavors.
119 auto crt_heap = _get_heap_handle(); 115 auto crt_heap = _get_heap_handle();
120 ULONG enable_LFH = 2; 116 ULONG enable_LFH = 2;
121 if (HeapSetInformation(reinterpret_cast<HANDLE>(crt_heap), 117 if (HeapSetInformation(reinterpret_cast<HANDLE>(crt_heap),
122 HeapCompatibilityInformation, 118 HeapCompatibilityInformation,
123 &enable_LFH, sizeof(enable_LFH))) { 119 &enable_LFH, sizeof(enable_LFH))) {
124 VLOG(1) << "Low fragmentation heap enabled."; 120 VLOG(1) << "Low fragmentation heap enabled.";
125 } 121 }
126 } 122 }
127 123
128 bool RunAsCrashpadHandler(wchar_t* command_line, int* rc) {
129 const base::CommandLine cmdline = base::CommandLine::FromString(command_line);
130 if (cmdline.GetSwitchValueASCII(switches::kProcessType) ==
131 switches::kCrashpadHandler) {
132 std::vector<base::string16> argv = cmdline.argv();
133 base::string16 process_type =
134 L"--" + base::UTF8ToUTF16(switches::kProcessType) + L"=";
135 argv.erase(std::remove_if(argv.begin(), argv.end(),
136 [&process_type](const base::string16& str) {
137 return str.compare(0, process_type.size(),
138 process_type) == 0;
139 }),
140 argv.end());
141
142 scoped_ptr<char* []> argv_as_utf8(new char*[argv.size() + 1]);
143 std::vector<std::string> storage;
144 storage.reserve(argv.size());
145 for (size_t i = 0; i < argv.size(); ++i) {
146 storage.push_back(base::UTF16ToUTF8(argv[i]));
147 argv_as_utf8[i] = &storage[i][0];
148 }
149 argv_as_utf8[argv.size()] = nullptr;
150 *rc = crashpad::HandlerMain(static_cast<int>(argv.size()),
151 argv_as_utf8.get());
152 return true;
153 }
154 return false;
155 }
156
157 } // namespace 124 } // namespace
158 125
159 #if !defined(WIN_CONSOLE_APP) 126 #if !defined(WIN_CONSOLE_APP)
160 int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prev, wchar_t*, int) { 127 int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prev, wchar_t*, int) {
161 #else 128 #else
162 int main() { 129 int main() {
163 HINSTANCE instance = GetModuleHandle(NULL); 130 HINSTANCE instance = GetModuleHandle(NULL);
164 #endif 131 #endif
165 int rc;
166 if (RunAsCrashpadHandler(GetCommandLine(), &rc))
167 return rc;
168
169 SwitchToLFHeap(); 132 SwitchToLFHeap();
170 133
171 startup_metric_utils::RecordExeMainEntryPointTime(base::Time::Now()); 134 startup_metric_utils::RecordExeMainEntryPointTime(base::Time::Now());
172 135
173 // Signal Chrome Elf that Chrome has begun to start. 136 // Signal Chrome Elf that Chrome has begun to start.
174 SignalChromeElf(); 137 SignalChromeElf();
175 138
176 // Initialize the commandline singleton from the environment. 139 // Initialize the commandline singleton from the environment.
177 base::CommandLine::Init(0, NULL); 140 base::CommandLine::Init(0, NULL);
178 // The exit manager is in charge of calling the dtors of singletons. 141 // The exit manager is in charge of calling the dtors of singletons.
179 base::AtExitManager exit_manager; 142 base::AtExitManager exit_manager;
180 143
181 // We don't want to set DPI awareness on pre-Win7 because we don't support 144 // We don't want to set DPI awareness on pre-Win7 because we don't support
182 // DirectWrite there. GDI fonts are kerned very badly, so better to leave 145 // DirectWrite there. GDI fonts are kerned very badly, so better to leave
183 // DPI-unaware and at effective 1.0. See also ShouldUseDirectWrite(). 146 // DPI-unaware and at effective 1.0. See also ShouldUseDirectWrite().
184 if (base::win::GetVersion() >= base::win::VERSION_WIN7) 147 if (base::win::GetVersion() >= base::win::VERSION_WIN7)
185 EnableHighDPISupport(); 148 EnableHighDPISupport();
186 149
187 if (AttemptFastNotify(*base::CommandLine::ForCurrentProcess())) 150 if (AttemptFastNotify(*base::CommandLine::ForCurrentProcess()))
188 return 0; 151 return 0;
189 152
190 // Load and launch the chrome dll. *Everything* happens inside. 153 // Load and launch the chrome dll. *Everything* happens inside.
191 VLOG(1) << "About to load main DLL."; 154 VLOG(1) << "About to load main DLL.";
192 MainDllLoader* loader = MakeMainDllLoader(); 155 MainDllLoader* loader = MakeMainDllLoader();
193 rc = loader->Launch(instance); 156 int rc = loader->Launch(instance);
194 loader->RelaunchChromeBrowserWithNewCommandLineIfNeeded(); 157 loader->RelaunchChromeBrowserWithNewCommandLineIfNeeded();
195 delete loader; 158 delete loader;
196 return rc; 159 return rc;
197 } 160 }
OLDNEW
« no previous file with comments | « chrome/app/chrome_crash_reporter_client.cc ('k') | chrome/app/chrome_main_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698