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/android/jni_android.h" | |
8 #include "base/android/jni_string.h" | |
7 #include "base/files/file.h" | 9 #include "base/files/file.h" |
8 #include "base/files/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" |
9 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
10 #include "base/threading/sequenced_worker_pool.h" | 12 #include "base/threading/sequenced_worker_pool.h" |
13 #include "jni/MinidumpUploadService_jni.h" | |
11 | 14 |
12 CrashUploadListAndroid::CrashUploadListAndroid( | 15 CrashUploadListAndroid::CrashUploadListAndroid( |
13 Delegate* delegate, | 16 Delegate* delegate, |
14 const base::FilePath& upload_log_path, | 17 const base::FilePath& upload_log_path, |
15 const scoped_refptr<base::SequencedWorkerPool>& worker_pool) | 18 const scoped_refptr<base::SequencedWorkerPool>& worker_pool) |
16 : CrashUploadList(delegate, upload_log_path, worker_pool) {} | 19 : CrashUploadList(delegate, upload_log_path, worker_pool) {} |
17 | 20 |
18 CrashUploadListAndroid::~CrashUploadListAndroid() {} | 21 CrashUploadListAndroid::~CrashUploadListAndroid() {} |
19 | 22 |
20 void CrashUploadListAndroid::LoadUploadList( | 23 void CrashUploadListAndroid::LoadUploadList( |
21 std::vector<UploadList::UploadInfo>* uploads) { | 24 std::vector<UploadList::UploadInfo>* uploads) { |
22 // This will load the list of successfully uploaded logs. | 25 // This will load the list of successfully uploaded logs. |
23 CrashUploadList::LoadUploadList(uploads); | 26 CrashUploadList::LoadUploadList(uploads); |
24 | 27 |
25 LoadUnsuccessfulUploadList(uploads); | 28 LoadUnsuccessfulUploadList(uploads); |
26 } | 29 } |
27 | 30 |
31 void CrashUploadListAndroid::RequestSingleCrashUpload( | |
32 const std::string& local_id) { | |
33 JNIEnv* env = base::android::AttachCurrentThread(); | |
34 base::android::ScopedJavaLocalRef<jstring> j_local_id = | |
35 base::android::ConvertUTF8ToJavaString(env, local_id); | |
36 Java_MinidumpUploadService_tryUploadCrashDumpWithLocalId(env, j_local_id); | |
37 } | |
38 | |
28 void CrashUploadListAndroid::LoadUnsuccessfulUploadList( | 39 void CrashUploadListAndroid::LoadUnsuccessfulUploadList( |
29 std::vector<UploadInfo>* uploads) { | 40 std::vector<UploadInfo>* uploads) { |
30 const char unsuccessful_uploads[] = ".dmp"; | 41 const char unsuccessful_uploads[] = ".dmp"; |
31 const char skipped_uploads[] = ".skipped"; | 42 const char skipped_uploads[] = ".skipped"; |
gayane -on leave until 09-2017
2016/09/09 18:18:29
We should also show .forced crashes here it should
Ilya Sherman
2016/09/09 23:02:56
Done.
| |
32 | 43 |
33 base::FileEnumerator files(upload_log_path().DirName(), false, | 44 base::FileEnumerator files(upload_log_path().DirName(), false, |
34 base::FileEnumerator::FILES); | 45 base::FileEnumerator::FILES); |
35 for (base::FilePath file = files.Next(); !file.empty(); file = files.Next()) { | 46 for (base::FilePath file = files.Next(); !file.empty(); file = files.Next()) { |
36 if (file.value().find(unsuccessful_uploads) == std::string::npos && | 47 if (file.value().find(unsuccessful_uploads) == std::string::npos && |
37 file.value().find(skipped_uploads) == std::string::npos) | 48 file.value().find(skipped_uploads) == std::string::npos) |
38 continue; | 49 continue; |
39 | 50 |
40 base::File::Info info; | 51 base::File::Info info; |
41 if (!base::GetFileInfo(file, &info)) | 52 if (!base::GetFileInfo(file, &info)) |
(...skipping 12 matching lines...) Expand all Loading... | |
54 if (pos == std::string::npos) | 65 if (pos == std::string::npos) |
55 continue; | 66 continue; |
56 | 67 |
57 id = id.substr(pos + 1); | 68 id = id.substr(pos + 1); |
58 UploadList::UploadInfo upload(std::string(), base::Time(), id, | 69 UploadList::UploadInfo upload(std::string(), base::Time(), id, |
59 info.creation_time, | 70 info.creation_time, |
60 UploadList::UploadInfo::State::NotUploaded); | 71 UploadList::UploadInfo::State::NotUploaded); |
61 uploads->push_back(upload); | 72 uploads->push_back(upload); |
62 } | 73 } |
63 } | 74 } |
OLD | NEW |