| 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, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 class MemorySnapshot { | 25 class MemorySnapshot { |
| 26 public: | 26 public: |
| 27 //! \brief An interface that MemorySnapshot clients must implement in order to | 27 //! \brief An interface that MemorySnapshot clients must implement in order to |
| 28 //! receive memory snapshot data. | 28 //! receive memory snapshot data. |
| 29 //! | 29 //! |
| 30 //! This callback-based model frees MemorySnapshot implementations from having | 30 //! This callback-based model frees MemorySnapshot implementations from having |
| 31 //! to deal with memory region ownership problems. When a memory snapshot’s | 31 //! to deal with memory region ownership problems. When a memory snapshot’s |
| 32 //! data is read, it will be passed to a delegate method. | 32 //! data is read, it will be passed to a delegate method. |
| 33 class Delegate { | 33 class Delegate { |
| 34 public: | 34 public: |
| 35 virtual ~Delegate() {} |
| 36 |
| 35 //! \brief Called by MemorySnapshot::Read() to provide data requested by a | 37 //! \brief Called by MemorySnapshot::Read() to provide data requested by a |
| 36 //! call to that method. | 38 //! call to that method. |
| 37 //! | 39 //! |
| 38 //! \param[in] data A pointer to the data that was read. The callee does not | 40 //! \param[in] data A pointer to the data that was read. The callee does not |
| 39 //! take ownership of this data. This data is only valid for the | 41 //! take ownership of this data. This data is only valid for the |
| 40 //! duration of the call to this method. | 42 //! duration of the call to this method. |
| 41 //! \param[in] size The size of the data that was read. | 43 //! \param[in] size The size of the data that was read. |
| 42 //! | 44 //! |
| 43 //! \return `true` on success, `false` on failure. MemoryDelegate::Read() | 45 //! \return `true` on success, `false` on failure. MemoryDelegate::Read() |
| 44 //! will use this as its own return value. | 46 //! will use this as its own return value. |
| 45 virtual bool MemorySnapshotDelegateRead(void* data, size_t size) = 0; | 47 virtual bool MemorySnapshotDelegateRead(void* data, size_t size) = 0; |
| 48 }; |
| 46 | 49 |
| 47 protected: | 50 virtual ~MemorySnapshot() {} |
| 48 ~Delegate() {} | |
| 49 }; | |
| 50 | 51 |
| 51 //! \brief The base address of the memory snapshot in the snapshot process’ | 52 //! \brief The base address of the memory snapshot in the snapshot process’ |
| 52 //! address space. | 53 //! address space. |
| 53 virtual uint64_t Address() const = 0; | 54 virtual uint64_t Address() const = 0; |
| 54 | 55 |
| 55 //! \brief The size of the memory snapshot. | 56 //! \brief The size of the memory snapshot. |
| 56 virtual size_t Size() const = 0; | 57 virtual size_t Size() const = 0; |
| 57 | 58 |
| 58 //! \brief Calls Delegate::MemorySnapshotDelegateRead(), providing it with | 59 //! \brief Calls Delegate::MemorySnapshotDelegateRead(), providing it with |
| 59 //! the memory snapshot’s data. | 60 //! the memory snapshot’s data. |
| 60 //! | 61 //! |
| 61 //! Implementations do not necessarily read the memory snapshot data prior to | 62 //! Implementations do not necessarily read the memory snapshot data prior to |
| 62 //! this method being called. Memory snapshot data may be loaded lazily and | 63 //! this method being called. Memory snapshot data may be loaded lazily and |
| 63 //! may be discarded after being passed to the delegate. This provides clean | 64 //! may be discarded after being passed to the delegate. This provides clean |
| 64 //! memory management without burdening a snapshot implementation with the | 65 //! memory management without burdening a snapshot implementation with the |
| 65 //! requirement that it track all memory region data simultaneously. | 66 //! requirement that it track all memory region data simultaneously. |
| 66 //! | 67 //! |
| 67 //! \return `false` on failure, otherwise, the return value of | 68 //! \return `false` on failure, otherwise, the return value of |
| 68 //! Delegate::MemorySnapshotDelegateRead(), which should be `true` on | 69 //! Delegate::MemorySnapshotDelegateRead(), which should be `true` on |
| 69 //! success and `false` on failure. | 70 //! success and `false` on failure. |
| 70 virtual bool Read(Delegate* delegate) const = 0; | 71 virtual bool Read(Delegate* delegate) const = 0; |
| 71 | |
| 72 protected: | |
| 73 ~MemorySnapshot() {} | |
| 74 }; | 72 }; |
| 75 | 73 |
| 76 } // namespace crashpad | 74 } // namespace crashpad |
| 77 | 75 |
| 78 #endif // CRASHPAD_SNAPSHOT_MEMORY_SNAPSHOT_H_ | 76 #endif // CRASHPAD_SNAPSHOT_MEMORY_SNAPSHOT_H_ |
| OLD | NEW |