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 <utility> | 7 #include <utility> |
8 | 8 |
| 9 #include "base/android/context_utils.h" |
9 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
10 #include "base/android/jni_string.h" | 11 #include "base/android/jni_string.h" |
11 #include "base/files/file.h" | 12 #include "base/files/file.h" |
12 #include "base/files/file_enumerator.h" | 13 #include "base/files/file_enumerator.h" |
13 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
14 #include "base/task_runner.h" | 15 #include "base/task_runner.h" |
15 #include "jni/MinidumpUploadService_jni.h" | 16 #include "jni/MinidumpUploadService_jni.h" |
16 #include "ui/base/text/bytes_formatting.h" | 17 #include "ui/base/text/bytes_formatting.h" |
17 | 18 |
18 CrashUploadListAndroid::CrashUploadListAndroid( | 19 CrashUploadListAndroid::CrashUploadListAndroid( |
19 Delegate* delegate, | 20 Delegate* delegate, |
20 const base::FilePath& upload_log_path, | 21 const base::FilePath& upload_log_path, |
21 scoped_refptr<base::TaskRunner> task_runner) | 22 scoped_refptr<base::TaskRunner> task_runner) |
22 : CrashUploadList(delegate, upload_log_path, std::move(task_runner)) {} | 23 : CrashUploadList(delegate, upload_log_path, std::move(task_runner)) {} |
23 | 24 |
24 CrashUploadListAndroid::~CrashUploadListAndroid() {} | 25 CrashUploadListAndroid::~CrashUploadListAndroid() {} |
25 | 26 |
26 void CrashUploadListAndroid::LoadUploadList( | 27 void CrashUploadListAndroid::LoadUploadList( |
27 std::vector<UploadList::UploadInfo>* uploads) { | 28 std::vector<UploadList::UploadInfo>* uploads) { |
28 // This will load the list of successfully uploaded logs. | 29 // This will load the list of successfully uploaded logs. |
29 CrashUploadList::LoadUploadList(uploads); | 30 CrashUploadList::LoadUploadList(uploads); |
30 | 31 |
31 LoadUnsuccessfulUploadList(uploads); | 32 LoadUnsuccessfulUploadList(uploads); |
32 } | 33 } |
33 | 34 |
34 void CrashUploadListAndroid::RequestSingleCrashUpload( | 35 void CrashUploadListAndroid::RequestSingleCrashUpload( |
35 const std::string& local_id) { | 36 const std::string& local_id) { |
36 JNIEnv* env = base::android::AttachCurrentThread(); | 37 JNIEnv* env = base::android::AttachCurrentThread(); |
| 38 const base::android::JavaRef<jobject>& context = |
| 39 base::android::GetApplicationContext(); |
37 base::android::ScopedJavaLocalRef<jstring> j_local_id = | 40 base::android::ScopedJavaLocalRef<jstring> j_local_id = |
38 base::android::ConvertUTF8ToJavaString(env, local_id); | 41 base::android::ConvertUTF8ToJavaString(env, local_id); |
39 Java_MinidumpUploadService_tryUploadCrashDumpWithLocalId(env, j_local_id); | 42 Java_MinidumpUploadService_tryUploadCrashDumpWithLocalId(env, context, |
| 43 j_local_id); |
40 } | 44 } |
41 | 45 |
42 void CrashUploadListAndroid::LoadUnsuccessfulUploadList( | 46 void CrashUploadListAndroid::LoadUnsuccessfulUploadList( |
43 std::vector<UploadInfo>* uploads) { | 47 std::vector<UploadInfo>* uploads) { |
44 const char pending_uploads[] = ".dmp"; | 48 const char pending_uploads[] = ".dmp"; |
45 const char skipped_uploads[] = ".skipped"; | 49 const char skipped_uploads[] = ".skipped"; |
46 const char manually_forced_uploads[] = ".forced"; | 50 const char manually_forced_uploads[] = ".forced"; |
47 | 51 |
48 base::FileEnumerator files(upload_log_path().DirName(), false, | 52 base::FileEnumerator files(upload_log_path().DirName(), false, |
49 base::FileEnumerator::FILES); | 53 base::FileEnumerator::FILES); |
(...skipping 30 matching lines...) Expand all Loading... |
80 std::size_t pos = id.find_last_of("-"); | 84 std::size_t pos = id.find_last_of("-"); |
81 if (pos == std::string::npos) | 85 if (pos == std::string::npos) |
82 continue; | 86 continue; |
83 | 87 |
84 id = id.substr(pos + 1); | 88 id = id.substr(pos + 1); |
85 UploadList::UploadInfo upload(id, info.creation_time, upload_state, | 89 UploadList::UploadInfo upload(id, info.creation_time, upload_state, |
86 ui::FormatBytes(file_size)); | 90 ui::FormatBytes(file_size)); |
87 uploads->push_back(upload); | 91 uploads->push_back(upload); |
88 } | 92 } |
89 } | 93 } |
OLD | NEW |