OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chromecast/crash/linux/synchronized_minidump_manager.h" | 5 #include "chromecast/crash/linux/synchronized_minidump_manager.h" |
6 | 6 |
7 #include <dirent.h> | 7 #include <dirent.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <fcntl.h> | 9 #include <fcntl.h> |
10 #include <stddef.h> | 10 #include <stddef.h> |
11 #include <stdint.h> | 11 #include <stdint.h> |
12 #include <string.h> | 12 #include <string.h> |
13 #include <sys/file.h> | 13 #include <sys/file.h> |
14 #include <sys/stat.h> | 14 #include <sys/stat.h> |
15 #include <sys/types.h> | 15 #include <sys/types.h> |
16 #include <time.h> | 16 #include <time.h> |
17 #include <unistd.h> | 17 #include <unistd.h> |
| 18 #include <utility> |
18 | 19 |
19 #include "base/files/dir_reader_posix.h" | 20 #include "base/files/dir_reader_posix.h" |
20 #include "base/files/file_util.h" | 21 #include "base/files/file_util.h" |
21 #include "base/logging.h" | 22 #include "base/logging.h" |
22 #include "base/strings/string_split.h" | 23 #include "base/strings/string_split.h" |
23 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
24 #include "chromecast/base/path_utils.h" | 25 #include "chromecast/base/path_utils.h" |
25 #include "chromecast/base/serializers.h" | 26 #include "chromecast/base/serializers.h" |
26 #include "chromecast/crash/linux/dump_info.h" | 27 #include "chromecast/crash/linux/dump_info.h" |
27 | 28 |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 | 264 |
264 scoped_ptr<base::ListValue> dumps = make_scoped_ptr(new base::ListValue()); | 265 scoped_ptr<base::ListValue> dumps = make_scoped_ptr(new base::ListValue()); |
265 | 266 |
266 // Validate dumps | 267 // Validate dumps |
267 for (const std::string& line : lines) { | 268 for (const std::string& line : lines) { |
268 if (line.size() == 0) | 269 if (line.size() == 0) |
269 continue; | 270 continue; |
270 scoped_ptr<base::Value> dump_info = DeserializeFromJson(line); | 271 scoped_ptr<base::Value> dump_info = DeserializeFromJson(line); |
271 DumpInfo info(dump_info.get()); | 272 DumpInfo info(dump_info.get()); |
272 RCHECK(info.valid(), -1); | 273 RCHECK(info.valid(), -1); |
273 dumps->Append(dump_info.Pass()); | 274 dumps->Append(std::move(dump_info)); |
274 } | 275 } |
275 | 276 |
276 scoped_ptr<base::Value> metadata = | 277 scoped_ptr<base::Value> metadata = |
277 DeserializeJsonFromFile(base::FilePath(metadata_path_)); | 278 DeserializeJsonFromFile(base::FilePath(metadata_path_)); |
278 RCHECK(ValidateMetadata(metadata.get()), -1); | 279 RCHECK(ValidateMetadata(metadata.get()), -1); |
279 | 280 |
280 dumps_ = dumps.Pass(); | 281 dumps_ = std::move(dumps); |
281 metadata_ = metadata.Pass(); | 282 metadata_ = std::move(metadata); |
282 return 0; | 283 return 0; |
283 } | 284 } |
284 | 285 |
285 int SynchronizedMinidumpManager::WriteFiles(const base::ListValue* dumps, | 286 int SynchronizedMinidumpManager::WriteFiles(const base::ListValue* dumps, |
286 const base::Value* metadata) { | 287 const base::Value* metadata) { |
287 DCHECK(dumps); | 288 DCHECK(dumps); |
288 DCHECK(metadata); | 289 DCHECK(metadata); |
289 std::string lockfile; | 290 std::string lockfile; |
290 | 291 |
291 for (const base::Value* elem : *dumps) { | 292 for (const base::Value* elem : *dumps) { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 metadata_.reset(); | 357 metadata_.reset(); |
357 } | 358 } |
358 | 359 |
359 ScopedVector<DumpInfo> SynchronizedMinidumpManager::GetDumps() { | 360 ScopedVector<DumpInfo> SynchronizedMinidumpManager::GetDumps() { |
360 ScopedVector<DumpInfo> dumps; | 361 ScopedVector<DumpInfo> dumps; |
361 | 362 |
362 for (const base::Value* elem : *dumps_) { | 363 for (const base::Value* elem : *dumps_) { |
363 dumps.push_back(new DumpInfo(elem)); | 364 dumps.push_back(new DumpInfo(elem)); |
364 } | 365 } |
365 | 366 |
366 return dumps.Pass(); | 367 return dumps; |
367 } | 368 } |
368 | 369 |
369 int SynchronizedMinidumpManager::SetCurrentDumps( | 370 int SynchronizedMinidumpManager::SetCurrentDumps( |
370 const ScopedVector<DumpInfo>& dumps) { | 371 const ScopedVector<DumpInfo>& dumps) { |
371 dumps_->Clear(); | 372 dumps_->Clear(); |
372 | 373 |
373 for (DumpInfo* dump : dumps) | 374 for (DumpInfo* dump : dumps) |
374 dumps_->Append(dump->GetAsValue()); | 375 dumps_->Append(dump->GetAsValue()); |
375 | 376 |
376 return 0; | 377 return 0; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 | 426 |
426 const std::string file_path = dump_path_.Append(reader.name()).value(); | 427 const std::string file_path = dump_path_.Append(reader.name()).value(); |
427 if (file_path != lockfile_path_ && file_path != metadata_path_) | 428 if (file_path != lockfile_path_ && file_path != metadata_path_) |
428 return true; | 429 return true; |
429 } | 430 } |
430 | 431 |
431 return false; | 432 return false; |
432 } | 433 } |
433 | 434 |
434 } // namespace chromecast | 435 } // namespace chromecast |
OLD | NEW |