Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: snapshot/memory_snapshot.h

Issue 597673004: Add the Snapshot interface (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Make everything else const too Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « snapshot/exception_snapshot.h ('k') | snapshot/module_snapshot.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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_SNAPSHOT_MEMORY_SNAPSHOT_H_
16 #define CRASHPAD_SNAPSHOT_MEMORY_SNAPSHOT_H_
17
18 #include <stdint.h>
19 #include <sys/types.h>
20
21 namespace crashpad {
22
23 //! \brief An abstract interface to a snapshot representing a region of memory
24 //! present in a snapshot process.
25 class MemorySnapshot {
26 public:
27 //! \brief An interface that MemorySnapshot clients must implement in order to
28 //! receive memory snapshot data.
29 //!
30 //! This callback-based model frees MemorySnapshot implementations from having
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.
33 class Delegate {
34 public:
35 //! \brief Called by MemorySnapshot::Read() to provide data requested by a
36 //! call to that method.
37 //!
38 //! \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
40 //! duration of the call to this method.
41 //! \param[in] size The size of the data that was read.
42 //!
43 //! \return `true` on success, `false` on failure. MemoryDelegate::Read()
44 //! will use this as its own return value.
45 virtual bool MemorySnapshotDelegateRead(void* data, size_t size) = 0;
46
47 protected:
48 ~Delegate() {}
49 };
50
51 //! \brief The base address of the memory snapshot in the snapshot process’
52 //! address space.
53 virtual uint64_t Address() const = 0;
54
55 //! \brief The size of the memory snapshot.
56 virtual size_t Size() const = 0;
57
58 //! \brief Calls Delegate::MemorySnapshotDelegateRead(), providing it with
59 //! the memory snapshot’s data.
60 //!
61 //! 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 //! may be discarded after being passed to the delegate. This provides clean
64 //! memory management without burdening a snapshot implementation with the
65 //! requirement that it track all memory region data simultaneously.
66 //!
67 //! \return `false` on failure, otherwise, the return value of
68 //! Delegate::MemorySnapshotDelegateRead(), which should be `true` on
69 //! success and `false` on failure.
70 virtual bool Read(Delegate* delegate) const = 0;
71
72 protected:
73 ~MemorySnapshot() {}
74 };
75
76 } // namespace crashpad
77
78 #endif // CRASHPAD_SNAPSHOT_MEMORY_SNAPSHOT_H_
OLDNEW
« no previous file with comments | « snapshot/exception_snapshot.h ('k') | snapshot/module_snapshot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698