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

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

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

Powered by Google App Engine
This is Rietveld 408576698