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

Side by Side Diff: chrome/utility/safe_browsing/mac/crdmg.cc

Issue 1899083002: Convert //chrome from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <errno.h> 5 #include <errno.h>
6 #include <fcntl.h> 6 #include <fcntl.h>
7 #include <limits.h> 7 #include <limits.h>
8 #include <sandbox.h> 8 #include <sandbox.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <stdint.h> 10 #include <stdint.h>
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 return false; 170 return false;
171 171
172 for (size_t i = 0; i < udif_parser.GetNumberOfPartitions(); ++i) { 172 for (size_t i = 0; i < udif_parser.GetNumberOfPartitions(); ++i) {
173 printf("=== Partition #%zu: %s ===\n", i, 173 printf("=== Partition #%zu: %s ===\n", i,
174 udif_parser.GetPartitionName(i).c_str()); 174 udif_parser.GetPartitionName(i).c_str());
175 175
176 std::string partition_type = udif_parser.GetPartitionType(i); 176 std::string partition_type = udif_parser.GetPartitionType(i);
177 if (partition_type != "Apple_HFS" && partition_type != "Apple_HFSX") 177 if (partition_type != "Apple_HFS" && partition_type != "Apple_HFSX")
178 continue; 178 continue;
179 179
180 scoped_ptr<safe_browsing::dmg::ReadStream> partition_stream( 180 std::unique_ptr<safe_browsing::dmg::ReadStream> partition_stream(
181 udif_parser.GetPartitionReadStream(i)); 181 udif_parser.GetPartitionReadStream(i));
182 safe_browsing::dmg::HFSIterator iterator(partition_stream.get()); 182 safe_browsing::dmg::HFSIterator iterator(partition_stream.get());
183 if (!iterator.Open()) { 183 if (!iterator.Open()) {
184 LOG(ERROR) << "Failed to open HFS partition"; 184 LOG(ERROR) << "Failed to open HFS partition";
185 continue; 185 continue;
186 } 186 }
187 187
188 while (iterator.Next()) { 188 while (iterator.Next()) {
189 std::string path = base::UTF16ToUTF8(iterator.GetPath()); 189 std::string path = base::UTF16ToUTF8(iterator.GetPath());
190 printf("%s\n", path.c_str()); 190 printf("%s\n", path.c_str());
(...skipping 23 matching lines...) Expand all
214 } 214 }
215 } else { 215 } else {
216 base::ScopedFD unpacked( 216 base::ScopedFD unpacked(
217 HANDLE_EINTR(openat(unpack_dir_.get(), path.c_str(), 217 HANDLE_EINTR(openat(unpack_dir_.get(), path.c_str(),
218 O_WRONLY | O_CREAT | O_TRUNC, 0644))); 218 O_WRONLY | O_CREAT | O_TRUNC, 0644)));
219 if (!unpacked.is_valid()) { 219 if (!unpacked.is_valid()) {
220 PLOG(ERROR) << "openat " << path; 220 PLOG(ERROR) << "openat " << path;
221 continue; 221 continue;
222 } 222 }
223 223
224 scoped_ptr<safe_browsing::dmg::ReadStream> stream( 224 std::unique_ptr<safe_browsing::dmg::ReadStream> stream(
225 iterator.GetReadStream()); 225 iterator.GetReadStream());
226 size_t read_this_pass = 0; 226 size_t read_this_pass = 0;
227 do { 227 do {
228 uint8_t buf[4096]; 228 uint8_t buf[4096];
229 if (!stream->Read(buf, sizeof(buf), &read_this_pass)) { 229 if (!stream->Read(buf, sizeof(buf), &read_this_pass)) {
230 LOG(ERROR) << "Failed to read stream: " << path; 230 LOG(ERROR) << "Failed to read stream: " << path;
231 unlinkat(unpack_dir_.get(), path.c_str(), 0); 231 unlinkat(unpack_dir_.get(), path.c_str(), 0);
232 break; 232 break;
233 } 233 }
234 234
(...skipping 13 matching lines...) Expand all
248 248
249 return true; 249 return true;
250 } 250 }
251 251
252 } // namespace 252 } // namespace
253 253
254 int main(int argc, const char* argv[]) { 254 int main(int argc, const char* argv[]) {
255 SafeDMG safe_dmg; 255 SafeDMG safe_dmg;
256 return safe_dmg.Main(argc, argv); 256 return safe_dmg.Main(argc, argv);
257 } 257 }
OLDNEW
« no previous file with comments | « chrome/utility/profile_import_handler.h ('k') | chrome/utility/safe_browsing/mac/dmg_analyzer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698