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

Side by Side Diff: third_party/crashpad/crashpad/minidump/minidump_user_stream_writer.cc

Issue 2814043003: Update Crashpad to 1f28a123a4c9449e3d7ddad4ff00dacd366d5216 (Closed)
Patch Set: Created 3 years, 8 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
OLDNEW
1 // Copyright 2016 The Crashpad Authors. All rights reserved. 1 // Copyright 2016 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 return writer_->Write(data, size); 49 return writer_->Write(data, size);
50 } 50 }
51 51
52 private: 52 private:
53 const MemorySnapshot* snapshot_; 53 const MemorySnapshot* snapshot_;
54 FileWriterInterface* writer_; 54 FileWriterInterface* writer_;
55 55
56 DISALLOW_COPY_AND_ASSIGN(SnapshotContentsWriter); 56 DISALLOW_COPY_AND_ASSIGN(SnapshotContentsWriter);
57 }; 57 };
58 58
59 class MinidumpUserStreamWriter::BufferContentsWriter final 59 class MinidumpUserStreamWriter::ExtensionStreamContentsWriter final
60 : public MinidumpUserStreamWriter::ContentsWriter { 60 : public MinidumpUserStreamWriter::ContentsWriter,
61 public MinidumpUserExtensionStreamDataSource::Delegate {
61 public: 62 public:
62 BufferContentsWriter(const void* buffer, size_t buffer_size) 63 explicit ExtensionStreamContentsWriter(
63 : buffer_(buffer), buffer_size_(buffer_size) {} 64 std::unique_ptr<MinidumpUserExtensionStreamDataSource> data_source)
65 : data_source_(std::move(data_source)), writer_(nullptr) {}
64 66
65 bool WriteContents(FileWriterInterface* writer) override { 67 bool WriteContents(FileWriterInterface* writer) override {
66 return writer->Write(buffer_, buffer_size_); 68 DCHECK(!writer_);
69
70 writer_ = writer;
71 return data_source_->ReadStreamData(this);
67 } 72 }
68 size_t GetSize() const override { return buffer_size_; } 73
74 size_t GetSize() const override { return data_source_->StreamDataSize(); }
75
76 bool ExtensionStreamDataSourceRead(const void* data, size_t size) override {
77 return writer_->Write(data, size);
78 }
69 79
70 private: 80 private:
71 const void* buffer_; 81 std::unique_ptr<MinidumpUserExtensionStreamDataSource> data_source_;
72 size_t buffer_size_; 82 FileWriterInterface* writer_;
73 83
74 DISALLOW_COPY_AND_ASSIGN(BufferContentsWriter); 84 DISALLOW_COPY_AND_ASSIGN(ExtensionStreamContentsWriter);
75 }; 85 };
76 86
77 MinidumpUserStreamWriter::MinidumpUserStreamWriter() : stream_type_() {} 87 MinidumpUserStreamWriter::MinidumpUserStreamWriter() : stream_type_() {}
78 88
79 MinidumpUserStreamWriter::~MinidumpUserStreamWriter() { 89 MinidumpUserStreamWriter::~MinidumpUserStreamWriter() {
80 } 90 }
81 91
82 void MinidumpUserStreamWriter::InitializeFromSnapshot( 92 void MinidumpUserStreamWriter::InitializeFromSnapshot(
83 const UserMinidumpStream* stream) { 93 const UserMinidumpStream* stream) {
84 DCHECK_EQ(state(), kStateMutable); 94 DCHECK_EQ(state(), kStateMutable);
85 DCHECK(!contents_writer_.get()); 95 DCHECK(!contents_writer_.get());
86 96
87 stream_type_ = static_cast<MinidumpStreamType>(stream->stream_type()); 97 stream_type_ = static_cast<MinidumpStreamType>(stream->stream_type());
88 contents_writer_ = 98 contents_writer_ =
89 base::WrapUnique(new SnapshotContentsWriter(stream->memory())); 99 base::WrapUnique(new SnapshotContentsWriter(stream->memory()));
90 } 100 }
91 101
92 void MinidumpUserStreamWriter::InitializeFromBuffer( 102 void MinidumpUserStreamWriter::InitializeFromUserExtensionStream(
93 MinidumpStreamType stream_type, 103 std::unique_ptr<MinidumpUserExtensionStreamDataSource> data_source) {
94 const void* buffer,
95 size_t buffer_size) {
96 DCHECK_EQ(state(), kStateMutable); 104 DCHECK_EQ(state(), kStateMutable);
97 DCHECK(!contents_writer_.get()); 105 DCHECK(!contents_writer_.get());
98 106
99 stream_type_ = stream_type; 107 stream_type_ = data_source->stream_type();
100 contents_writer_ = 108 contents_writer_ = base::WrapUnique(
101 base::WrapUnique(new BufferContentsWriter(buffer, buffer_size)); 109 new ExtensionStreamContentsWriter(std::move(data_source)));
102 } 110 }
103 111
104 bool MinidumpUserStreamWriter::Freeze() { 112 bool MinidumpUserStreamWriter::Freeze() {
105 DCHECK_EQ(state(), kStateMutable); 113 DCHECK_EQ(state(), kStateMutable);
106 DCHECK_NE(stream_type_, 0u); 114 DCHECK_NE(stream_type_, 0u);
107 return MinidumpStreamWriter::Freeze(); 115 return MinidumpStreamWriter::Freeze();
108 } 116 }
109 117
110 size_t MinidumpUserStreamWriter::SizeOfObject() { 118 size_t MinidumpUserStreamWriter::SizeOfObject() {
111 DCHECK_GE(state(), kStateFrozen); 119 DCHECK_GE(state(), kStateFrozen);
(...skipping 11 matching lines...) Expand all
123 DCHECK_EQ(state(), kStateWritable); 131 DCHECK_EQ(state(), kStateWritable);
124 132
125 return contents_writer_->WriteContents(file_writer); 133 return contents_writer_->WriteContents(file_writer);
126 } 134 }
127 135
128 MinidumpStreamType MinidumpUserStreamWriter::StreamType() const { 136 MinidumpStreamType MinidumpUserStreamWriter::StreamType() const {
129 return static_cast<MinidumpStreamType>(stream_type_); 137 return static_cast<MinidumpStreamType>(stream_type_);
130 } 138 }
131 139
132 } // namespace crashpad 140 } // namespace crashpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698