Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Side by Side Diff: chrome/browser/crash_upload_list/crash_upload_list_android.cc

Issue 2301943003: Show not uploaded crashes for Android. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 <regex>
8
9 #include "base/files/file.h"
10 #include "base/files/file_enumerator.h"
11 #include "base/files/file_util.h"
12 #include "base/threading/sequenced_worker_pool.h"
13
14 CrashUploadListAndroid::CrashUploadListAndroid(
15 Delegate* delegate,
16 const base::FilePath& upload_log_path,
17 const scoped_refptr<base::SequencedWorkerPool>& worker_pool)
18 : CrashUploadList(delegate, upload_log_path, worker_pool) {}
19
20 CrashUploadListAndroid::~CrashUploadListAndroid() {}
21
22 void CrashUploadListAndroid::LoadUploadList(
23 std::vector<UploadList::UploadInfo>* uploads) {
24 // This will load list of successfully uploaded logs.
Ilya Sherman 2016/09/01 20:49:31 nit: s/will load list/will load the list
gayane -on leave until 09-2017 2016/09/01 22:17:59 Done.
25 CrashUploadList::LoadUploadList(uploads);
26
27 LoadUnsuccessfulUploadList(uploads);
28 }
29
30 void CrashUploadListAndroid::LoadUnsuccessfulUploadList(
31 std::vector<UploadInfo>* uploads) {
32 std::string pattern = "\\.dmp|\\.skipped";
Ilya Sherman 2016/09/01 20:49:31 Hmm, I think it should be appropriate to only scan
gayane -on leave until 09-2017 2016/09/01 22:17:59 I was thinking about the case when crash dump gets
Ilya Sherman 2016/09/01 22:43:04 Ah, good call! Okay =)
33 std::regex re(pattern);
34
35 base::FileEnumerator files(upload_log_path().DirName(), false,
36 base::FileEnumerator::FILES);
37 base::File::Info info;
Ilya Sherman 2016/09/01 20:49:31 nit: Could you please declare this closer to where
gayane -on leave until 09-2017 2016/09/01 22:17:58 Done.
38 for (base::FilePath file = files.Next(); !file.empty(); file = files.Next()) {
39 if (std::regex_search(file.value(), re)) {
Ilya Sherman 2016/09/01 20:49:31 I think it would be simpler to just have a string
Ilya Sherman 2016/09/01 20:49:31 nit: Mebbe reverse the condition and use a continu
gayane -on leave until 09-2017 2016/09/01 22:17:59 Done.
gayane -on leave until 09-2017 2016/09/01 22:17:59 Done.
40
41 file = file.BaseName();
42 while (file != file.RemoveExtension())
43 file = file.RemoveExtension();
44
45 // Id is the last part of the file name.
Ilya Sherman 2016/09/01 20:49:31 nit: It might help to include a sample file name i
Ilya Sherman 2016/09/01 20:49:31 nit: s/Id/ID
gayane -on leave until 09-2017 2016/09/01 22:17:58 Done.
gayane -on leave until 09-2017 2016/09/01 22:17:58 Done.
46 std::string id = file.value();
47 id = id.substr(id.find_last_of("-") + 1);
Ilya Sherman 2016/09/01 20:49:31 nit: Is it worth adding a DCHECK to verify that "-
gayane -on leave until 09-2017 2016/09/01 22:17:58 I added a condition to just ignore files that will
48
49 base::GetFileInfo(file, &info);
50 UploadList::UploadInfo upload("", base::Time(), id, info.creation_time,
Ilya Sherman 2016/09/01 20:49:31 nit: Prefer std::string() to ""
gayane -on leave until 09-2017 2016/09/01 22:17:58 Done.
51 UploadList::UploadInfo::State::NotUploaded);
52 uploads->push_back(upload);
53 }
54 }
55 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698