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

Side by Side Diff: minidump/minidump_module_writer.cc

Issue 674153002: minidump: Change the ownership model (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Address review feedback Created 6 years, 1 month 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_module_writer.h ('k') | minidump/minidump_module_writer_test.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 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 ~MinidumpModuleCodeViewRecordPDB70Writer() { 96 ~MinidumpModuleCodeViewRecordPDB70Writer() {
97 } 97 }
98 98
99 MinidumpModuleMiscDebugRecordWriter::MinidumpModuleMiscDebugRecordWriter() 99 MinidumpModuleMiscDebugRecordWriter::MinidumpModuleMiscDebugRecordWriter()
100 : internal::MinidumpWritable(), 100 : internal::MinidumpWritable(),
101 image_debug_misc_(), 101 image_debug_misc_(),
102 data_(), 102 data_(),
103 data_utf16_() { 103 data_utf16_() {
104 } 104 }
105 105
106 MinidumpModuleMiscDebugRecordWriter::~MinidumpModuleMiscDebugRecordWriter() {
107 }
108
106 void MinidumpModuleMiscDebugRecordWriter::SetData(const std::string& data, 109 void MinidumpModuleMiscDebugRecordWriter::SetData(const std::string& data,
107 bool utf16) { 110 bool utf16) {
108 DCHECK_EQ(state(), kStateMutable); 111 DCHECK_EQ(state(), kStateMutable);
109 112
110 if (!utf16) { 113 if (!utf16) {
111 data_utf16_.clear(); 114 data_utf16_.clear();
112 image_debug_misc_.Unicode = 0; 115 image_debug_misc_.Unicode = 0;
113 data_ = data; 116 data_ = data;
114 } else { 117 } else {
115 data_.clear(); 118 data_.clear();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 void MinidumpModuleWriter::SetName(const std::string& name) { 195 void MinidumpModuleWriter::SetName(const std::string& name) {
193 DCHECK_EQ(state(), kStateMutable); 196 DCHECK_EQ(state(), kStateMutable);
194 197
195 if (!name_) { 198 if (!name_) {
196 name_.reset(new internal::MinidumpUTF16StringWriter()); 199 name_.reset(new internal::MinidumpUTF16StringWriter());
197 } 200 }
198 name_->SetUTF8(name); 201 name_->SetUTF8(name);
199 } 202 }
200 203
201 void MinidumpModuleWriter::SetCodeViewRecord( 204 void MinidumpModuleWriter::SetCodeViewRecord(
202 MinidumpModuleCodeViewRecordWriter* codeview_record) { 205 scoped_ptr<MinidumpModuleCodeViewRecordWriter> codeview_record) {
203 DCHECK_EQ(state(), kStateMutable); 206 DCHECK_EQ(state(), kStateMutable);
204 207
205 codeview_record_ = codeview_record; 208 codeview_record_ = codeview_record.Pass();
206 } 209 }
207 210
208 void MinidumpModuleWriter::SetMiscDebugRecord( 211 void MinidumpModuleWriter::SetMiscDebugRecord(
209 MinidumpModuleMiscDebugRecordWriter* misc_debug_record) { 212 scoped_ptr<MinidumpModuleMiscDebugRecordWriter> misc_debug_record) {
210 DCHECK_EQ(state(), kStateMutable); 213 DCHECK_EQ(state(), kStateMutable);
211 214
212 misc_debug_record_ = misc_debug_record; 215 misc_debug_record_ = misc_debug_record.Pass();
213 } 216 }
214 217
215 void MinidumpModuleWriter::SetTimestamp(time_t timestamp) { 218 void MinidumpModuleWriter::SetTimestamp(time_t timestamp) {
216 DCHECK_EQ(state(), kStateMutable); 219 DCHECK_EQ(state(), kStateMutable);
217 220
218 internal::MinidumpWriterUtil::AssignTimeT(&module_.TimeDateStamp, timestamp); 221 internal::MinidumpWriterUtil::AssignTimeT(&module_.TimeDateStamp, timestamp);
219 } 222 }
220 223
221 void MinidumpModuleWriter::SetFileVersion(uint16_t version_0, 224 void MinidumpModuleWriter::SetFileVersion(uint16_t version_0,
222 uint16_t version_1, 225 uint16_t version_1,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 return 0; 284 return 0;
282 } 285 }
283 286
284 std::vector<internal::MinidumpWritable*> MinidumpModuleWriter::Children() { 287 std::vector<internal::MinidumpWritable*> MinidumpModuleWriter::Children() {
285 DCHECK_GE(state(), kStateFrozen); 288 DCHECK_GE(state(), kStateFrozen);
286 DCHECK(name_); 289 DCHECK(name_);
287 290
288 std::vector<MinidumpWritable*> children; 291 std::vector<MinidumpWritable*> children;
289 children.push_back(name_.get()); 292 children.push_back(name_.get());
290 if (codeview_record_) { 293 if (codeview_record_) {
291 children.push_back(codeview_record_); 294 children.push_back(codeview_record_.get());
292 } 295 }
293 if (misc_debug_record_) { 296 if (misc_debug_record_) {
294 children.push_back(misc_debug_record_); 297 children.push_back(misc_debug_record_.get());
295 } 298 }
296 299
297 return children; 300 return children;
298 } 301 }
299 302
300 bool MinidumpModuleWriter::WriteObject(FileWriterInterface* file_writer) { 303 bool MinidumpModuleWriter::WriteObject(FileWriterInterface* file_writer) {
301 DCHECK_EQ(state(), kStateWritable); 304 DCHECK_EQ(state(), kStateWritable);
302 305
303 // This object doesn’t directly write anything itself. Its MINIDUMP_MODULE is 306 // This object doesn’t directly write anything itself. Its MINIDUMP_MODULE is
304 // written by its parent as part of a MINIDUMP_MODULE_LIST, and its children 307 // written by its parent as part of a MINIDUMP_MODULE_LIST, and its children
305 // are responsible for writing themselves. 308 // are responsible for writing themselves.
306 return true; 309 return true;
307 } 310 }
308 311
309 MinidumpModuleListWriter::MinidumpModuleListWriter() 312 MinidumpModuleListWriter::MinidumpModuleListWriter()
310 : MinidumpStreamWriter(), module_list_base_(), modules_() { 313 : MinidumpStreamWriter(), module_list_base_(), modules_() {
311 } 314 }
312 315
313 MinidumpModuleListWriter::~MinidumpModuleListWriter() { 316 MinidumpModuleListWriter::~MinidumpModuleListWriter() {
314 } 317 }
315 318
316 void MinidumpModuleListWriter::AddModule(MinidumpModuleWriter* module) { 319 void MinidumpModuleListWriter::AddModule(
320 scoped_ptr<MinidumpModuleWriter> module) {
317 DCHECK_EQ(state(), kStateMutable); 321 DCHECK_EQ(state(), kStateMutable);
318 322
319 modules_.push_back(module); 323 modules_.push_back(module.release());
320 } 324 }
321 325
322 bool MinidumpModuleListWriter::Freeze() { 326 bool MinidumpModuleListWriter::Freeze() {
323 DCHECK_EQ(state(), kStateMutable); 327 DCHECK_EQ(state(), kStateMutable);
324 328
325 if (!MinidumpStreamWriter::Freeze()) { 329 if (!MinidumpStreamWriter::Freeze()) {
326 return false; 330 return false;
327 } 331 }
328 332
329 size_t module_count = modules_.size(); 333 size_t module_count = modules_.size();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 } 371 }
368 372
369 return file_writer->WriteIoVec(&iovecs); 373 return file_writer->WriteIoVec(&iovecs);
370 } 374 }
371 375
372 MinidumpStreamType MinidumpModuleListWriter::StreamType() const { 376 MinidumpStreamType MinidumpModuleListWriter::StreamType() const {
373 return kMinidumpStreamTypeModuleList; 377 return kMinidumpStreamTypeModuleList;
374 } 378 }
375 379
376 } // namespace crashpad 380 } // namespace crashpad
OLDNEW
« no previous file with comments | « minidump/minidump_module_writer.h ('k') | minidump/minidump_module_writer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698