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

Unified Diff: minidump/minidump_simple_string_dictionary_writer.cc

Issue 683143003: minidump: Add InitializeFromSnapshot() for MinidumpModuleCrashpadInfoListWriter and downstream (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Address review feedback Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: minidump/minidump_simple_string_dictionary_writer.cc
diff --git a/minidump/minidump_simple_string_dictionary_writer.cc b/minidump/minidump_simple_string_dictionary_writer.cc
index 9218bd9786597a7c08e3cc484194d217e33a1eae..63352e665f18c3fbcb7507a7fa794b1d8ec8778c 100644
--- a/minidump/minidump_simple_string_dictionary_writer.cc
+++ b/minidump/minidump_simple_string_dictionary_writer.cc
@@ -41,6 +41,8 @@ MinidumpSimpleStringDictionaryEntryWriter::MinidumpSimpleStringDictionaryEntry()
void MinidumpSimpleStringDictionaryEntryWriter::SetKeyValue(
const std::string& key,
const std::string& value) {
+ DCHECK_EQ(state(), kStateMutable);
+
key_.SetUTF8(key);
value_.SetUTF8(value);
}
@@ -96,9 +98,22 @@ MinidumpSimpleStringDictionaryWriter::~MinidumpSimpleStringDictionaryWriter() {
STLDeleteContainerPairSecondPointers(entries_.begin(), entries_.end());
}
+void MinidumpSimpleStringDictionaryWriter::InitializeFromMap(
+ const std::map<std::string, std::string>& map) {
+ DCHECK_EQ(state(), kStateMutable);
+ DCHECK(entries_.empty());
+
+ for (const auto& iterator : map) {
+ auto entry =
+ make_scoped_ptr(new MinidumpSimpleStringDictionaryEntryWriter());
+ entry->SetKeyValue(iterator.first, iterator.second);
+ AddEntry(entry.Pass());
+ }
+}
+
void MinidumpSimpleStringDictionaryWriter::AddEntry(
scoped_ptr<MinidumpSimpleStringDictionaryEntryWriter> entry) {
- DCHECK_GE(state(), kStateMutable);
+ DCHECK_EQ(state(), kStateMutable);
const std::string& key = entry->Key();
auto iterator = entries_.find(key);
@@ -110,6 +125,10 @@ void MinidumpSimpleStringDictionaryWriter::AddEntry(
}
}
+bool MinidumpSimpleStringDictionaryWriter::IsUseful() const {
+ return !entries_.empty();
+}
+
bool MinidumpSimpleStringDictionaryWriter::Freeze() {
DCHECK_EQ(state(), kStateMutable);
« no previous file with comments | « minidump/minidump_simple_string_dictionary_writer.h ('k') | minidump/minidump_simple_string_dictionary_writer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698