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_SNAPSHOT_TEST_TEST_PROCESS_SNAPSHOT_H_ | 15 #ifndef CRASHPAD_SNAPSHOT_TEST_TEST_PROCESS_SNAPSHOT_H_ |
16 #define CRASHPAD_SNAPSHOT_TEST_TEST_PROCESS_SNAPSHOT_H_ | 16 #define CRASHPAD_SNAPSHOT_TEST_TEST_PROCESS_SNAPSHOT_H_ |
17 | 17 |
18 #include <stdint.h> | 18 #include <stdint.h> |
19 #include <sys/time.h> | 19 #include <sys/time.h> |
20 #include <sys/types.h> | 20 #include <sys/types.h> |
21 | 21 |
22 #include <map> | 22 #include <map> |
| 23 #include <memory> |
23 #include <string> | 24 #include <string> |
24 #include <utility> | 25 #include <utility> |
25 #include <vector> | 26 #include <vector> |
26 | 27 |
27 #include "base/macros.h" | 28 #include "base/macros.h" |
28 #include "base/memory/scoped_ptr.h" | |
29 #include "snapshot/exception_snapshot.h" | 29 #include "snapshot/exception_snapshot.h" |
30 #include "snapshot/memory_map_region_snapshot.h" | 30 #include "snapshot/memory_map_region_snapshot.h" |
31 #include "snapshot/memory_snapshot.h" | 31 #include "snapshot/memory_snapshot.h" |
32 #include "snapshot/module_snapshot.h" | 32 #include "snapshot/module_snapshot.h" |
33 #include "snapshot/process_snapshot.h" | 33 #include "snapshot/process_snapshot.h" |
34 #include "snapshot/system_snapshot.h" | 34 #include "snapshot/system_snapshot.h" |
35 #include "snapshot/thread_snapshot.h" | 35 #include "snapshot/thread_snapshot.h" |
36 #include "snapshot/unloaded_module_snapshot.h" | 36 #include "snapshot/unloaded_module_snapshot.h" |
37 #include "util/misc/uuid.h" | 37 #include "util/misc/uuid.h" |
38 #include "util/stdlib/pointer_container.h" | 38 #include "util/stdlib/pointer_container.h" |
(...skipping 27 matching lines...) Expand all Loading... |
66 void SetClientID(const UUID& client_id) { client_id_ = client_id; } | 66 void SetClientID(const UUID& client_id) { client_id_ = client_id; } |
67 void SetAnnotationsSimpleMap( | 67 void SetAnnotationsSimpleMap( |
68 const std::map<std::string, std::string>& annotations_simple_map) { | 68 const std::map<std::string, std::string>& annotations_simple_map) { |
69 annotations_simple_map_ = annotations_simple_map; | 69 annotations_simple_map_ = annotations_simple_map; |
70 } | 70 } |
71 | 71 |
72 //! \brief Sets the system snapshot to be returned by System(). | 72 //! \brief Sets the system snapshot to be returned by System(). |
73 //! | 73 //! |
74 //! \param[in] system The system snapshot that System() will return. The | 74 //! \param[in] system The system snapshot that System() will return. The |
75 //! TestProcessSnapshot object takes ownership of \a system. | 75 //! TestProcessSnapshot object takes ownership of \a system. |
76 void SetSystem(scoped_ptr<SystemSnapshot> system) { | 76 void SetSystem(std::unique_ptr<SystemSnapshot> system) { |
77 system_ = std::move(system); | 77 system_ = std::move(system); |
78 } | 78 } |
79 | 79 |
80 //! \brief Adds a thread snapshot to be returned by Threads(). | 80 //! \brief Adds a thread snapshot to be returned by Threads(). |
81 //! | 81 //! |
82 //! \param[in] thread The thread snapshot that will be included in Threads(). | 82 //! \param[in] thread The thread snapshot that will be included in Threads(). |
83 //! The TestProcessSnapshot object takes ownership of \a thread. | 83 //! The TestProcessSnapshot object takes ownership of \a thread. |
84 void AddThread(scoped_ptr<ThreadSnapshot> thread) { | 84 void AddThread(std::unique_ptr<ThreadSnapshot> thread) { |
85 threads_.push_back(thread.release()); | 85 threads_.push_back(thread.release()); |
86 } | 86 } |
87 | 87 |
88 //! \brief Adds a module snapshot to be returned by Modules(). | 88 //! \brief Adds a module snapshot to be returned by Modules(). |
89 //! | 89 //! |
90 //! \param[in] module The module snapshot that will be included in Modules(). | 90 //! \param[in] module The module snapshot that will be included in Modules(). |
91 //! The TestProcessSnapshot object takes ownership of \a module. | 91 //! The TestProcessSnapshot object takes ownership of \a module. |
92 void AddModule(scoped_ptr<ModuleSnapshot> module) { | 92 void AddModule(std::unique_ptr<ModuleSnapshot> module) { |
93 modules_.push_back(module.release()); | 93 modules_.push_back(module.release()); |
94 } | 94 } |
95 | 95 |
96 //! \brief Adds an unloaded module snapshot to be returned by | 96 //! \brief Adds an unloaded module snapshot to be returned by |
97 //! UnloadedModules(). | 97 //! UnloadedModules(). |
98 //! | 98 //! |
99 //! \param[in] unloaded_module The unloaded module snapshot that will be | 99 //! \param[in] unloaded_module The unloaded module snapshot that will be |
100 //! included in UnloadedModules(). | 100 //! included in UnloadedModules(). |
101 void AddModule(const UnloadedModuleSnapshot& unloaded_module) { | 101 void AddModule(const UnloadedModuleSnapshot& unloaded_module) { |
102 unloaded_modules_.push_back(unloaded_module); | 102 unloaded_modules_.push_back(unloaded_module); |
103 } | 103 } |
104 | 104 |
105 //! \brief Sets the exception snapshot to be returned by Exception(). | 105 //! \brief Sets the exception snapshot to be returned by Exception(). |
106 //! | 106 //! |
107 //! \param[in] exception The exception snapshot that Exception() will return. | 107 //! \param[in] exception The exception snapshot that Exception() will return. |
108 //! The TestProcessSnapshot object takes ownership of \a exception. | 108 //! The TestProcessSnapshot object takes ownership of \a exception. |
109 void SetException(scoped_ptr<ExceptionSnapshot> exception) { | 109 void SetException(std::unique_ptr<ExceptionSnapshot> exception) { |
110 exception_ = std::move(exception); | 110 exception_ = std::move(exception); |
111 } | 111 } |
112 | 112 |
113 //! \brief Adds a memory map region snapshot to be returned by MemoryMap(). | 113 //! \brief Adds a memory map region snapshot to be returned by MemoryMap(). |
114 //! | 114 //! |
115 //! \param[in] region The memory map region snapshot that will be included in | 115 //! \param[in] region The memory map region snapshot that will be included in |
116 //! MemoryMap(). The TestProcessSnapshot object takes ownership of \a | 116 //! MemoryMap(). The TestProcessSnapshot object takes ownership of \a |
117 //! region. | 117 //! region. |
118 void AddMemoryMapRegion(scoped_ptr<MemoryMapRegionSnapshot> region) { | 118 void AddMemoryMapRegion(std::unique_ptr<MemoryMapRegionSnapshot> region) { |
119 memory_map_.push_back(region.release()); | 119 memory_map_.push_back(region.release()); |
120 } | 120 } |
121 | 121 |
122 //! \brief Adds a handle snapshot to be returned by Handles(). | 122 //! \brief Adds a handle snapshot to be returned by Handles(). |
123 //! | 123 //! |
124 //! \param[in] region The handle snapshot that will be included in Handles(). | 124 //! \param[in] region The handle snapshot that will be included in Handles(). |
125 void AddHandle(const HandleSnapshot& handle) { | 125 void AddHandle(const HandleSnapshot& handle) { |
126 handles_.push_back(handle); | 126 handles_.push_back(handle); |
127 } | 127 } |
128 | 128 |
129 //! \brief Add a memory snapshot to be returned by ExtraMemory(). | 129 //! \brief Add a memory snapshot to be returned by ExtraMemory(). |
130 //! | 130 //! |
131 //! \param[in] extra_memory The memory snapshot that will be included in | 131 //! \param[in] extra_memory The memory snapshot that will be included in |
132 //! ExtraMemory(). The TestProcessSnapshot object takes ownership of \a | 132 //! ExtraMemory(). The TestProcessSnapshot object takes ownership of \a |
133 //! extra_memory. | 133 //! extra_memory. |
134 void AddExtraMemory(scoped_ptr<MemorySnapshot> extra_memory) { | 134 void AddExtraMemory(std::unique_ptr<MemorySnapshot> extra_memory) { |
135 extra_memory_.push_back(extra_memory.release()); | 135 extra_memory_.push_back(extra_memory.release()); |
136 } | 136 } |
137 | 137 |
138 // ProcessSnapshot: | 138 // ProcessSnapshot: |
139 | 139 |
140 pid_t ProcessID() const override; | 140 pid_t ProcessID() const override; |
141 pid_t ParentProcessID() const override; | 141 pid_t ParentProcessID() const override; |
142 void SnapshotTime(timeval* snapshot_time) const override; | 142 void SnapshotTime(timeval* snapshot_time) const override; |
143 void ProcessStartTime(timeval* start_time) const override; | 143 void ProcessStartTime(timeval* start_time) const override; |
144 void ProcessCPUTimes(timeval* user_time, timeval* system_time) const override; | 144 void ProcessCPUTimes(timeval* user_time, timeval* system_time) const override; |
(...skipping 13 matching lines...) Expand all Loading... |
158 private: | 158 private: |
159 pid_t process_id_; | 159 pid_t process_id_; |
160 pid_t parent_process_id_; | 160 pid_t parent_process_id_; |
161 timeval snapshot_time_; | 161 timeval snapshot_time_; |
162 timeval process_start_time_; | 162 timeval process_start_time_; |
163 timeval process_cpu_user_time_; | 163 timeval process_cpu_user_time_; |
164 timeval process_cpu_system_time_; | 164 timeval process_cpu_system_time_; |
165 UUID report_id_; | 165 UUID report_id_; |
166 UUID client_id_; | 166 UUID client_id_; |
167 std::map<std::string, std::string> annotations_simple_map_; | 167 std::map<std::string, std::string> annotations_simple_map_; |
168 scoped_ptr<SystemSnapshot> system_; | 168 std::unique_ptr<SystemSnapshot> system_; |
169 PointerVector<ThreadSnapshot> threads_; | 169 PointerVector<ThreadSnapshot> threads_; |
170 PointerVector<ModuleSnapshot> modules_; | 170 PointerVector<ModuleSnapshot> modules_; |
171 std::vector<UnloadedModuleSnapshot> unloaded_modules_; | 171 std::vector<UnloadedModuleSnapshot> unloaded_modules_; |
172 scoped_ptr<ExceptionSnapshot> exception_; | 172 std::unique_ptr<ExceptionSnapshot> exception_; |
173 PointerVector<MemoryMapRegionSnapshot> memory_map_; | 173 PointerVector<MemoryMapRegionSnapshot> memory_map_; |
174 std::vector<HandleSnapshot> handles_; | 174 std::vector<HandleSnapshot> handles_; |
175 PointerVector<MemorySnapshot> extra_memory_; | 175 PointerVector<MemorySnapshot> extra_memory_; |
176 | 176 |
177 DISALLOW_COPY_AND_ASSIGN(TestProcessSnapshot); | 177 DISALLOW_COPY_AND_ASSIGN(TestProcessSnapshot); |
178 }; | 178 }; |
179 | 179 |
180 } // namespace test | 180 } // namespace test |
181 } // namespace crashpad | 181 } // namespace crashpad |
182 | 182 |
183 #endif // CRASHPAD_SNAPSHOT_TEST_TEST_PROCESS_SNAPSHOT_H_ | 183 #endif // CRASHPAD_SNAPSHOT_TEST_TEST_PROCESS_SNAPSHOT_H_ |
OLD | NEW |