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" |
(...skipping 23 matching lines...) Expand all Loading... |
34 base::FileEnumerator::FILES); | 34 base::FileEnumerator::FILES); |
35 for (base::FilePath file = files.Next(); !file.empty(); file = files.Next()) { | 35 for (base::FilePath file = files.Next(); !file.empty(); file = files.Next()) { |
36 if (file.value().find(unsuccessful_uploads) == std::string::npos && | 36 if (file.value().find(unsuccessful_uploads) == std::string::npos && |
37 file.value().find(skipped_uploads) == std::string::npos) | 37 file.value().find(skipped_uploads) == std::string::npos) |
38 continue; | 38 continue; |
39 | 39 |
40 base::File::Info info; | 40 base::File::Info info; |
41 if (!base::GetFileInfo(file, &info)) | 41 if (!base::GetFileInfo(file, &info)) |
42 continue; | 42 continue; |
43 | 43 |
| 44 int64_t file_size = 0; |
| 45 if (!base::GetFileSize(file, &file_size)) |
| 46 continue; |
| 47 |
44 // Crash reports can have multiple extensions (e.g. foo.dmp, foo.dmp.try1, | 48 // Crash reports can have multiple extensions (e.g. foo.dmp, foo.dmp.try1, |
45 // foo.skipped.try0). | 49 // foo.skipped.try0). |
46 file = file.BaseName(); | 50 file = file.BaseName(); |
47 while (file != file.RemoveExtension()) | 51 while (file != file.RemoveExtension()) |
48 file = file.RemoveExtension(); | 52 file = file.RemoveExtension(); |
49 | 53 |
50 // ID is the last part of the file name. e.g. | 54 // ID is the last part of the file name. e.g. |
51 // chromium-renderer-minidump-f297dbcba7a2d0bb. | 55 // chromium-renderer-minidump-f297dbcba7a2d0bb. |
52 std::string id = file.value(); | 56 std::string id = file.value(); |
53 std::size_t pos = id.find_last_of("-"); | 57 std::size_t pos = id.find_last_of("-"); |
54 if (pos == std::string::npos) | 58 if (pos == std::string::npos) |
55 continue; | 59 continue; |
56 | 60 |
57 id = id.substr(pos + 1); | 61 id = id.substr(pos + 1); |
58 UploadList::UploadInfo upload(std::string(), base::Time(), id, | 62 UploadList::UploadInfo upload(id, info.creation_time, |
59 info.creation_time, | 63 UploadList::UploadInfo::State::NotUploaded, |
60 UploadList::UploadInfo::State::NotUploaded); | 64 file_size / 1024); |
61 uploads->push_back(upload); | 65 uploads->push_back(upload); |
62 } | 66 } |
63 } | 67 } |
OLD | NEW |