| 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 #include "minidump/minidump_memory_writer.h" | 15 #include "minidump/minidump_memory_writer.h" |
| 16 | 16 |
| 17 #include <utility> |
| 18 |
| 17 #include "base/auto_reset.h" | 19 #include "base/auto_reset.h" |
| 18 #include "base/logging.h" | 20 #include "base/logging.h" |
| 19 #include "snapshot/memory_snapshot.h" | 21 #include "snapshot/memory_snapshot.h" |
| 20 #include "util/file/file_writer.h" | 22 #include "util/file/file_writer.h" |
| 21 #include "util/stdlib/move.h" | |
| 22 #include "util/numeric/safe_assignment.h" | 23 #include "util/numeric/safe_assignment.h" |
| 23 | 24 |
| 24 namespace crashpad { | 25 namespace crashpad { |
| 25 namespace { | 26 namespace { |
| 26 | 27 |
| 27 class SnapshotMinidumpMemoryWriter final : public MinidumpMemoryWriter, | 28 class SnapshotMinidumpMemoryWriter final : public MinidumpMemoryWriter, |
| 28 public MemorySnapshot::Delegate { | 29 public MemorySnapshot::Delegate { |
| 29 public: | 30 public: |
| 30 explicit SnapshotMinidumpMemoryWriter(const MemorySnapshot* memory_snapshot) | 31 explicit SnapshotMinidumpMemoryWriter(const MemorySnapshot* memory_snapshot) |
| 31 : MinidumpMemoryWriter(), | 32 : MinidumpMemoryWriter(), |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 MinidumpMemoryListWriter::~MinidumpMemoryListWriter() { | 172 MinidumpMemoryListWriter::~MinidumpMemoryListWriter() { |
| 172 } | 173 } |
| 173 | 174 |
| 174 void MinidumpMemoryListWriter::AddFromSnapshot( | 175 void MinidumpMemoryListWriter::AddFromSnapshot( |
| 175 const std::vector<const MemorySnapshot*>& memory_snapshots) { | 176 const std::vector<const MemorySnapshot*>& memory_snapshots) { |
| 176 DCHECK_EQ(state(), kStateMutable); | 177 DCHECK_EQ(state(), kStateMutable); |
| 177 | 178 |
| 178 for (const MemorySnapshot* memory_snapshot : memory_snapshots) { | 179 for (const MemorySnapshot* memory_snapshot : memory_snapshots) { |
| 179 scoped_ptr<MinidumpMemoryWriter> memory = | 180 scoped_ptr<MinidumpMemoryWriter> memory = |
| 180 MinidumpMemoryWriter::CreateFromSnapshot(memory_snapshot); | 181 MinidumpMemoryWriter::CreateFromSnapshot(memory_snapshot); |
| 181 AddMemory(crashpad::move(memory)); | 182 AddMemory(std::move(memory)); |
| 182 } | 183 } |
| 183 } | 184 } |
| 184 | 185 |
| 185 void MinidumpMemoryListWriter::AddMemory( | 186 void MinidumpMemoryListWriter::AddMemory( |
| 186 scoped_ptr<MinidumpMemoryWriter> memory_writer) { | 187 scoped_ptr<MinidumpMemoryWriter> memory_writer) { |
| 187 DCHECK_EQ(state(), kStateMutable); | 188 DCHECK_EQ(state(), kStateMutable); |
| 188 | 189 |
| 189 AddExtraMemory(memory_writer.get()); | 190 AddExtraMemory(memory_writer.get()); |
| 190 children_.push_back(memory_writer.release()); | 191 children_.push_back(memory_writer.release()); |
| 191 } | 192 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 } | 253 } |
| 253 | 254 |
| 254 return file_writer->WriteIoVec(&iovecs); | 255 return file_writer->WriteIoVec(&iovecs); |
| 255 } | 256 } |
| 256 | 257 |
| 257 MinidumpStreamType MinidumpMemoryListWriter::StreamType() const { | 258 MinidumpStreamType MinidumpMemoryListWriter::StreamType() const { |
| 258 return kMinidumpStreamTypeMemoryList; | 259 return kMinidumpStreamTypeMemoryList; |
| 259 } | 260 } |
| 260 | 261 |
| 261 } // namespace crashpad | 262 } // namespace crashpad |
| OLD | NEW |