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

Side by Side Diff: minidump/minidump_thread_writer.cc

Issue 674153002: minidump: Change the ownership model (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Rebase 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
OLDNEW
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 16 matching lines...) Expand all
27 MinidumpThreadWriter::MinidumpThreadWriter() 27 MinidumpThreadWriter::MinidumpThreadWriter()
28 : MinidumpWritable(), thread_(), stack_(nullptr), context_(nullptr) { 28 : MinidumpWritable(), thread_(), stack_(nullptr), context_(nullptr) {
29 } 29 }
30 30
31 const MINIDUMP_THREAD* MinidumpThreadWriter::MinidumpThread() const { 31 const MINIDUMP_THREAD* MinidumpThreadWriter::MinidumpThread() const {
32 DCHECK_EQ(state(), kStateWritable); 32 DCHECK_EQ(state(), kStateWritable);
33 33
34 return &thread_; 34 return &thread_;
35 } 35 }
36 36
37 void MinidumpThreadWriter::SetStack(MinidumpMemoryWriter* stack) { 37 void MinidumpThreadWriter::SetStack(scoped_ptr<MinidumpMemoryWriter> stack) {
38 DCHECK_EQ(state(), kStateMutable); 38 DCHECK_EQ(state(), kStateMutable);
39 39
40 stack_ = stack; 40 stack_ = stack.Pass();
41 } 41 }
42 42
43 void MinidumpThreadWriter::SetContext(MinidumpContextWriter* context) { 43 void MinidumpThreadWriter::SetContext(
44 scoped_ptr<MinidumpContextWriter> context) {
44 DCHECK_EQ(state(), kStateMutable); 45 DCHECK_EQ(state(), kStateMutable);
45 46
46 context_ = context; 47 context_ = context.Pass();
47 } 48 }
48 49
49 bool MinidumpThreadWriter::Freeze() { 50 bool MinidumpThreadWriter::Freeze() {
50 DCHECK_EQ(state(), kStateMutable); 51 DCHECK_EQ(state(), kStateMutable);
51 CHECK(context_); 52 CHECK(context_);
52 53
53 if (!MinidumpWritable::Freeze()) { 54 if (!MinidumpWritable::Freeze()) {
54 return false; 55 return false;
55 } 56 }
56 57
(...skipping 14 matching lines...) Expand all
71 // are responsible for writing themselves. 72 // are responsible for writing themselves.
72 return 0; 73 return 0;
73 } 74 }
74 75
75 std::vector<internal::MinidumpWritable*> MinidumpThreadWriter::Children() { 76 std::vector<internal::MinidumpWritable*> MinidumpThreadWriter::Children() {
76 DCHECK_GE(state(), kStateFrozen); 77 DCHECK_GE(state(), kStateFrozen);
77 DCHECK(context_); 78 DCHECK(context_);
78 79
79 std::vector<MinidumpWritable*> children; 80 std::vector<MinidumpWritable*> children;
80 if (stack_) { 81 if (stack_) {
81 children.push_back(stack_); 82 children.push_back(stack_.get());
82 } 83 }
83 children.push_back(context_); 84 children.push_back(context_.get());
84 85
85 return children; 86 return children;
86 } 87 }
87 88
88 bool MinidumpThreadWriter::WriteObject(FileWriterInterface* file_writer) { 89 bool MinidumpThreadWriter::WriteObject(FileWriterInterface* file_writer) {
89 DCHECK_EQ(state(), kStateWritable); 90 DCHECK_EQ(state(), kStateWritable);
90 91
91 // This object doesn’t directly write anything itself. Its MINIDUMP_THREAD is 92 // This object doesn’t directly write anything itself. Its MINIDUMP_THREAD is
92 // written by its parent as part of a MINIDUMP_THREAD_LIST, and its children 93 // written by its parent as part of a MINIDUMP_THREAD_LIST, and its children
93 // are responsible for writing themselves. 94 // are responsible for writing themselves.
(...skipping 11 matching lines...) Expand all
105 } 106 }
106 107
107 void MinidumpThreadListWriter::SetMemoryListWriter( 108 void MinidumpThreadListWriter::SetMemoryListWriter(
108 MinidumpMemoryListWriter* memory_list_writer) { 109 MinidumpMemoryListWriter* memory_list_writer) {
109 DCHECK_EQ(state(), kStateMutable); 110 DCHECK_EQ(state(), kStateMutable);
110 DCHECK(threads_.empty()); 111 DCHECK(threads_.empty());
111 112
112 memory_list_writer_ = memory_list_writer; 113 memory_list_writer_ = memory_list_writer;
113 } 114 }
114 115
115 void MinidumpThreadListWriter::AddThread(MinidumpThreadWriter* thread) { 116 void MinidumpThreadListWriter::AddThread(
117 scoped_ptr<MinidumpThreadWriter> thread) {
116 DCHECK_EQ(state(), kStateMutable); 118 DCHECK_EQ(state(), kStateMutable);
117 119
118 threads_.push_back(thread);
119
120 if (memory_list_writer_) { 120 if (memory_list_writer_) {
121 MinidumpMemoryWriter* stack = thread->Stack(); 121 MinidumpMemoryWriter* stack = thread->Stack();
122 if (stack) { 122 if (stack) {
123 memory_list_writer_->AddExtraMemory(stack); 123 memory_list_writer_->AddExtraMemory(stack);
124 } 124 }
125 } 125 }
126
127 threads_.push_back(thread.release());
126 } 128 }
127 129
128 bool MinidumpThreadListWriter::Freeze() { 130 bool MinidumpThreadListWriter::Freeze() {
129 DCHECK_EQ(state(), kStateMutable); 131 DCHECK_EQ(state(), kStateMutable);
130 132
131 if (!MinidumpStreamWriter::Freeze()) { 133 if (!MinidumpStreamWriter::Freeze()) {
132 return false; 134 return false;
133 } 135 }
134 136
135 size_t thread_count = threads_.size(); 137 size_t thread_count = threads_.size();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 175 }
174 176
175 return file_writer->WriteIoVec(&iovecs); 177 return file_writer->WriteIoVec(&iovecs);
176 } 178 }
177 179
178 MinidumpStreamType MinidumpThreadListWriter::StreamType() const { 180 MinidumpStreamType MinidumpThreadListWriter::StreamType() const {
179 return kMinidumpStreamTypeThreadList; 181 return kMinidumpStreamTypeThreadList;
180 } 182 }
181 183
182 } // namespace crashpad 184 } // namespace crashpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698