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 #ifndef CRASHPAD_MINIDUMP_MINIDUMP_MODULE_CRASHPAD_INFO_WRITER_H_ | 15 #ifndef CRASHPAD_MINIDUMP_MINIDUMP_MODULE_CRASHPAD_INFO_WRITER_H_ |
16 #define CRASHPAD_MINIDUMP_MINIDUMP_MODULE_CRASHPAD_INFO_WRITER_H_ | 16 #define CRASHPAD_MINIDUMP_MINIDUMP_MODULE_CRASHPAD_INFO_WRITER_H_ |
17 | 17 |
18 #include <stdint.h> | 18 #include <stdint.h> |
19 | 19 |
20 #include <vector> | 20 #include <vector> |
21 | 21 |
22 #include "base/basictypes.h" | 22 #include "base/basictypes.h" |
| 23 #include "base/memory/scoped_ptr.h" |
23 #include "minidump/minidump_extensions.h" | 24 #include "minidump/minidump_extensions.h" |
24 #include "minidump/minidump_writable.h" | 25 #include "minidump/minidump_writable.h" |
| 26 #include "util/stdlib/pointer_container.h" |
25 | 27 |
26 namespace crashpad { | 28 namespace crashpad { |
27 | 29 |
28 class MinidumpSimpleStringDictionaryWriter; | 30 class MinidumpSimpleStringDictionaryWriter; |
29 | 31 |
30 //! \brief The writer for a MinidumpModuleCrashpadInfo object in a minidump | 32 //! \brief The writer for a MinidumpModuleCrashpadInfo object in a minidump |
31 //! file. | 33 //! file. |
32 class MinidumpModuleCrashpadInfoWriter final | 34 class MinidumpModuleCrashpadInfoWriter final |
33 : public internal::MinidumpWritable { | 35 : public internal::MinidumpWritable { |
34 public: | 36 public: |
35 MinidumpModuleCrashpadInfoWriter(); | 37 MinidumpModuleCrashpadInfoWriter(); |
36 ~MinidumpModuleCrashpadInfoWriter(); | 38 ~MinidumpModuleCrashpadInfoWriter(); |
37 | 39 |
38 //! \brief Sets MinidumpModuleCrashpadInfo::minidump_module_list_index. | 40 //! \brief Sets MinidumpModuleCrashpadInfo::minidump_module_list_index. |
39 void SetMinidumpModuleListIndex(uint32_t minidump_module_list_index) { | 41 void SetMinidumpModuleListIndex(uint32_t minidump_module_list_index) { |
40 module_.minidump_module_list_index = minidump_module_list_index; | 42 module_.minidump_module_list_index = minidump_module_list_index; |
41 } | 43 } |
42 | 44 |
43 //! \brief Arranges for MinidumpModuleCrashpadInfo::simple_annotations to | 45 //! \brief Arranges for MinidumpModuleCrashpadInfo::simple_annotations to |
44 //! point to the MinidumpSimpleStringDictionaryWriter object to be written | 46 //! point to the MinidumpSimpleStringDictionaryWriter object to be written |
45 //! by \a simple_annotations. | 47 //! by \a simple_annotations. |
46 //! | 48 //! |
47 //! \a simple_annotations will become a child of this object in the overall | 49 //! This object takes ownership of \a simple_annotations and becomes its |
48 //! tree of internal::MinidumpWritable objects. | 50 //! parent in the overall tree of internal::MinidumpWritable objects. |
49 //! | 51 //! |
50 //! \note Valid in #kStateMutable. | 52 //! \note Valid in #kStateMutable. |
51 void SetSimpleAnnotations( | 53 void SetSimpleAnnotations( |
52 MinidumpSimpleStringDictionaryWriter* simple_annotations); | 54 scoped_ptr<MinidumpSimpleStringDictionaryWriter> simple_annotations); |
53 | 55 |
54 protected: | 56 protected: |
55 // MinidumpWritable: | 57 // MinidumpWritable: |
56 bool Freeze() override; | 58 bool Freeze() override; |
57 size_t SizeOfObject() override; | 59 size_t SizeOfObject() override; |
58 std::vector<MinidumpWritable*> Children() override; | 60 std::vector<MinidumpWritable*> Children() override; |
59 bool WriteObject(FileWriterInterface* file_writer) override; | 61 bool WriteObject(FileWriterInterface* file_writer) override; |
60 | 62 |
61 private: | 63 private: |
62 MinidumpModuleCrashpadInfo module_; | 64 MinidumpModuleCrashpadInfo module_; |
63 MinidumpSimpleStringDictionaryWriter* simple_annotations_; // weak | 65 scoped_ptr<MinidumpSimpleStringDictionaryWriter> simple_annotations_; |
64 | 66 |
65 DISALLOW_COPY_AND_ASSIGN(MinidumpModuleCrashpadInfoWriter); | 67 DISALLOW_COPY_AND_ASSIGN(MinidumpModuleCrashpadInfoWriter); |
66 }; | 68 }; |
67 | 69 |
68 //! \brief The writer for a MinidumpModuleCrashpadInfoList object in a minidump | 70 //! \brief The writer for a MinidumpModuleCrashpadInfoList object in a minidump |
69 //! file, containing a list of MinidumpModuleCrashpadInfo objects. | 71 //! file, containing a list of MinidumpModuleCrashpadInfo objects. |
70 class MinidumpModuleCrashpadInfoListWriter final | 72 class MinidumpModuleCrashpadInfoListWriter final |
71 : public internal::MinidumpWritable { | 73 : public internal::MinidumpWritable { |
72 public: | 74 public: |
73 MinidumpModuleCrashpadInfoListWriter(); | 75 MinidumpModuleCrashpadInfoListWriter(); |
74 ~MinidumpModuleCrashpadInfoListWriter(); | 76 ~MinidumpModuleCrashpadInfoListWriter(); |
75 | 77 |
76 //! \brief Adds a MinidumpModuleCrashpadInfo to the | 78 //! \brief Adds a MinidumpModuleCrashpadInfo to the |
77 //! MinidumpModuleCrashpadInfoList. | 79 //! MinidumpModuleCrashpadInfoList. |
78 //! | 80 //! |
79 //! \a module will become a child of this object in the overall tree of | 81 //! This object takes ownership of \a module and becomes its parent in the |
80 //! internal::MinidumpWritable objects. | 82 //! overall tree of internal::MinidumpWritable objects. |
81 //! | 83 //! |
82 //! \note Valid in #kStateMutable. | 84 //! \note Valid in #kStateMutable. |
83 void AddModule(MinidumpModuleCrashpadInfoWriter* module); | 85 void AddModule(scoped_ptr<MinidumpModuleCrashpadInfoWriter> module); |
84 | 86 |
85 protected: | 87 protected: |
86 // MinidumpWritable: | 88 // MinidumpWritable: |
87 bool Freeze() override; | 89 bool Freeze() override; |
88 size_t SizeOfObject() override; | 90 size_t SizeOfObject() override; |
89 std::vector<MinidumpWritable*> Children() override; | 91 std::vector<MinidumpWritable*> Children() override; |
90 bool WriteObject(FileWriterInterface* file_writer) override; | 92 bool WriteObject(FileWriterInterface* file_writer) override; |
91 | 93 |
92 private: | 94 private: |
93 MinidumpModuleCrashpadInfoList module_list_base_; | 95 MinidumpModuleCrashpadInfoList module_list_base_; |
94 std::vector<MinidumpModuleCrashpadInfoWriter*> modules_; // weak | 96 PointerVector<MinidumpModuleCrashpadInfoWriter> modules_; |
95 std::vector<MINIDUMP_LOCATION_DESCRIPTOR> module_location_descriptors_; | 97 std::vector<MINIDUMP_LOCATION_DESCRIPTOR> module_location_descriptors_; |
96 | 98 |
97 DISALLOW_COPY_AND_ASSIGN(MinidumpModuleCrashpadInfoListWriter); | 99 DISALLOW_COPY_AND_ASSIGN(MinidumpModuleCrashpadInfoListWriter); |
98 }; | 100 }; |
99 | 101 |
100 } // namespace crashpad | 102 } // namespace crashpad |
101 | 103 |
102 #endif // CRASHPAD_MINIDUMP_MINIDUMP_MODULE_CRASHPAD_INFO_WRITER_H_ | 104 #endif // CRASHPAD_MINIDUMP_MINIDUMP_MODULE_CRASHPAD_INFO_WRITER_H_ |
OLD | NEW |