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

Side by Side Diff: minidump/minidump_module_crashpad_info_writer.cc

Issue 1483073004: Replace use of .Pass() with crashpad::move(). (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: pass: . Created 5 years 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,
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_module_crashpad_info_writer.h" 15 #include "minidump/minidump_module_crashpad_info_writer.h"
16 16
17 #include <sys/types.h> 17 #include <sys/types.h>
18 18
19 #include "base/logging.h" 19 #include "base/logging.h"
20 #include "minidump/minidump_simple_string_dictionary_writer.h" 20 #include "minidump/minidump_simple_string_dictionary_writer.h"
21 #include "snapshot/module_snapshot.h" 21 #include "snapshot/module_snapshot.h"
22 #include "util/file/file_writer.h" 22 #include "util/file/file_writer.h"
23 #include "util/stdlib/move.h"
23 #include "util/numeric/safe_assignment.h" 24 #include "util/numeric/safe_assignment.h"
24 25
25 namespace crashpad { 26 namespace crashpad {
26 27
27 MinidumpModuleCrashpadInfoWriter::MinidumpModuleCrashpadInfoWriter() 28 MinidumpModuleCrashpadInfoWriter::MinidumpModuleCrashpadInfoWriter()
28 : MinidumpWritable(), 29 : MinidumpWritable(),
29 module_(), 30 module_(),
30 list_annotations_(), 31 list_annotations_(),
31 simple_annotations_() { 32 simple_annotations_() {
32 module_.version = MinidumpModuleCrashpadInfo::kVersion; 33 module_.version = MinidumpModuleCrashpadInfo::kVersion;
33 } 34 }
34 35
35 MinidumpModuleCrashpadInfoWriter::~MinidumpModuleCrashpadInfoWriter() { 36 MinidumpModuleCrashpadInfoWriter::~MinidumpModuleCrashpadInfoWriter() {
36 } 37 }
37 38
38 void MinidumpModuleCrashpadInfoWriter::InitializeFromSnapshot( 39 void MinidumpModuleCrashpadInfoWriter::InitializeFromSnapshot(
39 const ModuleSnapshot* module_snapshot) { 40 const ModuleSnapshot* module_snapshot) {
40 DCHECK_EQ(state(), kStateMutable); 41 DCHECK_EQ(state(), kStateMutable);
41 DCHECK(!list_annotations_); 42 DCHECK(!list_annotations_);
42 DCHECK(!simple_annotations_); 43 DCHECK(!simple_annotations_);
43 44
44 auto list_annotations = make_scoped_ptr(new MinidumpUTF8StringListWriter()); 45 auto list_annotations = make_scoped_ptr(new MinidumpUTF8StringListWriter());
45 list_annotations->InitializeFromVector(module_snapshot->AnnotationsVector()); 46 list_annotations->InitializeFromVector(module_snapshot->AnnotationsVector());
46 if (list_annotations->IsUseful()) { 47 if (list_annotations->IsUseful()) {
47 SetListAnnotations(list_annotations.Pass()); 48 SetListAnnotations(crashpad::move(list_annotations));
48 } 49 }
49 50
50 auto simple_annotations = 51 auto simple_annotations =
51 make_scoped_ptr(new MinidumpSimpleStringDictionaryWriter()); 52 make_scoped_ptr(new MinidumpSimpleStringDictionaryWriter());
52 simple_annotations->InitializeFromMap( 53 simple_annotations->InitializeFromMap(
53 module_snapshot->AnnotationsSimpleMap()); 54 module_snapshot->AnnotationsSimpleMap());
54 if (simple_annotations->IsUseful()) { 55 if (simple_annotations->IsUseful()) {
55 SetSimpleAnnotations(simple_annotations.Pass()); 56 SetSimpleAnnotations(crashpad::move(simple_annotations));
56 } 57 }
57 } 58 }
58 59
59 void MinidumpModuleCrashpadInfoWriter::SetListAnnotations( 60 void MinidumpModuleCrashpadInfoWriter::SetListAnnotations(
60 scoped_ptr<MinidumpUTF8StringListWriter> list_annotations) { 61 scoped_ptr<MinidumpUTF8StringListWriter> list_annotations) {
61 DCHECK_EQ(state(), kStateMutable); 62 DCHECK_EQ(state(), kStateMutable);
62 63
63 list_annotations_ = list_annotations.Pass(); 64 list_annotations_ = crashpad::move(list_annotations);
64 } 65 }
65 66
66 void MinidumpModuleCrashpadInfoWriter::SetSimpleAnnotations( 67 void MinidumpModuleCrashpadInfoWriter::SetSimpleAnnotations(
67 scoped_ptr<MinidumpSimpleStringDictionaryWriter> simple_annotations) { 68 scoped_ptr<MinidumpSimpleStringDictionaryWriter> simple_annotations) {
68 DCHECK_EQ(state(), kStateMutable); 69 DCHECK_EQ(state(), kStateMutable);
69 70
70 simple_annotations_ = simple_annotations.Pass(); 71 simple_annotations_ = crashpad::move(simple_annotations);
71 } 72 }
72 73
73 bool MinidumpModuleCrashpadInfoWriter::IsUseful() const { 74 bool MinidumpModuleCrashpadInfoWriter::IsUseful() const {
74 return list_annotations_ || simple_annotations_; 75 return list_annotations_ || simple_annotations_;
75 } 76 }
76 77
77 bool MinidumpModuleCrashpadInfoWriter::Freeze() { 78 bool MinidumpModuleCrashpadInfoWriter::Freeze() {
78 DCHECK_EQ(state(), kStateMutable); 79 DCHECK_EQ(state(), kStateMutable);
79 80
80 if (!MinidumpWritable::Freeze()) { 81 if (!MinidumpWritable::Freeze()) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 DCHECK(module_crashpad_infos_.empty()); 138 DCHECK(module_crashpad_infos_.empty());
138 DCHECK(module_crashpad_info_links_.empty()); 139 DCHECK(module_crashpad_info_links_.empty());
139 140
140 size_t count = module_snapshots.size(); 141 size_t count = module_snapshots.size();
141 for (size_t index = 0; index < count; ++index) { 142 for (size_t index = 0; index < count; ++index) {
142 const ModuleSnapshot* module_snapshot = module_snapshots[index]; 143 const ModuleSnapshot* module_snapshot = module_snapshots[index];
143 144
144 auto module = make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter()); 145 auto module = make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter());
145 module->InitializeFromSnapshot(module_snapshot); 146 module->InitializeFromSnapshot(module_snapshot);
146 if (module->IsUseful()) { 147 if (module->IsUseful()) {
147 AddModule(module.Pass(), index); 148 AddModule(crashpad::move(module), index);
148 } 149 }
149 } 150 }
150 } 151 }
151 152
152 void MinidumpModuleCrashpadInfoListWriter::AddModule( 153 void MinidumpModuleCrashpadInfoListWriter::AddModule(
153 scoped_ptr<MinidumpModuleCrashpadInfoWriter> module_crashpad_info, 154 scoped_ptr<MinidumpModuleCrashpadInfoWriter> module_crashpad_info,
154 size_t minidump_module_list_index) { 155 size_t minidump_module_list_index) {
155 DCHECK_EQ(state(), kStateMutable); 156 DCHECK_EQ(state(), kStateMutable);
156 DCHECK_EQ(module_crashpad_infos_.size(), module_crashpad_info_links_.size()); 157 DCHECK_EQ(module_crashpad_infos_.size(), module_crashpad_info_links_.size());
157 158
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 iov.iov_base = &module_crashpad_info_links_[0]; 231 iov.iov_base = &module_crashpad_info_links_[0];
231 iov.iov_len = module_crashpad_info_links_.size() * 232 iov.iov_len = module_crashpad_info_links_.size() *
232 sizeof(module_crashpad_info_links_[0]); 233 sizeof(module_crashpad_info_links_[0]);
233 iovecs.push_back(iov); 234 iovecs.push_back(iov);
234 } 235 }
235 236
236 return file_writer->WriteIoVec(&iovecs); 237 return file_writer->WriteIoVec(&iovecs);
237 } 238 }
238 239
239 } // namespace crashpad 240 } // namespace crashpad
OLDNEW
« no previous file with comments | « minidump/minidump_misc_info_writer_test.cc ('k') | minidump/minidump_module_crashpad_info_writer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698