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_LOCATION_DESCRIPTOR_LIST_WRITER_H_ | |
16 #define CRASHPAD_MINIDUMP_LOCATION_DESCRIPTOR_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 MinidumpLocationDescriptorList object in a minidump | |
32 //! file, containing a list of MINIDUMP_LOCATION_DESCRIPTOR objects. | |
33 class MinidumpLocationDescriptorListWriter : public internal::MinidumpWritable { | |
34 protected: | |
35 MinidumpLocationDescriptorListWriter(); | |
36 ~MinidumpLocationDescriptorListWriter() override; | |
37 | |
38 //! \brief Adds a MINIDUMP_LOCATION_DESCRIPTOR referencing an | |
39 //! internal::MinidumpWritable to the MinidumpLocationDescriptorList. | |
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 an object’s children added with AddChild(). | |
53 const PointerVector<MinidumpWritable>& children() const { return children_; } | |
Robert Sesek
2014/11/06 19:44:28
Could you return this as a std::vector instead? Ye
Mark Mentovai
2014/11/06 20:37:05
Robert Sesek wrote:
| |
54 | |
55 //! \brief Returns an object’s MINIDUMP_LOCATION_DESCRIPTOR objects | |
56 //! 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<MINIDUMP_LOCATION_DESCRIPTOR>& child_location_descriptors() | |
61 const { | |
62 return child_location_descriptors_; | |
63 } | |
64 | |
65 // MinidumpWritable: | |
66 bool Freeze() override; | |
67 size_t SizeOfObject() override; | |
68 std::vector<MinidumpWritable*> Children() override; | |
69 bool WriteObject(FileWriterInterface* file_writer) override; | |
70 | |
71 private: | |
72 MinidumpLocationDescriptorList location_descriptor_list_base_; | |
73 PointerVector<MinidumpWritable> children_; | |
74 std::vector<MINIDUMP_LOCATION_DESCRIPTOR> child_location_descriptors_; | |
75 | |
76 DISALLOW_COPY_AND_ASSIGN(MinidumpLocationDescriptorListWriter); | |
77 }; | |
78 | |
79 } // namespace crashpad | |
80 | |
81 #endif // CRASHPAD_MINIDUMP_LOCATION_DESCRIPTOR_LIST_WRITER_H_ | |
OLD | NEW |