| OLD | NEW |
| 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 "base/win/windows_version.h" | 5 #include "base/win/windows_version.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/utf_string_conversions.h" |
| 11 #include "base/win/registry.h" |
| 10 | 12 |
| 11 namespace base { | 13 namespace base { |
| 12 namespace win { | 14 namespace win { |
| 13 | 15 |
| 14 // static | 16 // static |
| 15 OSInfo* OSInfo::GetInstance() { | 17 OSInfo* OSInfo::GetInstance() { |
| 16 // Note: we don't use the Singleton class because it depends on AtExitManager, | 18 // Note: we don't use the Singleton class because it depends on AtExitManager, |
| 17 // and it's convenient for other modules to use this classs without it. This | 19 // and it's convenient for other modules to use this classs without it. This |
| 18 // pattern is copied from gurl.cc. | 20 // pattern is copied from gurl.cc. |
| 19 static OSInfo* info; | 21 static OSInfo* info; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 case PROCESSOR_ARCHITECTURE_AMD64: architecture_ = X64_ARCHITECTURE; break; | 71 case PROCESSOR_ARCHITECTURE_AMD64: architecture_ = X64_ARCHITECTURE; break; |
| 70 case PROCESSOR_ARCHITECTURE_IA64: architecture_ = IA64_ARCHITECTURE; break; | 72 case PROCESSOR_ARCHITECTURE_IA64: architecture_ = IA64_ARCHITECTURE; break; |
| 71 } | 73 } |
| 72 processors_ = system_info.dwNumberOfProcessors; | 74 processors_ = system_info.dwNumberOfProcessors; |
| 73 allocation_granularity_ = system_info.dwAllocationGranularity; | 75 allocation_granularity_ = system_info.dwAllocationGranularity; |
| 74 } | 76 } |
| 75 | 77 |
| 76 OSInfo::~OSInfo() { | 78 OSInfo::~OSInfo() { |
| 77 } | 79 } |
| 78 | 80 |
| 81 std::string OSInfo::processor_model_name() { |
| 82 if (processor_model_name_.empty()) { |
| 83 const wchar_t kProcessorNameString[] = |
| 84 L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"; |
| 85 base::win::RegKey key(HKEY_LOCAL_MACHINE, kProcessorNameString, KEY_READ); |
| 86 string16 value; |
| 87 key.ReadValue(L"ProcessorNameString", &value); |
| 88 processor_model_name_ = UTF16ToUTF8(value); |
| 89 } |
| 90 return processor_model_name_; |
| 91 } |
| 92 |
| 79 // static | 93 // static |
| 80 OSInfo::WOW64Status OSInfo::GetWOW64StatusForProcess(HANDLE process_handle) { | 94 OSInfo::WOW64Status OSInfo::GetWOW64StatusForProcess(HANDLE process_handle) { |
| 81 typedef BOOL (WINAPI* IsWow64ProcessFunc)(HANDLE, PBOOL); | 95 typedef BOOL (WINAPI* IsWow64ProcessFunc)(HANDLE, PBOOL); |
| 82 IsWow64ProcessFunc is_wow64_process = reinterpret_cast<IsWow64ProcessFunc>( | 96 IsWow64ProcessFunc is_wow64_process = reinterpret_cast<IsWow64ProcessFunc>( |
| 83 GetProcAddress(GetModuleHandle(L"kernel32.dll"), "IsWow64Process")); | 97 GetProcAddress(GetModuleHandle(L"kernel32.dll"), "IsWow64Process")); |
| 84 if (!is_wow64_process) | 98 if (!is_wow64_process) |
| 85 return WOW64_DISABLED; | 99 return WOW64_DISABLED; |
| 86 BOOL is_wow64 = FALSE; | 100 BOOL is_wow64 = FALSE; |
| 87 if (!(*is_wow64_process)(process_handle, &is_wow64)) | 101 if (!(*is_wow64_process)(process_handle, &is_wow64)) |
| 88 return WOW64_UNKNOWN; | 102 return WOW64_UNKNOWN; |
| 89 return is_wow64 ? WOW64_ENABLED : WOW64_DISABLED; | 103 return is_wow64 ? WOW64_ENABLED : WOW64_DISABLED; |
| 90 } | 104 } |
| 91 | 105 |
| 92 Version GetVersion() { | 106 Version GetVersion() { |
| 93 return OSInfo::GetInstance()->version(); | 107 return OSInfo::GetInstance()->version(); |
| 94 } | 108 } |
| 95 | 109 |
| 96 } // namespace win | 110 } // namespace win |
| 97 } // namespace base | 111 } // namespace base |
| OLD | NEW |