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

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

Issue 2816513002: Revert of Change base::Value::ListStorage to std::vector<base::Value> (Closed)
Patch Set: Created 3 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 "chromecast/crash/linux/crash_testing_utils.h" 5 #include "chromecast/crash/linux/crash_testing_utils.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 std::unique_ptr<base::Value> ParseMetadataFile(const std::string& path) { 57 std::unique_ptr<base::Value> ParseMetadataFile(const std::string& path) {
58 return DeserializeJsonFromFile(base::FilePath(path)); 58 return DeserializeJsonFromFile(base::FilePath(path));
59 } 59 }
60 60
61 int WriteLockFile(const std::string& path, base::ListValue* contents) { 61 int WriteLockFile(const std::string& path, base::ListValue* contents) {
62 DCHECK(contents); 62 DCHECK(contents);
63 std::string lockfile; 63 std::string lockfile;
64 64
65 for (const auto& elem : *contents) { 65 for (const auto& elem : *contents) {
66 std::unique_ptr<std::string> dump_info = SerializeToJson(elem); 66 std::unique_ptr<std::string> dump_info = SerializeToJson(*elem);
67 RCHECK(dump_info, -1, "Failed to serialize DumpInfo"); 67 RCHECK(dump_info, -1, "Failed to serialize DumpInfo");
68 lockfile += *dump_info; 68 lockfile += *dump_info;
69 lockfile += "\n"; // Add line seperatators 69 lockfile += "\n"; // Add line seperatators
70 } 70 }
71 71
72 return WriteFile(base::FilePath(path), lockfile.c_str(), lockfile.size()) >= 0 72 return WriteFile(base::FilePath(path), lockfile.c_str(), lockfile.size()) >= 0
73 ? 0 73 ? 0
74 : -1; 74 : -1;
75 } 75 }
76 76
(...skipping 11 matching lines...) Expand all
88 88
89 bool FetchDumps(const std::string& lockfile_path, 89 bool FetchDumps(const std::string& lockfile_path,
90 std::vector<std::unique_ptr<DumpInfo>>* dumps) { 90 std::vector<std::unique_ptr<DumpInfo>>* dumps) {
91 DCHECK(dumps); 91 DCHECK(dumps);
92 std::unique_ptr<base::ListValue> dump_list = ParseLockFile(lockfile_path); 92 std::unique_ptr<base::ListValue> dump_list = ParseLockFile(lockfile_path);
93 RCHECK(dump_list, false, "Failed to parse lockfile"); 93 RCHECK(dump_list, false, "Failed to parse lockfile");
94 94
95 dumps->clear(); 95 dumps->clear();
96 96
97 for (const auto& elem : *dump_list) { 97 for (const auto& elem : *dump_list) {
98 std::unique_ptr<DumpInfo> dump(new DumpInfo(&elem)); 98 std::unique_ptr<DumpInfo> dump(new DumpInfo(elem.get()));
99 RCHECK(dump->valid(), false, "Invalid DumpInfo"); 99 RCHECK(dump->valid(), false, "Invalid DumpInfo");
100 dumps->push_back(std::move(dump)); 100 dumps->push_back(std::move(dump));
101 } 101 }
102 102
103 return true; 103 return true;
104 } 104 }
105 105
106 bool ClearDumps(const std::string& lockfile_path) { 106 bool ClearDumps(const std::string& lockfile_path) {
107 std::unique_ptr<base::ListValue> dump_list = 107 std::unique_ptr<base::ListValue> dump_list =
108 base::MakeUnique<base::ListValue>(); 108 base::MakeUnique<base::ListValue>();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 if (!contents || !contents->GetAsDictionary(&dict) || 150 if (!contents || !contents->GetAsDictionary(&dict) ||
151 !dict->GetDictionary(kRatelimitKey, &ratelimit_params)) { 151 !dict->GetDictionary(kRatelimitKey, &ratelimit_params)) {
152 return false; 152 return false;
153 } 153 }
154 154
155 ratelimit_params->SetDouble(kRatelimitPeriodStartKey, start.ToDoubleT()); 155 ratelimit_params->SetDouble(kRatelimitPeriodStartKey, start.ToDoubleT());
156 return WriteMetadataFile(metadata_path, contents.get()) == 0; 156 return WriteMetadataFile(metadata_path, contents.get()) == 0;
157 } 157 }
158 158
159 } // namespace chromecast 159 } // namespace chromecast
OLDNEW
« no previous file with comments | « chrome/utility/importer/nss_decryptor.cc ('k') | chromecast/crash/linux/synchronized_minidump_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698