Remove dead code
With the removal of the file corruption checker,
SystemUtil::{GetFileVersion(), GetFileVersionString()} are no longer
used in production code. Hence we can safely remove them.
No user-visible change is intended.
BUG=
TEST=
REF_BUG=27182026
REF_CL=114714920
REF_TIME=2016-02-15T18:07:37-08:00
REF_TIME_RAW=1455588457 -0800
Yohei Yukawa
8 years ago
135 | 135 | 'VCLinkerTool': { |
136 | 136 | 'AdditionalDependencies': [ |
137 | 137 | 'aux_ulib.lib', # used in 'win_util.cc' |
138 | 'propsys.lib', # used in 'win_util.cc' | |
139 | 'version.lib', # used in 'util.cc' | |
140 | 138 | 'KtmW32.lib', # used in 'file_util.cc' |
141 | 139 | ], |
142 | 140 | }, |
767 | 767 | return Singleton<SystemDirectoryCache>::get()->system_dir(); |
768 | 768 | } |
769 | 769 | |
770 | bool SystemUtil::GetFileVersion(const wstring &file_fullpath, int *major, | |
771 | int *minor, int *build, int *revision) { | |
772 | DCHECK(major); | |
773 | DCHECK(minor); | |
774 | DCHECK(build); | |
775 | DCHECK(revision); | |
776 | string path; | |
777 | Util::WideToUTF8(file_fullpath.c_str(), &path); | |
778 | ||
779 | // Accoding to KB826496, we should check file existence. | |
780 | // http://support.microsoft.com/kb/826496 | |
781 | if (!FileUtil::FileExists(path)) { | |
782 | LOG(ERROR) << "file not found"; | |
783 | return false; | |
784 | } | |
785 | ||
786 | DWORD handle = 0; | |
787 | const DWORD version_size = | |
788 | ::GetFileVersionInfoSizeW(file_fullpath.c_str(), &handle); | |
789 | ||
790 | if (version_size == 0) { | |
791 | LOG(ERROR) << "GetFileVersionInfoSizeW failed." | |
792 | << " error = " << ::GetLastError(); | |
793 | return false; | |
794 | } | |
795 | ||
796 | unique_ptr<BYTE[]> version_buffer(new BYTE[version_size]); | |
797 | ||
798 | if (!::GetFileVersionInfoW(file_fullpath.c_str(), 0, | |
799 | version_size, version_buffer.get())) { | |
800 | LOG(ERROR) << "GetFileVersionInfo failed." | |
801 | << " error = " << ::GetLastError(); | |
802 | return false; | |
803 | } | |
804 | ||
805 | VS_FIXEDFILEINFO *fixed_fileinfo = nullptr; | |
806 | UINT length = 0; | |
807 | if (!::VerQueryValueW(version_buffer.get(), L"\\", | |
808 | reinterpret_cast<LPVOID *>(&fixed_fileinfo), | |
809 | &length)) { | |
810 | LOG(ERROR) << "VerQueryValue failed." | |
811 | << " error = " << ::GetLastError(); | |
812 | return false; | |
813 | } | |
814 | ||
815 | *major = HIWORD(fixed_fileinfo->dwFileVersionMS); | |
816 | *minor = LOWORD(fixed_fileinfo->dwFileVersionMS); | |
817 | *build = HIWORD(fixed_fileinfo->dwFileVersionLS); | |
818 | *revision = LOWORD(fixed_fileinfo->dwFileVersionLS); | |
819 | ||
820 | return true; | |
821 | } | |
822 | ||
823 | string SystemUtil::GetFileVersionString(const wstring &file_fullpath) { | |
824 | int major, minor, build, revision; | |
825 | if (!GetFileVersion(file_fullpath, &major, &minor, &build, &revision)) { | |
826 | return ""; | |
827 | } | |
828 | ||
829 | stringstream buf; | |
830 | buf << major << "." << minor << "." << build << "." << revision; | |
831 | ||
832 | return buf.str(); | |
833 | } | |
834 | ||
835 | 770 | string SystemUtil::GetMSCTFAsmCacheReadyEventName() { |
836 | 771 | const string &session_id = GetSessionIdString(); |
837 | 772 | if (session_id.empty()) { |
147 | 147 | // This function is thread safe. |
148 | 148 | static const wchar_t *GetSystemDir(); |
149 | 149 | |
150 | // Retrieves version of the specified file. | |
151 | // If the function fails, returns false. | |
152 | static bool GetFileVersion(const wstring &file_fullpath, | |
153 | int *major, | |
154 | int *minor, | |
155 | int *build, | |
156 | int *revision); | |
157 | ||
158 | // Retrieves version string of the specified file. | |
159 | // The version string consists of 4 digits separated by comma | |
160 | // like "X.YY.ZZZ.WWWW". | |
161 | // If the function fails, the return value is an empty string. | |
162 | static string GetFileVersionString(const wstring &file_fullpath); | |
163 | ||
164 | 150 | // Returns "MSCTF.AsmCacheReady.<desktop name><session #>" to work around |
165 | 151 | // b/5765783. |
166 | 152 | // Returns an empty string if fails. |
60 | 60 | SystemUtil::IS_WINDOWS_X64_DEFAULT_MODE); |
61 | 61 | } |
62 | 62 | |
63 | #ifdef OS_WIN | |
64 | TEST_F(SystemUtilTest, GetFileVersion) { | |
65 | const wchar_t kDllName[] = L"kernel32.dll"; | |
66 | ||
67 | wstring path = SystemUtil::GetSystemDir(); | |
68 | path += L"\\"; | |
69 | path += kDllName; | |
70 | ||
71 | int major, minor, build, revision; | |
72 | EXPECT_TRUE( | |
73 | SystemUtil::GetFileVersion(path, &major, &minor, &build, &revision)); | |
74 | } | |
75 | ||
76 | TEST_F(SystemUtilTest, GetFileVersionStringTest) { | |
77 | const wchar_t kDllName[] = L"kernel32.dll"; | |
78 | ||
79 | wstring path = SystemUtil::GetSystemDir(); | |
80 | path += L"\\"; | |
81 | path += kDllName; | |
82 | ||
83 | const string version_string = SystemUtil::GetFileVersionString(path); | |
84 | ||
85 | vector<string> numbers; | |
86 | Util::SplitStringUsing(version_string, ".", &numbers); | |
87 | ||
88 | // must be 4 digits. | |
89 | ASSERT_EQ(numbers.size(), 4); | |
90 | ||
91 | // must be integer. | |
92 | uint32 dummy = 0; | |
93 | ASSERT_TRUE(NumberUtil::SafeStrToUInt32(numbers[0], &dummy)); | |
94 | ASSERT_TRUE(NumberUtil::SafeStrToUInt32(numbers[1], &dummy)); | |
95 | ASSERT_TRUE(NumberUtil::SafeStrToUInt32(numbers[2], &dummy)); | |
96 | ASSERT_TRUE(NumberUtil::SafeStrToUInt32(numbers[3], &dummy)); | |
97 | } | |
98 | #endif // OS_WIN | |
99 | ||
100 | 63 | #ifndef OS_NACL |
101 | 64 | TEST_F(SystemUtilTest, GetTotalPhysicalMemoryTest) { |
102 | 65 | EXPECT_GT(SystemUtil::GetTotalPhysicalMemory(), 0); |
0 | 0 | MAJOR=2 |
1 | 1 | MINOR=17 |
2 | BUILD=2491 | |
2 | BUILD=2492 | |
3 | 3 | REVISION=102 |
4 | 4 | # NACL_DICTIONARY_VERSION is the target version of the system dictionary to be |
5 | 5 | # downloaded by NaCl Mozc. |
97 | 97 | }, |
98 | 98 | 'VCLinkerTool': { |
99 | 99 | 'DelayLoadDLLs': [ |
100 | 'version.dll', | |
101 | 100 | 'wininet.dll', |
102 | 101 | ], |
103 | 102 | }, |
35 | 35 | |
36 | 36 | #include <string> |
37 | 37 | |
38 | #include "base/system_util.h" | |
39 | 38 | #include "base/util.h" |
40 | 39 | #include "base/win_util.h" |
41 | 40 | #include "win32/base/accessible_object.h" |
69 | 68 | } |
70 | 69 | |
71 | 70 | } // namespace |
72 | ||
73 | BrowserInfo::Version::Version() | |
74 | : major(0), | |
75 | minor(0), | |
76 | build(0), | |
77 | revision(0) {} | |
78 | 71 | |
79 | 72 | // static |
80 | 73 | BrowserInfo::BrowserType BrowserInfo::GetBrowerType() { |
189 | 182 | } |
190 | 183 | |
191 | 184 | // static |
192 | BrowserInfo::Version BrowserInfo::GetProcessModuleVersion() { | |
193 | if (!g_exe_module_ver_initialized_) { | |
194 | bool loder_locked = false; | |
195 | if (!WinUtil::IsDLLSynchronizationHeld(&loder_locked) || | |
196 | loder_locked) { | |
197 | return Version(); | |
198 | } | |
199 | ||
200 | const wstring &exe_path = GetProcessModuleName(); | |
201 | if (!exe_path.empty()) { | |
202 | SystemUtil::GetFileVersion(exe_path, | |
203 | &g_exe_module_ver_major_, | |
204 | &g_exe_module_ver_minor_, | |
205 | &g_exe_module_ver_build_, | |
206 | &g_exe_module_ver_revision_); | |
207 | } | |
208 | g_exe_module_ver_initialized_ = true; | |
209 | } | |
210 | ||
211 | Version version; | |
212 | version.major = g_exe_module_ver_major_; | |
213 | version.minor = g_exe_module_ver_minor_; | |
214 | version.build = g_exe_module_ver_build_; | |
215 | version.revision = g_exe_module_ver_revision_; | |
216 | return version; | |
217 | } | |
218 | ||
219 | // static | |
220 | 185 | void BrowserInfo::OnDllProcessAttach(HINSTANCE module_handle, |
221 | 186 | bool static_loading) { |
222 | 187 | const DWORD copied_len_without_null = ::GetModuleFileName( |
47 | 47 | kBrowserTypeIE, |
48 | 48 | kBrowserTypeOpera, |
49 | 49 | }; |
50 | struct Version { | |
51 | Version(); | |
52 | int major; | |
53 | int minor; | |
54 | int build; | |
55 | int revision; | |
56 | }; | |
57 | 50 | |
58 | 51 | static BrowserType GetBrowerType(); |
59 | static Version GetProcessModuleVersion(); | |
60 | 52 | |
61 | 53 | static bool IsInIncognitoMode( |
62 | 54 | const FocusHierarchyObserver &focus_hierarchy_observer); |