OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
| 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (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 |
| 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. |
| 14 |
| 15 #ifndef CRASHPAD_MINIDUMP_RVA_LIST_WRITER_H_ |
| 16 #define CRASHPAD_MINIDUMP_RVA_LIST_WRITER_H_ |
| 17 |
| 18 #include <stdint.h> |
| 19 #include <sys/types.h> |
| 20 |
| 21 #include <vector> |
| 22 |
| 23 #include "base/basictypes.h" |
| 24 #include "base/memory/scoped_ptr.h" |
| 25 #include "minidump/minidump_extensions.h" |
| 26 #include "minidump/minidump_writable.h" |
| 27 #include "util/stdlib/pointer_container.h" |
| 28 |
| 29 namespace crashpad { |
| 30 |
| 31 //! \brief The writer for a MinidumpRVAList object in a minidump file, |
| 32 //! containing a list of ::RVA pointers. |
| 33 class MinidumpRVAListWriter : public internal::MinidumpWritable { |
| 34 protected: |
| 35 MinidumpRVAListWriter(); |
| 36 ~MinidumpRVAListWriter() override; |
| 37 |
| 38 //! \brief Adds an ::RVA referencing an internal::MinidumpWritable to the |
| 39 //! MinidumpRVAList. |
| 40 //! |
| 41 //! This object takes ownership of \a child and becomes its parent in the |
| 42 //! overall tree of internal::MinidumpWritable objects. |
| 43 //! |
| 44 //! To provide type-correctness, subclasses are expected to provide a public |
| 45 //! method that accepts a `scoped_ptr`-wrapped argument of the proper |
| 46 //! internal::MinidumpWritable subclass, and call this method with that |
| 47 //! argument. |
| 48 //! |
| 49 //! \note Valid in #kStateMutable. |
| 50 void AddChild(scoped_ptr<MinidumpWritable> child); |
| 51 |
| 52 //! \brief Returns `true` if no child objects have been added by AddChild(), |
| 53 //! and `false` if child objects are present. |
| 54 bool IsEmpty() const { return children_.empty(); } |
| 55 |
| 56 //! \brief Returns an object’s ::RVA objects referencing its children. |
| 57 //! |
| 58 //! \note The returned vector will be empty until the object advances to |
| 59 //! #kStateFrozen or beyond. |
| 60 const std::vector<RVA>& child_rvas() const { return child_rvas_; } |
| 61 |
| 62 // MinidumpWritable: |
| 63 bool Freeze() override; |
| 64 size_t SizeOfObject() override; |
| 65 std::vector<MinidumpWritable*> Children() override; |
| 66 bool WriteObject(FileWriterInterface* file_writer) override; |
| 67 |
| 68 private: |
| 69 MinidumpRVAList rva_list_base_; |
| 70 PointerVector<MinidumpWritable> children_; |
| 71 std::vector<RVA> child_rvas_; |
| 72 |
| 73 DISALLOW_COPY_AND_ASSIGN(MinidumpRVAListWriter); |
| 74 }; |
| 75 |
| 76 } // namespace crashpad |
| 77 |
| 78 #endif // CRASHPAD_MINIDUMP_RVA_LIST_WRITER_H_ |
OLD | NEW |