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

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

Issue 1825823002: Cleanup: LFH only needs to be enabled on XP/2003 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge Created 4 years, 8 months 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) 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 <stddef.h> 8 #include <stddef.h>
9 #include <tchar.h> 9 #include <tchar.h>
10 10
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 return set_process_dpi_aware_func && 123 return set_process_dpi_aware_func &&
124 set_process_dpi_aware_func(); 124 set_process_dpi_aware_func();
125 } 125 }
126 126
127 void EnableHighDPISupport() { 127 void EnableHighDPISupport() {
128 if (!SetProcessDpiAwarenessWrapper(PROCESS_SYSTEM_DPI_AWARE)) { 128 if (!SetProcessDpiAwarenessWrapper(PROCESS_SYSTEM_DPI_AWARE)) {
129 SetProcessDPIAwareWrapper(); 129 SetProcessDPIAwareWrapper();
130 } 130 }
131 } 131 }
132 132
133 void SwitchToLFHeap() {
134 // Only needed on XP but harmless on other Windows flavors.
135 auto crt_heap = _get_heap_handle();
136 ULONG enable_LFH = 2;
137 if (HeapSetInformation(reinterpret_cast<HANDLE>(crt_heap),
138 HeapCompatibilityInformation,
139 &enable_LFH, sizeof(enable_LFH))) {
140 VLOG(1) << "Low fragmentation heap enabled.";
141 }
142 }
143
144 // Returns true if |command_line| contains a /prefetch:# argument where # is in 133 // Returns true if |command_line| contains a /prefetch:# argument where # is in
145 // [1, 8]. 134 // [1, 8].
146 bool HasValidWindowsPrefetchArgument(const base::CommandLine& command_line) { 135 bool HasValidWindowsPrefetchArgument(const base::CommandLine& command_line) {
147 const base::char16 kPrefetchArgumentPrefix[] = L"/prefetch:"; 136 const base::char16 kPrefetchArgumentPrefix[] = L"/prefetch:";
148 137
149 for (const auto& arg : command_line.argv()) { 138 for (const auto& arg : command_line.argv()) {
150 if (arg.size() == arraysize(kPrefetchArgumentPrefix) && 139 if (arg.size() == arraysize(kPrefetchArgumentPrefix) &&
151 base::StartsWith(arg, kPrefetchArgumentPrefix, 140 base::StartsWith(arg, kPrefetchArgumentPrefix,
152 base::CompareCase::SENSITIVE)) { 141 base::CompareCase::SENSITIVE)) {
153 return arg[arraysize(kPrefetchArgumentPrefix) - 1] >= L'1' && 142 return arg[arraysize(kPrefetchArgumentPrefix) - 1] >= L'1' &&
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 187
199 if (process_type == crash_reporter::switches::kCrashpadHandler) { 188 if (process_type == crash_reporter::switches::kCrashpadHandler) {
200 return crash_reporter::RunAsCrashpadHandler( 189 return crash_reporter::RunAsCrashpadHandler(
201 *base::CommandLine::ForCurrentProcess()); 190 *base::CommandLine::ForCurrentProcess());
202 } 191 }
203 192
204 crash_reporter::SetCrashReporterClient(g_chrome_crash_client.Pointer()); 193 crash_reporter::SetCrashReporterClient(g_chrome_crash_client.Pointer());
205 crash_reporter::InitializeCrashpadWithEmbeddedHandler(process_type.empty(), 194 crash_reporter::InitializeCrashpadWithEmbeddedHandler(process_type.empty(),
206 process_type); 195 process_type);
207 196
208 SwitchToLFHeap();
209
210 startup_metric_utils::RecordExeMainEntryPointTime(base::Time::Now()); 197 startup_metric_utils::RecordExeMainEntryPointTime(base::Time::Now());
211 198
212 // Signal Chrome Elf that Chrome has begun to start. 199 // Signal Chrome Elf that Chrome has begun to start.
213 SignalChromeElf(); 200 SignalChromeElf();
214 201
215 // The exit manager is in charge of calling the dtors of singletons. 202 // The exit manager is in charge of calling the dtors of singletons.
216 base::AtExitManager exit_manager; 203 base::AtExitManager exit_manager;
217 204
218 // We don't want to set DPI awareness on pre-Win7 because we don't support 205 // We don't want to set DPI awareness on pre-Win7 because we don't support
219 // DirectWrite there. GDI fonts are kerned very badly, so better to leave 206 // DirectWrite there. GDI fonts are kerned very badly, so better to leave
220 // DPI-unaware and at effective 1.0. See also ShouldUseDirectWrite(). 207 // DPI-unaware and at effective 1.0. See also ShouldUseDirectWrite().
221 if (base::win::GetVersion() >= base::win::VERSION_WIN7) 208 if (base::win::GetVersion() >= base::win::VERSION_WIN7)
222 EnableHighDPISupport(); 209 EnableHighDPISupport();
223 210
224 if (AttemptFastNotify(*command_line)) 211 if (AttemptFastNotify(*command_line))
225 return 0; 212 return 0;
226 213
227 // Load and launch the chrome dll. *Everything* happens inside. 214 // Load and launch the chrome dll. *Everything* happens inside.
228 VLOG(1) << "About to load main DLL."; 215 VLOG(1) << "About to load main DLL.";
229 MainDllLoader* loader = MakeMainDllLoader(); 216 MainDllLoader* loader = MakeMainDllLoader();
230 int rc = loader->Launch(instance); 217 int rc = loader->Launch(instance);
231 loader->RelaunchChromeBrowserWithNewCommandLineIfNeeded(); 218 loader->RelaunchChromeBrowserWithNewCommandLineIfNeeded();
232 delete loader; 219 delete loader;
233 return rc; 220 return rc;
234 } 221 }
OLDNEW
« base/allocator/allocator_shim_win.cc ('K') | « base/process/memory_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698