OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/crash_upload_list/crash_upload_list_android.h" |
| 6 |
| 7 #include "base/files/file.h" |
| 8 #include "base/files/file_enumerator.h" |
| 9 #include "base/files/file_util.h" |
| 10 #include "base/threading/sequenced_worker_pool.h" |
| 11 |
| 12 CrashUploadListAndroid::CrashUploadListAndroid( |
| 13 Delegate* delegate, |
| 14 const base::FilePath& upload_log_path, |
| 15 const scoped_refptr<base::SequencedWorkerPool>& worker_pool) |
| 16 : CrashUploadList(delegate, upload_log_path, worker_pool) {} |
| 17 |
| 18 CrashUploadListAndroid::~CrashUploadListAndroid() {} |
| 19 |
| 20 void CrashUploadListAndroid::LoadUploadList( |
| 21 std::vector<UploadList::UploadInfo>* uploads) { |
| 22 // This will load the list of successfully uploaded logs. |
| 23 CrashUploadList::LoadUploadList(uploads); |
| 24 |
| 25 LoadUnsuccessfulUploadList(uploads); |
| 26 } |
| 27 |
| 28 void CrashUploadListAndroid::LoadUnsuccessfulUploadList( |
| 29 std::vector<UploadInfo>* uploads) { |
| 30 const char unsuccessful_uploads[] = ".dmp"; |
| 31 const char skipped_uploads[] = ".skipped"; |
| 32 |
| 33 base::FileEnumerator files(upload_log_path().DirName(), false, |
| 34 base::FileEnumerator::FILES); |
| 35 for (base::FilePath file = files.Next(); !file.empty(); file = files.Next()) { |
| 36 if (file.value().find(unsuccessful_uploads) == std::string::npos && |
| 37 file.value().find(skipped_uploads) == std::string::npos) |
| 38 continue; |
| 39 |
| 40 base::File::Info info; |
| 41 if (!base::GetFileInfo(file, &info)) |
| 42 continue; |
| 43 |
| 44 // Crash reports can have multiple extensions (e.g. foo.dmp, foo.dmp.try1, |
| 45 // foo.skipped.try0). |
| 46 file = file.BaseName(); |
| 47 while (file != file.RemoveExtension()) |
| 48 file = file.RemoveExtension(); |
| 49 |
| 50 // ID is the last part of the file name. e.g. |
| 51 // chromium-renderer-minidump-f297dbcba7a2d0bb. |
| 52 std::string id = file.value(); |
| 53 std::size_t pos = id.find_last_of("-"); |
| 54 if (pos == std::string::npos) |
| 55 continue; |
| 56 |
| 57 id = id.substr(pos + 1); |
| 58 UploadList::UploadInfo upload(std::string(), base::Time(), id, |
| 59 info.creation_time, |
| 60 UploadList::UploadInfo::State::NotUploaded); |
| 61 uploads->push_back(upload); |
| 62 } |
| 63 } |
OLD | NEW |