OLD | NEW |
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 <shlwapi.h> | 6 #include <shlwapi.h> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/environment.h" | 10 #include "base/environment.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 } | 161 } |
162 #endif // if defined(GOOGLE_CHROME_BUILD) | 162 #endif // if defined(GOOGLE_CHROME_BUILD) |
163 #endif // if defined(OS_WIN) | 163 #endif // if defined(OS_WIN) |
164 | 164 |
165 // Expects that |dir| has a trailing backslash. |dir| is modified so it | 165 // Expects that |dir| has a trailing backslash. |dir| is modified so it |
166 // contains the full path that was tried. Caller must check for the return | 166 // contains the full path that was tried. Caller must check for the return |
167 // value not being null to determine if this path contains a valid dll. | 167 // value not being null to determine if this path contains a valid dll. |
168 HMODULE LoadChromeWithDirectory(std::wstring* dir) { | 168 HMODULE LoadChromeWithDirectory(std::wstring* dir) { |
169 ::SetCurrentDirectoryW(dir->c_str()); | 169 ::SetCurrentDirectoryW(dir->c_str()); |
170 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); | 170 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); |
171 #ifdef _WIN64 | |
172 if ((cmd_line.GetSwitchValueASCII(switches::kProcessType) == | |
173 switches::kNaClBrokerProcess) || | |
174 (cmd_line.GetSwitchValueASCII(switches::kProcessType) == | |
175 switches::kNaClLoaderProcess)) { | |
176 // Load the 64-bit DLL when running in a 64-bit process. | |
177 dir->append(installer::kChromeNaCl64Dll); | |
178 } else { | |
179 // Only NaCl broker and loader can be launched as Win64 processes. | |
180 NOTREACHED(); | |
181 return NULL; | |
182 } | |
183 #else | |
184 dir->append(installer::kChromeDll); | 171 dir->append(installer::kChromeDll); |
185 #endif | |
186 | 172 |
187 #ifndef WIN_DISABLE_PREREAD | 173 #ifndef WIN_DISABLE_PREREAD |
188 #ifdef NDEBUG | 174 #ifdef NDEBUG |
189 // Experimental pre-reading optimization | 175 // Experimental pre-reading optimization |
190 // The idea is to pre-read a significant portion of chrome.dll in advance | 176 // The idea is to pre-read a significant portion of chrome.dll in advance |
191 // so that subsequent hard page faults are avoided. | 177 // so that subsequent hard page faults are avoided. |
192 // | 178 // |
193 // Pre-read may be disabled at compile time by defining WIN_DISABLE_PREREAD, | 179 // Pre-read may be disabled at compile time by defining WIN_DISABLE_PREREAD, |
194 // but by default it is enabled in release builds. The ability to disable it | 180 // but by default it is enabled in release builds. The ability to disable it |
195 // is useful for evaluating competing optimization techniques. | 181 // is useful for evaluating competing optimization techniques. |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 } | 396 } |
411 }; | 397 }; |
412 | 398 |
413 MainDllLoader* MakeMainDllLoader() { | 399 MainDllLoader* MakeMainDllLoader() { |
414 #if defined(GOOGLE_CHROME_BUILD) | 400 #if defined(GOOGLE_CHROME_BUILD) |
415 return new ChromeDllLoader(); | 401 return new ChromeDllLoader(); |
416 #else | 402 #else |
417 return new ChromiumDllLoader(); | 403 return new ChromiumDllLoader(); |
418 #endif | 404 #endif |
419 } | 405 } |
OLD | NEW |