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

Side by Side Diff: minidump/minidump_file_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
« no previous file with comments | « minidump/minidump_exception_writer_test.cc ('k') | minidump/minidump_file_writer_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 10 matching lines...) Expand all
21 #include "minidump/minidump_memory_info_writer.h" 21 #include "minidump/minidump_memory_info_writer.h"
22 #include "minidump/minidump_memory_writer.h" 22 #include "minidump/minidump_memory_writer.h"
23 #include "minidump/minidump_misc_info_writer.h" 23 #include "minidump/minidump_misc_info_writer.h"
24 #include "minidump/minidump_module_writer.h" 24 #include "minidump/minidump_module_writer.h"
25 #include "minidump/minidump_system_info_writer.h" 25 #include "minidump/minidump_system_info_writer.h"
26 #include "minidump/minidump_thread_id_map.h" 26 #include "minidump/minidump_thread_id_map.h"
27 #include "minidump/minidump_thread_writer.h" 27 #include "minidump/minidump_thread_writer.h"
28 #include "minidump/minidump_writer_util.h" 28 #include "minidump/minidump_writer_util.h"
29 #include "snapshot/process_snapshot.h" 29 #include "snapshot/process_snapshot.h"
30 #include "util/file/file_writer.h" 30 #include "util/file/file_writer.h"
31 #include "util/stdlib/move.h"
31 #include "util/numeric/safe_assignment.h" 32 #include "util/numeric/safe_assignment.h"
32 33
33 namespace crashpad { 34 namespace crashpad {
34 35
35 MinidumpFileWriter::MinidumpFileWriter() 36 MinidumpFileWriter::MinidumpFileWriter()
36 : MinidumpWritable(), header_(), streams_(), stream_types_() { 37 : MinidumpWritable(), header_(), streams_(), stream_types_() {
37 // Don’t set the signature field right away. Leave it set to 0, so that a 38 // Don’t set the signature field right away. Leave it set to 0, so that a
38 // partially-written minidump file isn’t confused for a complete and valid 39 // partially-written minidump file isn’t confused for a complete and valid
39 // one. The header will be rewritten in WriteToFile(). 40 // one. The header will be rewritten in WriteToFile().
40 header_.Signature = 0; 41 header_.Signature = 0;
(...skipping 19 matching lines...) Expand all
60 // done by MinidumpMiscInfoWriter::InitializeFromSnapshot(). Handling both 61 // done by MinidumpMiscInfoWriter::InitializeFromSnapshot(). Handling both
61 // timestamps in the same way allows the highest-fidelity computation of 62 // timestamps in the same way allows the highest-fidelity computation of
62 // process uptime as the difference between the two values. 63 // process uptime as the difference between the two values.
63 timeval snapshot_time; 64 timeval snapshot_time;
64 process_snapshot->SnapshotTime(&snapshot_time); 65 process_snapshot->SnapshotTime(&snapshot_time);
65 SetTimestamp(snapshot_time.tv_sec); 66 SetTimestamp(snapshot_time.tv_sec);
66 67
67 const SystemSnapshot* system_snapshot = process_snapshot->System(); 68 const SystemSnapshot* system_snapshot = process_snapshot->System();
68 auto system_info = make_scoped_ptr(new MinidumpSystemInfoWriter()); 69 auto system_info = make_scoped_ptr(new MinidumpSystemInfoWriter());
69 system_info->InitializeFromSnapshot(system_snapshot); 70 system_info->InitializeFromSnapshot(system_snapshot);
70 AddStream(system_info.Pass()); 71 AddStream(crashpad::move(system_info));
71 72
72 auto misc_info = make_scoped_ptr(new MinidumpMiscInfoWriter()); 73 auto misc_info = make_scoped_ptr(new MinidumpMiscInfoWriter());
73 misc_info->InitializeFromSnapshot(process_snapshot); 74 misc_info->InitializeFromSnapshot(process_snapshot);
74 AddStream(misc_info.Pass()); 75 AddStream(crashpad::move(misc_info));
75 76
76 auto memory_list = make_scoped_ptr(new MinidumpMemoryListWriter()); 77 auto memory_list = make_scoped_ptr(new MinidumpMemoryListWriter());
77 auto thread_list = make_scoped_ptr(new MinidumpThreadListWriter()); 78 auto thread_list = make_scoped_ptr(new MinidumpThreadListWriter());
78 thread_list->SetMemoryListWriter(memory_list.get()); 79 thread_list->SetMemoryListWriter(memory_list.get());
79 MinidumpThreadIDMap thread_id_map; 80 MinidumpThreadIDMap thread_id_map;
80 thread_list->InitializeFromSnapshot(process_snapshot->Threads(), 81 thread_list->InitializeFromSnapshot(process_snapshot->Threads(),
81 &thread_id_map); 82 &thread_id_map);
82 AddStream(thread_list.Pass()); 83 AddStream(crashpad::move(thread_list));
83 84
84 const ExceptionSnapshot* exception_snapshot = process_snapshot->Exception(); 85 const ExceptionSnapshot* exception_snapshot = process_snapshot->Exception();
85 if (exception_snapshot) { 86 if (exception_snapshot) {
86 auto exception = make_scoped_ptr(new MinidumpExceptionWriter()); 87 auto exception = make_scoped_ptr(new MinidumpExceptionWriter());
87 exception->InitializeFromSnapshot(exception_snapshot, thread_id_map); 88 exception->InitializeFromSnapshot(exception_snapshot, thread_id_map);
88 AddStream(exception.Pass()); 89 AddStream(crashpad::move(exception));
89 } 90 }
90 91
91 auto module_list = make_scoped_ptr(new MinidumpModuleListWriter()); 92 auto module_list = make_scoped_ptr(new MinidumpModuleListWriter());
92 module_list->InitializeFromSnapshot(process_snapshot->Modules()); 93 module_list->InitializeFromSnapshot(process_snapshot->Modules());
93 AddStream(module_list.Pass()); 94 AddStream(crashpad::move(module_list));
94 95
95 auto crashpad_info = make_scoped_ptr(new MinidumpCrashpadInfoWriter()); 96 auto crashpad_info = make_scoped_ptr(new MinidumpCrashpadInfoWriter());
96 crashpad_info->InitializeFromSnapshot(process_snapshot); 97 crashpad_info->InitializeFromSnapshot(process_snapshot);
97 98
98 // Since the MinidumpCrashpadInfo stream is an extension, it’s safe to not add 99 // Since the MinidumpCrashpadInfo stream is an extension, it’s safe to not add
99 // it to the minidump file if it wouldn’t carry any useful information. 100 // it to the minidump file if it wouldn’t carry any useful information.
100 if (crashpad_info->IsUseful()) { 101 if (crashpad_info->IsUseful()) {
101 AddStream(crashpad_info.Pass()); 102 AddStream(crashpad::move(crashpad_info));
102 } 103 }
103 104
104 std::vector<const MemoryMapRegionSnapshot*> memory_map_snapshot = 105 std::vector<const MemoryMapRegionSnapshot*> memory_map_snapshot =
105 process_snapshot->MemoryMap(); 106 process_snapshot->MemoryMap();
106 if (!memory_map_snapshot.empty()) { 107 if (!memory_map_snapshot.empty()) {
107 auto memory_info_list = make_scoped_ptr(new MinidumpMemoryInfoListWriter()); 108 auto memory_info_list = make_scoped_ptr(new MinidumpMemoryInfoListWriter());
108 memory_info_list->InitializeFromSnapshot(memory_map_snapshot); 109 memory_info_list->InitializeFromSnapshot(memory_map_snapshot);
109 AddStream(memory_info_list.Pass()); 110 AddStream(crashpad::move(memory_info_list));
110 } 111 }
111 112
112 std::vector<HandleSnapshot> handles_snapshot = process_snapshot->Handles(); 113 std::vector<HandleSnapshot> handles_snapshot = process_snapshot->Handles();
113 if (!handles_snapshot.empty()) { 114 if (!handles_snapshot.empty()) {
114 auto handle_data_writer = make_scoped_ptr(new MinidumpHandleDataWriter()); 115 auto handle_data_writer = make_scoped_ptr(new MinidumpHandleDataWriter());
115 handle_data_writer->InitializeFromSnapshot(handles_snapshot); 116 handle_data_writer->InitializeFromSnapshot(handles_snapshot);
116 AddStream(handle_data_writer.Pass()); 117 AddStream(crashpad::move(handle_data_writer));
117 } 118 }
118 119
119 memory_list->AddFromSnapshot(process_snapshot->ExtraMemory()); 120 memory_list->AddFromSnapshot(process_snapshot->ExtraMemory());
120 121
121 AddStream(memory_list.Pass()); 122 AddStream(crashpad::move(memory_list));
122 } 123 }
123 124
124 void MinidumpFileWriter::SetTimestamp(time_t timestamp) { 125 void MinidumpFileWriter::SetTimestamp(time_t timestamp) {
125 DCHECK_EQ(state(), kStateMutable); 126 DCHECK_EQ(state(), kStateMutable);
126 127
127 internal::MinidumpWriterUtil::AssignTimeT(&header_.TimeDateStamp, timestamp); 128 internal::MinidumpWriterUtil::AssignTimeT(&header_.TimeDateStamp, timestamp);
128 } 129 }
129 130
130 void MinidumpFileWriter::AddStream( 131 void MinidumpFileWriter::AddStream(
131 scoped_ptr<internal::MinidumpStreamWriter> stream) { 132 scoped_ptr<internal::MinidumpStreamWriter> stream) {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 for (internal::MinidumpStreamWriter* stream : streams_) { 240 for (internal::MinidumpStreamWriter* stream : streams_) {
240 iov.iov_base = stream->DirectoryListEntry(); 241 iov.iov_base = stream->DirectoryListEntry();
241 iov.iov_len = sizeof(MINIDUMP_DIRECTORY); 242 iov.iov_len = sizeof(MINIDUMP_DIRECTORY);
242 iovecs.push_back(iov); 243 iovecs.push_back(iov);
243 } 244 }
244 245
245 return file_writer->WriteIoVec(&iovecs); 246 return file_writer->WriteIoVec(&iovecs);
246 } 247 }
247 248
248 } // namespace crashpad 249 } // namespace crashpad
OLDNEW
« no previous file with comments | « minidump/minidump_exception_writer_test.cc ('k') | minidump/minidump_file_writer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698