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); |