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 std::string unsuccessful_uploads = ".dmp"; | |
Lei Zhang
2016/09/02 21:35:18
Can these be C strings?
gayane -on leave until 09-2017
2016/09/07 15:18:49
Done.
Lei Zhang
2016/09/07 19:31:50
To be specific, const char foo[] = "foo";
With co
| |
31 const std::string 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 && | |
Lei Zhang
2016/09/02 21:35:18
You actually want base::EndsWith() or file.Extensi
Ilya Sherman
2016/09/02 21:42:16
No, because crash report files have multiple exten
Lei Zhang
2016/09/02 21:51:59
I guess that answers my question below.
| |
37 file.value().find(skipped_uploads) == std::string::npos) | |
38 continue; | |
39 | |
40 base::File::Info info; | |
41 base::GetFileInfo(file, &info); | |
Lei Zhang
2016/09/02 21:35:18
And if this returns false?
gayane -on leave until 09-2017
2016/09/07 15:18:49
Done.
| |
42 | |
43 // Crash reports can have multiple extensions. | |
Lei Zhang
2016/09/02 21:35:18
Can you given an example? Does Chrome Android name
gayane -on leave until 09-2017
2016/09/07 15:18:49
It cannot be foo.dmp.skipped, but it can be foo.dm
Lei Zhang
2016/09/07 19:31:50
Rather than replying in the code review, can you a
| |
44 file = file.BaseName(); | |
45 while (file != file.RemoveExtension()) | |
46 file = file.RemoveExtension(); | |
47 | |
48 // ID is the last part of the file name. e.g. | |
49 // chromium-renderer-minidump-f297dbcba7a2d0bb. | |
50 std::string id = file.value(); | |
51 std::size_t pos = id.find_last_of("-"); | |
52 if (pos == std::string::npos) | |
53 continue; | |
54 | |
55 id = id.substr(pos + 1); | |
56 UploadList::UploadInfo upload(std::string(), base::Time(), id, | |
57 info.creation_time, | |
58 UploadList::UploadInfo::State::NotUploaded); | |
59 uploads->push_back(upload); | |
60 } | |
61 } | |
OLD | NEW |