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

Side by Side Diff: chrome/installer/test/resource_loader.cc

Issue 1548153002: Switch to standard integer types in chrome/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
« no previous file with comments | « chrome/installer/test/resource_loader.h ('k') | chrome/installer/test/resource_updater.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/installer/test/resource_loader.h" 5 #include "chrome/installer/test/resource_loader.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 11
12 namespace { 12 namespace {
13 13
14 // Populates |resource_data| with the address and size of the resource in 14 // Populates |resource_data| with the address and size of the resource in
15 // |module| identified by |name_or_id| of type |type_name_or_id|, returning 15 // |module| identified by |name_or_id| of type |type_name_or_id|, returning
16 // true on success. 16 // true on success.
17 bool DoLoad(HMODULE module, const wchar_t* name_or_id, 17 bool DoLoad(HMODULE module,
18 const wchar_t* name_or_id,
18 const wchar_t* type_name_or_id, 19 const wchar_t* type_name_or_id,
19 std::pair<const uint8*, DWORD>* resource_data) { 20 std::pair<const uint8_t*, DWORD>* resource_data) {
20 bool loaded = false; 21 bool loaded = false;
21 HRSRC resource_info; 22 HRSRC resource_info;
22 23
23 resource_info = FindResource(module, name_or_id, type_name_or_id); 24 resource_info = FindResource(module, name_or_id, type_name_or_id);
24 if (resource_info != NULL) { 25 if (resource_info != NULL) {
25 HGLOBAL loaded_resource; 26 HGLOBAL loaded_resource;
26 27
27 loaded_resource = LoadResource(module, resource_info); 28 loaded_resource = LoadResource(module, resource_info);
28 if (loaded_resource != NULL) { 29 if (loaded_resource != NULL) {
29 resource_data->first = 30 resource_data->first =
30 static_cast<const uint8*>(LockResource(loaded_resource)); 31 static_cast<const uint8_t*>(LockResource(loaded_resource));
31 if (resource_data->first != NULL) { 32 if (resource_data->first != NULL) {
32 resource_data->second = SizeofResource(module, resource_info); 33 resource_data->second = SizeofResource(module, resource_info);
33 DPCHECK(resource_data->second != 0); 34 DPCHECK(resource_data->second != 0);
34 loaded = true; 35 loaded = true;
35 } else { 36 } else {
36 DPCHECK(false) << "LockResource failed"; 37 DPCHECK(false) << "LockResource failed";
37 } 38 }
38 } else { 39 } else {
39 DPCHECK(false) << "LoadResource failed"; 40 DPCHECK(false) << "LoadResource failed";
40 } 41 }
(...skipping 23 matching lines...) Expand all
64 module_ = LoadLibraryEx(pe_image_path.value().c_str(), NULL, 65 module_ = LoadLibraryEx(pe_image_path.value().c_str(), NULL,
65 (LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE | 66 (LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE |
66 LOAD_LIBRARY_AS_IMAGE_RESOURCE)); 67 LOAD_LIBRARY_AS_IMAGE_RESOURCE));
67 DPLOG_IF(INFO, module_ == NULL) 68 DPLOG_IF(INFO, module_ == NULL)
68 << "Failed loading \"" << pe_image_path.value() << "\""; 69 << "Failed loading \"" << pe_image_path.value() << "\"";
69 return module_ != NULL; 70 return module_ != NULL;
70 } 71 }
71 72
72 bool ResourceLoader::Load(const std::wstring& name, 73 bool ResourceLoader::Load(const std::wstring& name,
73 const std::wstring& type, 74 const std::wstring& type,
74 std::pair<const uint8*, DWORD>* resource_data) { 75 std::pair<const uint8_t*, DWORD>* resource_data) {
75 DCHECK(resource_data != NULL); 76 DCHECK(resource_data != NULL);
76 DCHECK(module_ != NULL); 77 DCHECK(module_ != NULL);
77 78
78 return DoLoad(module_, name.c_str(), type.c_str(), resource_data); 79 return DoLoad(module_, name.c_str(), type.c_str(), resource_data);
79 } 80 }
80 81
81 bool ResourceLoader::Load(WORD id, 82 bool ResourceLoader::Load(WORD id,
82 WORD type, 83 WORD type,
83 std::pair<const uint8*, DWORD>* resource_data) { 84 std::pair<const uint8_t*, DWORD>* resource_data) {
84 DCHECK(resource_data != NULL); 85 DCHECK(resource_data != NULL);
85 DCHECK(module_ != NULL); 86 DCHECK(module_ != NULL);
86 87
87 return DoLoad(module_, MAKEINTRESOURCE(id), MAKEINTRESOURCE(type), 88 return DoLoad(module_, MAKEINTRESOURCE(id), MAKEINTRESOURCE(type),
88 resource_data); 89 resource_data);
89 } 90 }
90 91
91 } // namespace upgrade_test 92 } // namespace upgrade_test
OLDNEW
« no previous file with comments | « chrome/installer/test/resource_loader.h ('k') | chrome/installer/test/resource_updater.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698