| OLD | NEW |
| 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, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. | 13 // limitations under the License. |
| 14 | 14 |
| 15 #include "minidump/minidump_location_descriptor_list_writer.h" | 15 #include "minidump/minidump_location_descriptor_list_writer.h" |
| 16 | 16 |
| 17 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "util/file/file_writer.h" | 18 #include "util/file/file_writer.h" |
| 19 #include "util/numeric/safe_assignment.h" | 19 #include "util/numeric/safe_assignment.h" |
| 20 | 20 |
| 21 namespace crashpad { | 21 namespace crashpad { |
| 22 namespace internal { |
| 22 | 23 |
| 23 MinidumpLocationDescriptorListWriter::MinidumpLocationDescriptorListWriter() | 24 MinidumpLocationDescriptorListWriter::MinidumpLocationDescriptorListWriter() |
| 24 : MinidumpWritable(), | 25 : MinidumpWritable(), |
| 25 location_descriptor_list_base_(), | 26 location_descriptor_list_base_(), |
| 26 children_(), | 27 children_(), |
| 27 child_location_descriptors_() { | 28 child_location_descriptors_() { |
| 28 } | 29 } |
| 29 | 30 |
| 30 MinidumpLocationDescriptorListWriter::~MinidumpLocationDescriptorListWriter() { | 31 MinidumpLocationDescriptorListWriter::~MinidumpLocationDescriptorListWriter() { |
| 31 } | 32 } |
| 32 | 33 |
| 33 void MinidumpLocationDescriptorListWriter::AddChild( | 34 void MinidumpLocationDescriptorListWriter::AddChild( |
| 34 scoped_ptr<internal::MinidumpWritable> child) { | 35 scoped_ptr<MinidumpWritable> child) { |
| 35 DCHECK_EQ(state(), kStateMutable); | 36 DCHECK_EQ(state(), kStateMutable); |
| 36 | 37 |
| 37 children_.push_back(child.release()); | 38 children_.push_back(child.release()); |
| 38 } | 39 } |
| 39 | 40 |
| 40 bool MinidumpLocationDescriptorListWriter::Freeze() { | 41 bool MinidumpLocationDescriptorListWriter::Freeze() { |
| 41 DCHECK_EQ(state(), kStateMutable); | 42 DCHECK_EQ(state(), kStateMutable); |
| 42 DCHECK(child_location_descriptors_.empty()); | 43 DCHECK(child_location_descriptors_.empty()); |
| 43 | 44 |
| 44 if (!MinidumpWritable::Freeze()) { | 45 if (!MinidumpWritable::Freeze()) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 60 return true; | 61 return true; |
| 61 } | 62 } |
| 62 | 63 |
| 63 size_t MinidumpLocationDescriptorListWriter::SizeOfObject() { | 64 size_t MinidumpLocationDescriptorListWriter::SizeOfObject() { |
| 64 DCHECK_GE(state(), kStateFrozen); | 65 DCHECK_GE(state(), kStateFrozen); |
| 65 | 66 |
| 66 return sizeof(location_descriptor_list_base_) + | 67 return sizeof(location_descriptor_list_base_) + |
| 67 children_.size() * sizeof(MINIDUMP_LOCATION_DESCRIPTOR); | 68 children_.size() * sizeof(MINIDUMP_LOCATION_DESCRIPTOR); |
| 68 } | 69 } |
| 69 | 70 |
| 70 std::vector<internal::MinidumpWritable*> | 71 std::vector<MinidumpWritable*> |
| 71 MinidumpLocationDescriptorListWriter::Children() { | 72 MinidumpLocationDescriptorListWriter::Children() { |
| 72 DCHECK_GE(state(), kStateFrozen); | 73 DCHECK_GE(state(), kStateFrozen); |
| 73 | 74 |
| 74 std::vector<MinidumpWritable*> children; | 75 std::vector<MinidumpWritable*> children; |
| 75 for (MinidumpWritable* child : children_) { | 76 for (MinidumpWritable* child : children_) { |
| 76 children.push_back(child); | 77 children.push_back(child); |
| 77 } | 78 } |
| 78 | 79 |
| 79 return children; | 80 return children; |
| 80 } | 81 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 92 if (!child_location_descriptors_.empty()) { | 93 if (!child_location_descriptors_.empty()) { |
| 93 iov.iov_base = &child_location_descriptors_[0]; | 94 iov.iov_base = &child_location_descriptors_[0]; |
| 94 iov.iov_len = child_location_descriptors_.size() * | 95 iov.iov_len = child_location_descriptors_.size() * |
| 95 sizeof(MINIDUMP_LOCATION_DESCRIPTOR); | 96 sizeof(MINIDUMP_LOCATION_DESCRIPTOR); |
| 96 iovecs.push_back(iov); | 97 iovecs.push_back(iov); |
| 97 } | 98 } |
| 98 | 99 |
| 99 return file_writer->WriteIoVec(&iovecs); | 100 return file_writer->WriteIoVec(&iovecs); |
| 100 } | 101 } |
| 101 | 102 |
| 103 } // namespace internal |
| 102 } // namespace crashpad | 104 } // namespace crashpad |
| OLD | NEW |