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..23bf16b1711e9a09a1c50dc9fe37926cb0308e0e |
--- /dev/null |
+++ b/chrome/browser/crash_upload_list/crash_upload_list_android.cc |
@@ -0,0 +1,63 @@ |
+// 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 char* unsuccessful_uploads = ".dmp"; |
+ const char* 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 && |
+ file.value().find(skipped_uploads) == std::string::npos) |
+ continue; |
+ |
+ base::File::Info info; |
+ base::Time creation_time; |
+ if (base::GetFileInfo(file, &info)) |
+ creation_time = info.creation_time; |
Lei Zhang
2016/09/07 19:31:50
But if GetFileInfo() fails, that likely means some
gayane -on leave until 09-2017
2016/09/07 20:20:32
Done.
|
+ |
+ // Crash reports can have multiple extensions. |
+ 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, |
+ creation_time, |
+ UploadList::UploadInfo::State::NotUploaded); |
+ uploads->push_back(upload); |
+ } |
+} |