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

Side by Side Diff: chromecast/crash/linux/synchronized_minidump_manager.cc

Issue 2000803003: Use std::unique_ptr for base::DictionaryValue and base::ListValue's internal store. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More fixes Created 4 years, 6 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 | « chromecast/crash/linux/crash_testing_utils.cc ('k') | chromeos/network/network_util.cc » ('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 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 "chromecast/crash/linux/synchronized_minidump_manager.h" 5 #include "chromecast/crash/linux/synchronized_minidump_manager.h"
6 6
7 #include <dirent.h> 7 #include <dirent.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <stddef.h> 10 #include <stddef.h>
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 metadata_ = std::move(metadata); 285 metadata_ = std::move(metadata);
286 return 0; 286 return 0;
287 } 287 }
288 288
289 int SynchronizedMinidumpManager::WriteFiles(const base::ListValue* dumps, 289 int SynchronizedMinidumpManager::WriteFiles(const base::ListValue* dumps,
290 const base::Value* metadata) { 290 const base::Value* metadata) {
291 DCHECK(dumps); 291 DCHECK(dumps);
292 DCHECK(metadata); 292 DCHECK(metadata);
293 std::string lockfile; 293 std::string lockfile;
294 294
295 for (const base::Value* elem : *dumps) { 295 for (const auto& elem : *dumps) {
296 std::unique_ptr<std::string> dump_info = SerializeToJson(*elem); 296 std::unique_ptr<std::string> dump_info = SerializeToJson(*elem);
297 RCHECK(dump_info, -1); 297 RCHECK(dump_info, -1);
298 lockfile += *dump_info; 298 lockfile += *dump_info;
299 lockfile += "\n"; // Add line seperatators 299 lockfile += "\n"; // Add line seperatators
300 } 300 }
301 301
302 if (WriteFile(base::FilePath(lockfile_path_), 302 if (WriteFile(base::FilePath(lockfile_path_),
303 lockfile.c_str(), 303 lockfile.c_str(),
304 lockfile.size()) < 0) { 304 lockfile.size()) < 0) {
305 return -1; 305 return -1;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 lockfile_fd_ = -1; 357 lockfile_fd_ = -1;
358 } 358 }
359 359
360 dumps_.reset(); 360 dumps_.reset();
361 metadata_.reset(); 361 metadata_.reset();
362 } 362 }
363 363
364 ScopedVector<DumpInfo> SynchronizedMinidumpManager::GetDumps() { 364 ScopedVector<DumpInfo> SynchronizedMinidumpManager::GetDumps() {
365 ScopedVector<DumpInfo> dumps; 365 ScopedVector<DumpInfo> dumps;
366 366
367 for (const base::Value* elem : *dumps_) { 367 for (const auto& elem : *dumps_) {
368 dumps.push_back(new DumpInfo(elem)); 368 dumps.push_back(new DumpInfo(elem.get()));
369 } 369 }
370 370
371 return dumps; 371 return dumps;
372 } 372 }
373 373
374 int SynchronizedMinidumpManager::SetCurrentDumps( 374 int SynchronizedMinidumpManager::SetCurrentDumps(
375 const ScopedVector<DumpInfo>& dumps) { 375 const ScopedVector<DumpInfo>& dumps) {
376 dumps_->Clear(); 376 dumps_->Clear();
377 377
378 for (DumpInfo* dump : dumps) 378 for (DumpInfo* dump : dumps)
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 430
431 const std::string file_path = dump_path_.Append(reader.name()).value(); 431 const std::string file_path = dump_path_.Append(reader.name()).value();
432 if (file_path != lockfile_path_ && file_path != metadata_path_) 432 if (file_path != lockfile_path_ && file_path != metadata_path_)
433 return true; 433 return true;
434 } 434 }
435 435
436 return false; 436 return false;
437 } 437 }
438 438
439 } // namespace chromecast 439 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/crash/linux/crash_testing_utils.cc ('k') | chromeos/network/network_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698