OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/crash_upload_list/crash_upload_list_android.h" | 5 #include "chrome/browser/crash_upload_list/crash_upload_list_android.h" |
6 | 6 |
7 #include "base/files/file.h" | 7 #include "base/files/file.h" |
8 #include "base/files/file_enumerator.h" | 8 #include "base/files/file_enumerator.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/threading/sequenced_worker_pool.h" | 10 #include "base/threading/sequenced_worker_pool.h" |
| 11 #include "ui/base/text/bytes_formatting.h" |
11 | 12 |
12 CrashUploadListAndroid::CrashUploadListAndroid( | 13 CrashUploadListAndroid::CrashUploadListAndroid( |
13 Delegate* delegate, | 14 Delegate* delegate, |
14 const base::FilePath& upload_log_path, | 15 const base::FilePath& upload_log_path, |
15 const scoped_refptr<base::SequencedWorkerPool>& worker_pool) | 16 const scoped_refptr<base::SequencedWorkerPool>& worker_pool) |
16 : CrashUploadList(delegate, upload_log_path, worker_pool) {} | 17 : CrashUploadList(delegate, upload_log_path, worker_pool) {} |
17 | 18 |
18 CrashUploadListAndroid::~CrashUploadListAndroid() {} | 19 CrashUploadListAndroid::~CrashUploadListAndroid() {} |
19 | 20 |
20 void CrashUploadListAndroid::LoadUploadList( | 21 void CrashUploadListAndroid::LoadUploadList( |
(...skipping 13 matching lines...) Expand all Loading... |
34 base::FileEnumerator::FILES); | 35 base::FileEnumerator::FILES); |
35 for (base::FilePath file = files.Next(); !file.empty(); file = files.Next()) { | 36 for (base::FilePath file = files.Next(); !file.empty(); file = files.Next()) { |
36 if (file.value().find(unsuccessful_uploads) == std::string::npos && | 37 if (file.value().find(unsuccessful_uploads) == std::string::npos && |
37 file.value().find(skipped_uploads) == std::string::npos) | 38 file.value().find(skipped_uploads) == std::string::npos) |
38 continue; | 39 continue; |
39 | 40 |
40 base::File::Info info; | 41 base::File::Info info; |
41 if (!base::GetFileInfo(file, &info)) | 42 if (!base::GetFileInfo(file, &info)) |
42 continue; | 43 continue; |
43 | 44 |
| 45 int64_t file_size = 0; |
| 46 if (!base::GetFileSize(file, &file_size)) |
| 47 continue; |
| 48 |
44 // Crash reports can have multiple extensions (e.g. foo.dmp, foo.dmp.try1, | 49 // Crash reports can have multiple extensions (e.g. foo.dmp, foo.dmp.try1, |
45 // foo.skipped.try0). | 50 // foo.skipped.try0). |
46 file = file.BaseName(); | 51 file = file.BaseName(); |
47 while (file != file.RemoveExtension()) | 52 while (file != file.RemoveExtension()) |
48 file = file.RemoveExtension(); | 53 file = file.RemoveExtension(); |
49 | 54 |
50 // ID is the last part of the file name. e.g. | 55 // ID is the last part of the file name. e.g. |
51 // chromium-renderer-minidump-f297dbcba7a2d0bb. | 56 // chromium-renderer-minidump-f297dbcba7a2d0bb. |
52 std::string id = file.value(); | 57 std::string id = file.value(); |
53 std::size_t pos = id.find_last_of("-"); | 58 std::size_t pos = id.find_last_of("-"); |
54 if (pos == std::string::npos) | 59 if (pos == std::string::npos) |
55 continue; | 60 continue; |
56 | 61 |
57 id = id.substr(pos + 1); | 62 id = id.substr(pos + 1); |
58 UploadList::UploadInfo upload(std::string(), base::Time(), id, | 63 UploadList::UploadInfo upload(id, info.creation_time, |
59 info.creation_time, | 64 UploadList::UploadInfo::State::NotUploaded, |
60 UploadList::UploadInfo::State::NotUploaded); | 65 ui::FormatBytes(file_size)); |
61 uploads->push_back(upload); | 66 uploads->push_back(upload); |
62 } | 67 } |
63 } | 68 } |
OLD | NEW |