| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 HKEY_LOCAL_MACHINE; | 51 HKEY_LOCAL_MACHINE; |
| 52 HKEY key; | 52 HKEY key; |
| 53 if (::RegOpenKeyEx(reg_root, key_path, 0, KEY_READ, &key) != ERROR_SUCCESS) | 53 if (::RegOpenKeyEx(reg_root, key_path, 0, KEY_READ, &key) != ERROR_SUCCESS) |
| 54 return false; | 54 return false; |
| 55 | 55 |
| 56 // If 'new_chrome.exe' is present it means chrome was auto-updated while | 56 // If 'new_chrome.exe' is present it means chrome was auto-updated while |
| 57 // running. We need to consult the opv value so we can load the old dll. | 57 // running. We need to consult the opv value so we can load the old dll. |
| 58 // TODO(cpu) : This is solving the same problem as the environment variable | 58 // TODO(cpu) : This is solving the same problem as the environment variable |
| 59 // so one of them will eventually be deprecated. | 59 // so one of them will eventually be deprecated. |
| 60 std::wstring new_chrome_exe(exe_path); | 60 std::wstring new_chrome_exe(exe_path); |
| 61 new_chrome_exe.append(installer::kChromeNewExe); | 61 new_chrome_exe.append(installer_util::kChromeNewExe); |
| 62 if (::PathFileExistsW(new_chrome_exe.c_str()) && | 62 if (::PathFileExistsW(new_chrome_exe.c_str()) && |
| 63 ReadRegistryStr(key, google_update::kRegOldVersionField, version)) { | 63 ReadRegistryStr(key, google_update::kRegOldVersionField, version)) { |
| 64 ::RegCloseKey(key); | 64 ::RegCloseKey(key); |
| 65 return true; | 65 return true; |
| 66 } | 66 } |
| 67 | 67 |
| 68 bool ret = ReadRegistryStr(key, google_update::kRegVersionField, version); | 68 bool ret = ReadRegistryStr(key, google_update::kRegVersionField, version); |
| 69 ::RegCloseKey(key); | 69 ::RegCloseKey(key); |
| 70 return ret; | 70 return ret; |
| 71 } | 71 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 96 // value not being null to determine if this path contains a valid dll. | 96 // value not being null to determine if this path contains a valid dll. |
| 97 HMODULE LoadChromeWithDirectory(std::wstring* dir) { | 97 HMODULE LoadChromeWithDirectory(std::wstring* dir) { |
| 98 ::SetCurrentDirectoryW(dir->c_str()); | 98 ::SetCurrentDirectoryW(dir->c_str()); |
| 99 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); | 99 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); |
| 100 #ifdef _WIN64 | 100 #ifdef _WIN64 |
| 101 if ((cmd_line.GetSwitchValueASCII(switches::kProcessType) == | 101 if ((cmd_line.GetSwitchValueASCII(switches::kProcessType) == |
| 102 switches::kNaClBrokerProcess) || | 102 switches::kNaClBrokerProcess) || |
| 103 (cmd_line.GetSwitchValueASCII(switches::kProcessType) == | 103 (cmd_line.GetSwitchValueASCII(switches::kProcessType) == |
| 104 switches::kNaClLoaderProcess)) { | 104 switches::kNaClLoaderProcess)) { |
| 105 // Load the 64-bit DLL when running in a 64-bit process. | 105 // Load the 64-bit DLL when running in a 64-bit process. |
| 106 dir->append(installer::kChromeNaCl64Dll); | 106 dir->append(installer_util::kChromeNaCl64Dll); |
| 107 } else { | 107 } else { |
| 108 // Only NaCl broker and loader can be launched as Win64 processes. | 108 // Only NaCl broker and loader can be launched as Win64 processes. |
| 109 NOTREACHED(); | 109 NOTREACHED(); |
| 110 return NULL; | 110 return NULL; |
| 111 } | 111 } |
| 112 #else | 112 #else |
| 113 dir->append(installer::kChromeDll); | 113 dir->append(installer_util::kChromeDll); |
| 114 #endif | 114 #endif |
| 115 | 115 |
| 116 #ifdef NDEBUG | 116 #ifdef NDEBUG |
| 117 // Experimental pre-reading optimization | 117 // Experimental pre-reading optimization |
| 118 // The idea is to pre read significant portion of chrome.dll in advance | 118 // The idea is to pre read significant portion of chrome.dll in advance |
| 119 // so that subsequent hard page faults are avoided. | 119 // so that subsequent hard page faults are avoided. |
| 120 if (!cmd_line.HasSwitch(switches::kProcessType)) { | 120 if (!cmd_line.HasSwitch(switches::kProcessType)) { |
| 121 // The kernel brings in 8 pages for the code section at a time and 4 pages | 121 // The kernel brings in 8 pages for the code section at a time and 4 pages |
| 122 // for other sections. We can skip over these pages to avoid a soft page | 122 // for other sections. We can skip over these pages to avoid a soft page |
| 123 // fault which may not occur during code execution. However skipping 4K at | 123 // fault which may not occur during code execution. However skipping 4K at |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 } | 332 } |
| 333 }; | 333 }; |
| 334 | 334 |
| 335 MainDllLoader* MakeMainDllLoader() { | 335 MainDllLoader* MakeMainDllLoader() { |
| 336 #if defined(GOOGLE_CHROME_BUILD) | 336 #if defined(GOOGLE_CHROME_BUILD) |
| 337 return new ChromeDllLoader(); | 337 return new ChromeDllLoader(); |
| 338 #else | 338 #else |
| 339 return new ChromiumDllLoader(); | 339 return new ChromiumDllLoader(); |
| 340 #endif | 340 #endif |
| 341 } | 341 } |
| OLD | NEW |