| 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_WRITABLE_H_ | 15 #ifndef CRASHPAD_MINIDUMP_MINIDUMP_WRITABLE_H_ |
| 16 #define CRASHPAD_MINIDUMP_MINIDUMP_WRITABLE_H_ | 16 #define CRASHPAD_MINIDUMP_MINIDUMP_WRITABLE_H_ |
| 17 | 17 |
| 18 #include <windows.h> | 18 #include <windows.h> |
| 19 #include <dbghelp.h> | 19 #include <dbghelp.h> |
| 20 #include <sys/types.h> | 20 #include <sys/types.h> |
| 21 | 21 |
| 22 #include <vector> | 22 #include <vector> |
| 23 | 23 |
| 24 #include "base/basictypes.h" | 24 #include "base/basictypes.h" |
| 25 #include "util/file/file_io.h" |
| 25 | 26 |
| 26 namespace crashpad { | 27 namespace crashpad { |
| 27 | 28 |
| 28 class FileWriterInterface; | 29 class FileWriterInterface; |
| 29 | 30 |
| 30 namespace internal { | 31 namespace internal { |
| 31 | 32 |
| 32 //! \brief The base class for all content that might be written to a minidump | 33 //! \brief The base class for all content that might be written to a minidump |
| 33 //! file. | 34 //! file. |
| 34 class MinidumpWritable { | 35 class MinidumpWritable { |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 //! the objects will be written to the minidump file. | 206 //! the objects will be written to the minidump file. |
| 206 //! | 207 //! |
| 207 //! \return The file size consumed by this object and all children, including | 208 //! \return The file size consumed by this object and all children, including |
| 208 //! any padding inserted to meet alignment requirements. On failure, | 209 //! any padding inserted to meet alignment requirements. On failure, |
| 209 //! #kInvalidSize, with an appropriate message logged. | 210 //! #kInvalidSize, with an appropriate message logged. |
| 210 //! | 211 //! |
| 211 //! \note This method cannot be overridden. Subclasses that need to perform | 212 //! \note This method cannot be overridden. Subclasses that need to perform |
| 212 //! processing when an object transitions to #kStateWritable should | 213 //! processing when an object transitions to #kStateWritable should |
| 213 //! implement WillWriteAtOffsetImpl(), which is called by this method. | 214 //! implement WillWriteAtOffsetImpl(), which is called by this method. |
| 214 size_t WillWriteAtOffset(Phase phase, | 215 size_t WillWriteAtOffset(Phase phase, |
| 215 off_t* offset, | 216 FileOffset* offset, |
| 216 std::vector<MinidumpWritable*>* write_sequence); | 217 std::vector<MinidumpWritable*>* write_sequence); |
| 217 | 218 |
| 218 //! \brief Called once an object’s writable file offset is determined, as it | 219 //! \brief Called once an object’s writable file offset is determined, as it |
| 219 //! transitions into #kStateWritable. | 220 //! transitions into #kStateWritable. |
| 220 //! | 221 //! |
| 221 //! Subclasses can override this method if they need to provide additional | 222 //! Subclasses can override this method if they need to provide additional |
| 222 //! processing once their writable file offset is known. Typically, this will | 223 //! processing once their writable file offset is known. Typically, this will |
| 223 //! be done by subclasses that handle certain RVAs themselves instead of using | 224 //! be done by subclasses that handle certain RVAs themselves instead of using |
| 224 //! the RegisterRVA() interface. | 225 //! the RegisterRVA() interface. |
| 225 //! | 226 //! |
| 226 //! \param[in] offset The file offset at which the object will be written. The | 227 //! \param[in] offset The file offset at which the object will be written. The |
| 227 //! value passed to this method will already have been adjusted to meet | 228 //! value passed to this method will already have been adjusted to meet |
| 228 //! alignment requirements. | 229 //! alignment requirements. |
| 229 //! | 230 //! |
| 230 //! \return `true` on success. `false` on error, indicating that the minidump | 231 //! \return `true` on success. `false` on error, indicating that the minidump |
| 231 //! file should not be written. | 232 //! file should not be written. |
| 232 //! | 233 //! |
| 233 //! \note Valid in #kStateFrozen. The object will transition to | 234 //! \note Valid in #kStateFrozen. The object will transition to |
| 234 //! #kStateWritable after this method returns. | 235 //! #kStateWritable after this method returns. |
| 235 virtual bool WillWriteAtOffsetImpl(off_t offset); | 236 virtual bool WillWriteAtOffsetImpl(FileOffset offset); |
| 236 | 237 |
| 237 //! \brief Writes the object, transitioning it from #kStateWritable to | 238 //! \brief Writes the object, transitioning it from #kStateWritable to |
| 238 //! #kStateWritten. | 239 //! #kStateWritten. |
| 239 //! | 240 //! |
| 240 //! Writes any padding necessary to meet alignment requirements, and then | 241 //! Writes any padding necessary to meet alignment requirements, and then |
| 241 //! calls WriteObject() to write the object’s content. | 242 //! calls WriteObject() to write the object’s content. |
| 242 //! | 243 //! |
| 243 //! \param[in] file_writer The file writer to receive the object’s content. | 244 //! \param[in] file_writer The file writer to receive the object’s content. |
| 244 //! | 245 //! |
| 245 //! \return `true` on success. `false` on error with an appropriate message | 246 //! \return `true` on success. `false` on error with an appropriate message |
| (...skipping 23 matching lines...) Expand all Loading... |
| 269 size_t leading_pad_bytes_; | 270 size_t leading_pad_bytes_; |
| 270 State state_; | 271 State state_; |
| 271 | 272 |
| 272 DISALLOW_COPY_AND_ASSIGN(MinidumpWritable); | 273 DISALLOW_COPY_AND_ASSIGN(MinidumpWritable); |
| 273 }; | 274 }; |
| 274 | 275 |
| 275 } // namespace internal | 276 } // namespace internal |
| 276 } // namespace crashpad | 277 } // namespace crashpad |
| 277 | 278 |
| 278 #endif // CRASHPAD_MINIDUMP_MINIDUMP_WRITABLE_H_ | 279 #endif // CRASHPAD_MINIDUMP_MINIDUMP_WRITABLE_H_ |
| OLD | NEW |