| 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_SIMPLE_STRING_DICTIONARY_WRITER_H_ | 15 #ifndef CRASHPAD_MINIDUMP_MINIDUMP_SIMPLE_STRING_DICTIONARY_WRITER_H_ |
| 16 #define CRASHPAD_MINIDUMP_MINIDUMP_SIMPLE_STRING_DICTIONARY_WRITER_H_ | 16 #define CRASHPAD_MINIDUMP_MINIDUMP_SIMPLE_STRING_DICTIONARY_WRITER_H_ |
| 17 | 17 |
| 18 #include <sys/types.h> | 18 #include <sys/types.h> |
| 19 | 19 |
| 20 #include <string> | 20 #include <string> |
| 21 #include <map> | 21 #include <map> |
| 22 #include <vector> | 22 #include <vector> |
| 23 | 23 |
| 24 #include "base/basictypes.h" | 24 #include "base/basictypes.h" |
| 25 #include "base/memory/scoped_ptr.h" |
| 25 #include "minidump/minidump_extensions.h" | 26 #include "minidump/minidump_extensions.h" |
| 26 #include "minidump/minidump_string_writer.h" | 27 #include "minidump/minidump_string_writer.h" |
| 27 #include "minidump/minidump_writable.h" | 28 #include "minidump/minidump_writable.h" |
| 28 | 29 |
| 29 namespace crashpad { | 30 namespace crashpad { |
| 30 | 31 |
| 31 //! \brief The writer for a MinidumpSimpleStringDictionaryEntry object in a | 32 //! \brief The writer for a MinidumpSimpleStringDictionaryEntry object in a |
| 32 //! minidump file. | 33 //! minidump file. |
| 33 //! | 34 //! |
| 34 //! Because MinidumpSimpleStringDictionaryEntry objects only appear as elements | 35 //! Because MinidumpSimpleStringDictionaryEntry objects only appear as elements |
| 35 //! of MinidumpSimpleStringDictionary objects, this class does not write any | 36 //! of MinidumpSimpleStringDictionary objects, this class does not write any |
| 36 //! data on its own. It makes its MinidumpSimpleStringDictionaryEntry data | 37 //! data on its own. It makes its MinidumpSimpleStringDictionaryEntry data |
| 37 //! available to its MinidumpSimpleStringDictionaryWriter parent, which writes | 38 //! available to its MinidumpSimpleStringDictionaryWriter parent, which writes |
| 38 //! it as part of a MinidumpSimpleStringDictionary. | 39 //! it as part of a MinidumpSimpleStringDictionary. |
| 39 class MinidumpSimpleStringDictionaryEntryWriter final | 40 class MinidumpSimpleStringDictionaryEntryWriter final |
| 40 : public internal::MinidumpWritable { | 41 : public internal::MinidumpWritable { |
| 41 public: | 42 public: |
| 42 MinidumpSimpleStringDictionaryEntryWriter(); | 43 MinidumpSimpleStringDictionaryEntryWriter(); |
| 43 ~MinidumpSimpleStringDictionaryEntryWriter(); | 44 ~MinidumpSimpleStringDictionaryEntryWriter() override; |
| 44 | 45 |
| 45 //! \brief Returns a MinidumpSimpleStringDictionaryEntry referencing this | 46 //! \brief Returns a MinidumpSimpleStringDictionaryEntry referencing this |
| 46 //! object’s data. | 47 //! object’s data. |
| 47 //! | 48 //! |
| 48 //! This method is expected to be called by a | 49 //! This method is expected to be called by a |
| 49 //! MinidumpSimpleStringDictionaryWriter in order to obtain a | 50 //! MinidumpSimpleStringDictionaryWriter in order to obtain a |
| 50 //! MinidumpSimpleStringDictionaryEntry to include in its list. | 51 //! MinidumpSimpleStringDictionaryEntry to include in its list. |
| 51 //! | 52 //! |
| 52 //! \note Valid in #kStateWritable. | 53 //! \note Valid in #kStateWritable. |
| 53 const MinidumpSimpleStringDictionaryEntry* | 54 const MinidumpSimpleStringDictionaryEntry* |
| (...skipping 27 matching lines...) Expand all Loading... |
| 81 | 82 |
| 82 //! \brief The writer for a MinidumpSimpleStringDictionary object in a minidump | 83 //! \brief The writer for a MinidumpSimpleStringDictionary object in a minidump |
| 83 //! file, containing a list of MinidumpSimpleStringDictionaryEntry objects. | 84 //! file, containing a list of MinidumpSimpleStringDictionaryEntry objects. |
| 84 //! | 85 //! |
| 85 //! Because this class writes a representatin of a dictionary, the order of | 86 //! Because this class writes a representatin of a dictionary, the order of |
| 86 //! entries is insignificant. Entries may be written in any order. | 87 //! entries is insignificant. Entries may be written in any order. |
| 87 class MinidumpSimpleStringDictionaryWriter final | 88 class MinidumpSimpleStringDictionaryWriter final |
| 88 : public internal::MinidumpWritable { | 89 : public internal::MinidumpWritable { |
| 89 public: | 90 public: |
| 90 MinidumpSimpleStringDictionaryWriter(); | 91 MinidumpSimpleStringDictionaryWriter(); |
| 91 ~MinidumpSimpleStringDictionaryWriter(); | 92 ~MinidumpSimpleStringDictionaryWriter() override; |
| 92 | 93 |
| 93 //! \brief Adds a MinidumpSimpleStringDictionaryEntryWriter to the | 94 //! \brief Adds a MinidumpSimpleStringDictionaryEntryWriter to the |
| 94 //! MinidumpSimpleStringDictionary. | 95 //! MinidumpSimpleStringDictionary. |
| 95 //! | 96 //! |
| 96 //! \a entry will become a child of this object in the overall tree of | 97 //! This object takes ownership of \a entry and becomes its parent in the |
| 97 //! internal::MinidumpWritable objects. | 98 //! overall tree of internal::MinidumpWritable objects. |
| 98 //! | 99 //! |
| 99 //! If the key contained in \a entry duplicates the key of an entry already | 100 //! If the key contained in \a entry duplicates the key of an entry already |
| 100 //! present in the MinidumpSimpleStringDictionary, the new \a entry will | 101 //! present in the MinidumpSimpleStringDictionary, the new \a entry will |
| 101 //! replace the previous one. | 102 //! replace the previous one. |
| 102 //! | 103 //! |
| 103 //! \note Valid in #kStateMutable. | 104 //! \note Valid in #kStateMutable. |
| 104 void AddEntry(MinidumpSimpleStringDictionaryEntryWriter* entry); | 105 void AddEntry(scoped_ptr<MinidumpSimpleStringDictionaryEntryWriter> entry); |
| 105 | 106 |
| 106 protected: | 107 protected: |
| 107 // MinidumpWritable: | 108 // MinidumpWritable: |
| 108 | 109 |
| 109 bool Freeze() override; | 110 bool Freeze() override; |
| 110 size_t SizeOfObject() override; | 111 size_t SizeOfObject() override; |
| 111 std::vector<MinidumpWritable*> Children() override; | 112 std::vector<MinidumpWritable*> Children() override; |
| 112 bool WriteObject(FileWriterInterface* file_writer) override; | 113 bool WriteObject(FileWriterInterface* file_writer) override; |
| 113 | 114 |
| 114 private: | 115 private: |
| 115 MinidumpSimpleStringDictionary simple_string_dictionary_base_; | 116 MinidumpSimpleStringDictionary simple_string_dictionary_base_; |
| 116 std::map<std::string, MinidumpSimpleStringDictionaryEntryWriter*> | 117 |
| 117 entries_; // weak | 118 // This object owns the MinidumpSimpleStringDictionaryEntryWriter objects. |
| 119 std::map<std::string, MinidumpSimpleStringDictionaryEntryWriter*> entries_; |
| 118 | 120 |
| 119 DISALLOW_COPY_AND_ASSIGN(MinidumpSimpleStringDictionaryWriter); | 121 DISALLOW_COPY_AND_ASSIGN(MinidumpSimpleStringDictionaryWriter); |
| 120 }; | 122 }; |
| 121 | 123 |
| 122 } // namespace crashpad | 124 } // namespace crashpad |
| 123 | 125 |
| 124 #endif // CRASHPAD_MINIDUMP_MINIDUMP_SIMPLE_STRING_DICTIONARY_WRITER_H_ | 126 #endif // CRASHPAD_MINIDUMP_MINIDUMP_SIMPLE_STRING_DICTIONARY_WRITER_H_ |
| OLD | NEW |