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

Side by Side Diff: android_webview/java/src/org/chromium/android_webview/crash/AwMinidumpUploaderDelegate.java

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 package org.chromium.android_webview.crash; 5 package org.chromium.android_webview.crash;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.net.ConnectivityManager; 8 import android.net.ConnectivityManager;
9 import android.webkit.ValueCallback; 9 import android.webkit.ValueCallback;
10 10
11 import org.chromium.android_webview.PlatformServiceBridge; 11 import org.chromium.android_webview.PlatformServiceBridge;
12 import org.chromium.android_webview.command_line.CommandLineUtil; 12 import org.chromium.android_webview.command_line.CommandLineUtil;
13 import org.chromium.base.CommandLine; 13 import org.chromium.base.CommandLine;
14 import org.chromium.base.ContextUtils;
14 import org.chromium.base.ThreadUtils; 15 import org.chromium.base.ThreadUtils;
15 import org.chromium.base.VisibleForTesting; 16 import org.chromium.base.VisibleForTesting;
16 import org.chromium.components.minidump_uploader.MinidumpUploaderDelegate; 17 import org.chromium.components.minidump_uploader.MinidumpUploaderDelegate;
17 import org.chromium.components.minidump_uploader.util.CrashReportingPermissionMa nager; 18 import org.chromium.components.minidump_uploader.util.CrashReportingPermissionMa nager;
18 import org.chromium.components.minidump_uploader.util.NetworkPermissionUtil; 19 import org.chromium.components.minidump_uploader.util.NetworkPermissionUtil;
19 20
20 import java.io.File; 21 import java.io.File;
21 22
22 /** 23 /**
23 * Android Webview-specific implementations for minidump uploading logic. 24 * Android Webview-specific implementations for minidump uploading logic.
24 */ 25 */
25 public class AwMinidumpUploaderDelegate implements MinidumpUploaderDelegate { 26 public class AwMinidumpUploaderDelegate implements MinidumpUploaderDelegate {
26 private final Context mContext;
27 private final ConnectivityManager mConnectivityManager; 27 private final ConnectivityManager mConnectivityManager;
28 28
29 private boolean mPermittedByUser = false; 29 private boolean mPermittedByUser = false;
30 30
31 @VisibleForTesting 31 @VisibleForTesting
32 public AwMinidumpUploaderDelegate(Context context) { 32 public AwMinidumpUploaderDelegate() {
33 mContext = context;
34 mConnectivityManager = 33 mConnectivityManager =
35 (ConnectivityManager) context.getSystemService(Context.CONNECTIV ITY_SERVICE); 34 (ConnectivityManager) ContextUtils.getApplicationContext().getSy stemService(
35 Context.CONNECTIVITY_SERVICE);
36 } 36 }
37 37
38 @Override 38 @Override
39 public File getCrashParentDir() { 39 public File getCrashParentDir() {
40 return CrashReceiverService.createWebViewCrashDir(mContext); 40 return CrashReceiverService.getOrCreateWebViewCrashDir();
41 } 41 }
42 42
43 @Override 43 @Override
44 public CrashReportingPermissionManager createCrashReportingPermissionManager () { 44 public CrashReportingPermissionManager createCrashReportingPermissionManager () {
45 return new CrashReportingPermissionManager() { 45 return new CrashReportingPermissionManager() {
46 @Override 46 @Override
47 public boolean isClientInMetricsSample() { 47 public boolean isClientInMetricsSample() {
48 // We will check whether the client is in the metrics sample bef ore 48 // We will check whether the client is in the metrics sample bef ore
49 // generating a minidump - so if no minidump is generated this c ode will 49 // generating a minidump - so if no minidump is generated this c ode will
50 // never run and we don't need to check whether we are in the sa mple. 50 // never run and we don't need to check whether we are in the sa mple.
(...skipping 18 matching lines...) Expand all
69 // on the main thread, but before the current worker thread star ted - so this thread 69 // on the main thread, but before the current worker thread star ted - so this thread
70 // will have seen the initialization of the CommandLine. 70 // will have seen the initialization of the CommandLine.
71 return CommandLine.getInstance().hasSwitch( 71 return CommandLine.getInstance().hasSwitch(
72 CommandLineUtil.CRASH_UPLOADS_ENABLED_FOR_TESTING_SWITCH ); 72 CommandLineUtil.CRASH_UPLOADS_ENABLED_FOR_TESTING_SWITCH );
73 } 73 }
74 }; 74 };
75 } 75 }
76 76
77 @Override 77 @Override
78 public void prepareToUploadMinidumps(final Runnable startUploads) { 78 public void prepareToUploadMinidumps(final Runnable startUploads) {
79 PlatformServiceBridge.getOrCreateInstance(mContext).queryMetricsSetting( 79 PlatformServiceBridge.getOrCreateInstance().queryMetricsSetting(
80 new ValueCallback<Boolean>() { 80 new ValueCallback<Boolean>() {
81 public void onReceiveValue(Boolean enabled) { 81 public void onReceiveValue(Boolean enabled) {
82 ThreadUtils.assertOnUiThread(); 82 ThreadUtils.assertOnUiThread();
83 mPermittedByUser = enabled; 83 mPermittedByUser = enabled;
84 startUploads.run(); 84 startUploads.run();
85 } 85 }
86 }); 86 });
87 } 87 }
88 88
89 @Override 89 @Override
90 public void recordUploadSuccess(File minidump) {} 90 public void recordUploadSuccess(File minidump) {}
91 91
92 @Override 92 @Override
93 public void recordUploadFailure(File minidump) {} 93 public void recordUploadFailure(File minidump) {}
94 } 94 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698