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

Side by Side Diff: minidump/minidump_simple_string_dictionary_writer.cc

Issue 895313004: win: convert MinidumpSimpleStringDictionaryWriter to scoped_ptr (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: remove mistaken addition Created 5 years, 10 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 | « minidump/minidump_simple_string_dictionary_writer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 DCHECK_EQ(state(), kStateWritable); 84 DCHECK_EQ(state(), kStateWritable);
85 85
86 // This object doesn’t directly write anything itself. Its 86 // This object doesn’t directly write anything itself. Its
87 // MinidumpSimpleStringDictionaryEntry is written by its parent as part of a 87 // MinidumpSimpleStringDictionaryEntry is written by its parent as part of a
88 // MinidumpSimpleStringDictionary, and its children are responsible for 88 // MinidumpSimpleStringDictionary, and its children are responsible for
89 // writing themselves. 89 // writing themselves.
90 return true; 90 return true;
91 } 91 }
92 92
93 MinidumpSimpleStringDictionaryWriter::MinidumpSimpleStringDictionaryWriter() 93 MinidumpSimpleStringDictionaryWriter::MinidumpSimpleStringDictionaryWriter()
94 : MinidumpWritable(), entries_(), simple_string_dictionary_base_() { 94 : MinidumpWritable(),
95 entries_(),
96 simple_string_dictionary_base_(new MinidumpSimpleStringDictionary()) {
95 } 97 }
96 98
97 MinidumpSimpleStringDictionaryWriter::~MinidumpSimpleStringDictionaryWriter() { 99 MinidumpSimpleStringDictionaryWriter::~MinidumpSimpleStringDictionaryWriter() {
98 STLDeleteContainerPairSecondPointers(entries_.begin(), entries_.end()); 100 STLDeleteContainerPairSecondPointers(entries_.begin(), entries_.end());
99 } 101 }
100 102
101 void MinidumpSimpleStringDictionaryWriter::InitializeFromMap( 103 void MinidumpSimpleStringDictionaryWriter::InitializeFromMap(
102 const std::map<std::string, std::string>& map) { 104 const std::map<std::string, std::string>& map) {
103 DCHECK_EQ(state(), kStateMutable); 105 DCHECK_EQ(state(), kStateMutable);
104 DCHECK(entries_.empty()); 106 DCHECK(entries_.empty());
(...skipping 25 matching lines...) Expand all
130 } 132 }
131 133
132 bool MinidumpSimpleStringDictionaryWriter::Freeze() { 134 bool MinidumpSimpleStringDictionaryWriter::Freeze() {
133 DCHECK_EQ(state(), kStateMutable); 135 DCHECK_EQ(state(), kStateMutable);
134 136
135 if (!MinidumpWritable::Freeze()) { 137 if (!MinidumpWritable::Freeze()) {
136 return false; 138 return false;
137 } 139 }
138 140
139 size_t entry_count = entries_.size(); 141 size_t entry_count = entries_.size();
140 if (!AssignIfInRange(&simple_string_dictionary_base_.count, entry_count)) { 142 if (!AssignIfInRange(&simple_string_dictionary_base_->count, entry_count)) {
141 LOG(ERROR) << "entry_count " << entry_count << " out of range"; 143 LOG(ERROR) << "entry_count " << entry_count << " out of range";
142 return false; 144 return false;
143 } 145 }
144 146
145 return true; 147 return true;
146 } 148 }
147 149
148 size_t MinidumpSimpleStringDictionaryWriter::SizeOfObject() { 150 size_t MinidumpSimpleStringDictionaryWriter::SizeOfObject() {
149 DCHECK_GE(state(), kStateFrozen); 151 DCHECK_GE(state(), kStateFrozen);
150 152
151 return sizeof(simple_string_dictionary_base_) + 153 return sizeof(*simple_string_dictionary_base_) +
152 entries_.size() * sizeof(MinidumpSimpleStringDictionaryEntry); 154 entries_.size() * sizeof(MinidumpSimpleStringDictionaryEntry);
153 } 155 }
154 156
155 std::vector<internal::MinidumpWritable*> 157 std::vector<internal::MinidumpWritable*>
156 MinidumpSimpleStringDictionaryWriter::Children() { 158 MinidumpSimpleStringDictionaryWriter::Children() {
157 DCHECK_GE(state(), kStateMutable); 159 DCHECK_GE(state(), kStateMutable);
158 160
159 std::vector<MinidumpWritable*> children; 161 std::vector<MinidumpWritable*> children;
160 for (const auto& key_entry : entries_) { 162 for (const auto& key_entry : entries_) {
161 children.push_back(key_entry.second); 163 children.push_back(key_entry.second);
162 } 164 }
163 165
164 return children; 166 return children;
165 } 167 }
166 168
167 bool MinidumpSimpleStringDictionaryWriter::WriteObject( 169 bool MinidumpSimpleStringDictionaryWriter::WriteObject(
168 FileWriterInterface* file_writer) { 170 FileWriterInterface* file_writer) {
169 DCHECK_GE(state(), kStateWritable); 171 DCHECK_GE(state(), kStateWritable);
170 172
171 WritableIoVec iov; 173 WritableIoVec iov;
172 iov.iov_base = &simple_string_dictionary_base_; 174 iov.iov_base = simple_string_dictionary_base_.get();
173 iov.iov_len = sizeof(simple_string_dictionary_base_); 175 iov.iov_len = sizeof(*simple_string_dictionary_base_);
174 std::vector<WritableIoVec> iovecs(1, iov); 176 std::vector<WritableIoVec> iovecs(1, iov);
175 177
176 for (const auto& key_entry : entries_) { 178 for (const auto& key_entry : entries_) {
177 iov.iov_base = key_entry.second->MinidumpSimpleStringDictionaryEntry(); 179 iov.iov_base = key_entry.second->MinidumpSimpleStringDictionaryEntry();
178 iov.iov_len = sizeof(MinidumpSimpleStringDictionaryEntry); 180 iov.iov_len = sizeof(MinidumpSimpleStringDictionaryEntry);
179 iovecs.push_back(iov); 181 iovecs.push_back(iov);
180 } 182 }
181 183
182 return file_writer->WriteIoVec(&iovecs); 184 return file_writer->WriteIoVec(&iovecs);
183 } 185 }
184 186
185 } // namespace crashpad 187 } // namespace crashpad
OLDNEW
« no previous file with comments | « minidump/minidump_simple_string_dictionary_writer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698