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

Side by Side Diff: ceee/ie/common/ie_util.cc

Issue 6090006: Regkey functions return error code instead of bool (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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 | Annotate | Revision Log
OLDNEW
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 // Utility functions to interact with IE. 5 // Utility functions to interact with IE.
6 6
7 #include "ceee/ie/common/ie_util.h" 7 #include "ceee/ie/common/ie_util.h"
8 8
9 #include <atlcomcli.h> 9 #include <atlcomcli.h>
10 #include <exdisp.h> // IWebBrowser2 10 #include <exdisp.h> // IWebBrowser2
(...skipping 25 matching lines...) Expand all
36 return enum_punk->QueryInterface(IID_IEnumVARIANT, 36 return enum_punk->QueryInterface(IID_IEnumVARIANT,
37 reinterpret_cast<void**>(enum_windows)); 37 reinterpret_cast<void**>(enum_windows));
38 } 38 }
39 39
40 bool GetIeVersionString(std::wstring* version) { 40 bool GetIeVersionString(std::wstring* version) {
41 DCHECK(version != NULL); 41 DCHECK(version != NULL);
42 if (version == NULL) 42 if (version == NULL)
43 return false; 43 return false;
44 base::win::RegKey key(HKEY_LOCAL_MACHINE, kIeVersionKey, KEY_READ); 44 base::win::RegKey key(HKEY_LOCAL_MACHINE, kIeVersionKey, KEY_READ);
45 DCHECK(key.ValueExists(kIeVersionValue)); 45 DCHECK(key.ValueExists(kIeVersionValue));
46 return key.ReadValue(kIeVersionValue, version); 46 return key.ReadValue(kIeVersionValue, version) == ERROR_SUCCESS;
47 } 47 }
48 48
49 } // namespace 49 } // namespace
50 50
51 namespace ie_util { 51 namespace ie_util {
52 52
53 HRESULT GetWebBrowserForTopLevelIeHwnd( 53 HRESULT GetWebBrowserForTopLevelIeHwnd(
54 HWND window, IWebBrowser2* not_him, IWebBrowser2** browser) { 54 HWND window, IWebBrowser2* not_him, IWebBrowser2** browser) {
55 DCHECK(browser != NULL); 55 DCHECK(browser != NULL);
56 CComPtr<IEnumVARIANT> enum_windows; 56 CComPtr<IEnumVARIANT> enum_windows;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 key_name += L"\\iexplore"; 158 key_name += L"\\iexplore";
159 159
160 base::win::RegKey stats_key(HKEY_CURRENT_USER, key_name.c_str(), KEY_READ); 160 base::win::RegKey stats_key(HKEY_CURRENT_USER, key_name.c_str(), KEY_READ);
161 if (!stats_key.Valid()) { 161 if (!stats_key.Valid()) {
162 LOG(ERROR) << "Missing stats key: " << key_name; 162 LOG(ERROR) << "Missing stats key: " << key_name;
163 return kInvalidTime; 163 return kInvalidTime;
164 } 164 }
165 165
166 DWORD load_time = 0; 166 DWORD load_time = 0;
167 if (GetIeVersion() < IEVERSION_IE9) { 167 if (GetIeVersion() < IEVERSION_IE9) {
168 if (!stats_key.ReadValueDW(time_prefix.c_str(), &load_time)) { 168 LONG result = stats_key.ReadValueDW(time_prefix.c_str(), &load_time);
Sigurður Ásgeirsson 2011/01/10 21:02:43 ugh, I guess we rely on this everywhere. Can I sti
169 if (result != ERROR_SUCCESS) {
169 VLOG(1) << "Can't read time: " << time_prefix; 170 VLOG(1) << "Can't read time: " << time_prefix;
170 return kInvalidTime; 171 return kInvalidTime;
171 } 172 }
172 } else { 173 } else {
173 std::wstring value_name(time_prefix); 174 std::wstring value_name(time_prefix);
174 value_name += L"Array"; 175 value_name += L"Array";
175 DWORD count = 0; 176 DWORD count = 0;
176 int32 values[100]; 177 int32 values[100];
177 DWORD data_size = sizeof(values); 178 DWORD data_size = sizeof(values);
178 DWORD data_type = REG_NONE; 179 DWORD data_type = REG_NONE;
179 180
180 if (!stats_key.ReadValue(value_name.c_str(), &values, &data_size, 181 LONG result = stats_key.ReadValue(value_name.c_str(), &values, &data_size,
181 &data_type)) { 182 &data_type);
183 if (result != ERROR_SUCCESS) {
182 VLOG(1) << "Can't read time: " << value_name; 184 VLOG(1) << "Can't read time: " << value_name;
Sigurður Ásgeirsson 2011/01/10 21:02:43 com::LogWe(result) now that we have the error in q
amit 2011/01/12 04:11:23 Done.
183 return kInvalidTime; 185 return kInvalidTime;
184 } 186 }
185 187
186 if (data_type != REG_BINARY) { 188 if (data_type != REG_BINARY) {
187 LOG(ERROR) << "Unexpected data type:" << data_type; 189 LOG(ERROR) << "Unexpected data type:" << data_type;
188 return kInvalidTime; 190 return kInvalidTime;
189 } 191 }
190 192
191 if (data_size % sizeof(values[0]) != 0) { 193 if (data_size % sizeof(values[0]) != 0) {
192 LOG(ERROR) << "Unexpected data length:" << data_size; 194 LOG(ERROR) << "Unexpected data length:" << data_size;
(...skipping 22 matching lines...) Expand all
215 217
216 if (load_time < 0) { 218 if (load_time < 0) {
217 LOG(ERROR) << "Invalid time:" << load_time; 219 LOG(ERROR) << "Invalid time:" << load_time;
218 return kInvalidTime; 220 return kInvalidTime;
219 } 221 }
220 222
221 return load_time; 223 return load_time;
222 } 224 }
223 225
224 } // namespace ie_util 226 } // namespace ie_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698