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

Unified Diff: chrome/browser/crash_upload_list/crash_upload_list_android.cc

Issue 2301943003: Show not uploaded crashes for Android. (Closed)
Patch Set: sync 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/crash_upload_list/crash_upload_list_android.cc
diff --git a/chrome/browser/crash_upload_list/crash_upload_list_android.cc b/chrome/browser/crash_upload_list/crash_upload_list_android.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1011e37a3482af431aad2bd0c445e93c47e83acd
--- /dev/null
+++ b/chrome/browser/crash_upload_list/crash_upload_list_android.cc
@@ -0,0 +1,61 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/crash_upload_list/crash_upload_list_android.h"
+
+#include "base/files/file.h"
+#include "base/files/file_enumerator.h"
+#include "base/files/file_util.h"
+#include "base/threading/sequenced_worker_pool.h"
+
+CrashUploadListAndroid::CrashUploadListAndroid(
+ Delegate* delegate,
+ const base::FilePath& upload_log_path,
+ const scoped_refptr<base::SequencedWorkerPool>& worker_pool)
+ : CrashUploadList(delegate, upload_log_path, worker_pool) {}
+
+CrashUploadListAndroid::~CrashUploadListAndroid() {}
+
+void CrashUploadListAndroid::LoadUploadList(
+ std::vector<UploadList::UploadInfo>* uploads) {
+ // This will load the list of successfully uploaded logs.
+ CrashUploadList::LoadUploadList(uploads);
+
+ LoadUnsuccessfulUploadList(uploads);
+}
+
+void CrashUploadListAndroid::LoadUnsuccessfulUploadList(
+ std::vector<UploadInfo>* uploads) {
+ 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
+ const std::string skipped_uploads = ".skipped";
+
+ base::FileEnumerator files(upload_log_path().DirName(), false,
+ base::FileEnumerator::FILES);
+ for (base::FilePath file = files.Next(); !file.empty(); file = files.Next()) {
+ 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.
+ file.value().find(skipped_uploads) == std::string::npos)
+ continue;
+
+ base::File::Info info;
+ 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.
+
+ // 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
+ file = file.BaseName();
+ while (file != file.RemoveExtension())
+ file = file.RemoveExtension();
+
+ // ID is the last part of the file name. e.g.
+ // chromium-renderer-minidump-f297dbcba7a2d0bb.
+ std::string id = file.value();
+ std::size_t pos = id.find_last_of("-");
+ if (pos == std::string::npos)
+ continue;
+
+ id = id.substr(pos + 1);
+ UploadList::UploadInfo upload(std::string(), base::Time(), id,
+ info.creation_time,
+ UploadList::UploadInfo::State::NotUploaded);
+ uploads->push_back(upload);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698