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 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.net.NetworkInfo; | |
10 import android.webkit.ValueCallback; | 9 import android.webkit.ValueCallback; |
11 | 10 |
12 import org.chromium.android_webview.PlatformServiceBridge; | 11 import org.chromium.android_webview.PlatformServiceBridge; |
13 import org.chromium.android_webview.command_line.CommandLineUtil; | 12 import org.chromium.android_webview.command_line.CommandLineUtil; |
14 import org.chromium.base.CommandLine; | 13 import org.chromium.base.CommandLine; |
15 import org.chromium.base.ThreadUtils; | 14 import org.chromium.base.ThreadUtils; |
16 import org.chromium.base.VisibleForTesting; | 15 import org.chromium.base.VisibleForTesting; |
17 import org.chromium.components.minidump_uploader.MinidumpUploaderDelegate; | 16 import org.chromium.components.minidump_uploader.MinidumpUploaderDelegate; |
17 import org.chromium.components.minidump_uploader.util.CrashReportingNetworkPermi ssionManager; | |
18 import org.chromium.components.minidump_uploader.util.CrashReportingPermissionMa nager; | 18 import org.chromium.components.minidump_uploader.util.CrashReportingPermissionMa nager; |
19 | 19 |
20 import java.io.File; | 20 import java.io.File; |
21 | 21 |
22 /** | 22 /** |
23 * Android Webview-specific implementations for minidump uploading logic. | 23 * Android Webview-specific implementations for minidump uploading logic. |
24 */ | 24 */ |
25 public class AwMinidumpUploaderDelegate implements MinidumpUploaderDelegate { | 25 public class AwMinidumpUploaderDelegate implements MinidumpUploaderDelegate { |
26 private final Context mContext; | 26 private final Context mContext; |
27 private final ConnectivityManager mConnectivityManager; | 27 private final ConnectivityManager mConnectivityManager; |
(...skipping 19 matching lines...) Expand all Loading... | |
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. |
51 // TODO(gsennton): when we switch to using Finch for this value we should use the | 51 // TODO(gsennton): when we switch to using Finch for this value we should use the |
52 // Finch value here as well. | 52 // Finch value here as well. |
53 return true; | 53 return true; |
54 } | 54 } |
55 @Override | 55 @Override |
56 public boolean isNetworkAvailableForCrashUploads() { | 56 public boolean isNetworkAvailableForCrashUploads() { |
57 // JobScheduler will call onStopJob causing our upload to be int errupted when our | 57 // Note that this is the same critierion that the JobScheduler u ses to schedule the |
58 // network requirements no longer hold. | 58 // job. JobScheduler will call onStopJob causing our upload to b e interrupted when |
59 // TODO(isherman): This code should really be shared with Chrome . Chrome currently | 59 // our network requirements no longer hold. |
60 // checks only whether the network is WiFi (or ethernet) vs. cel lular. Most likely, | 60 return CrashReportingNetworkPermissionManager.isNetworkUnmetered ( |
Ilya Sherman
2017/03/17 01:19:02
This class name is a bit unwieldy. WDYT -- any su
| |
61 // Chrome should instead check whether the network is metered, a s is done here. | 61 mConnectivityManager); |
62 NetworkInfo networkInfo = mConnectivityManager.getActiveNetworkI nfo(); | |
63 if (networkInfo == null || !networkInfo.isConnected()) return fa lse; | |
64 return !mConnectivityManager.isActiveNetworkMetered(); | |
65 } | 62 } |
66 @Override | 63 @Override |
67 public boolean isCrashUploadDisabledByCommandLine() { | 64 public boolean isCrashUploadDisabledByCommandLine() { |
68 return false; | 65 return false; |
69 } | 66 } |
70 /** | 67 /** |
71 * This method is already represented by isClientInMetricsSample() a nd | 68 * This method is already represented by isClientInMetricsSample() a nd |
72 * isNetworkAvailableForCrashUploads(). | 69 * isNetworkAvailableForCrashUploads(). |
73 */ | 70 */ |
74 @Override | 71 @Override |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 | 106 |
110 /** | 107 /** |
111 * Utility method to allow us to test the logic of this class by injecting | 108 * Utility method to allow us to test the logic of this class by injecting |
112 * a test-specific PlatformServiceBridge. | 109 * a test-specific PlatformServiceBridge. |
113 */ | 110 */ |
114 @VisibleForTesting | 111 @VisibleForTesting |
115 public PlatformServiceBridge createPlatformServiceBridge() { | 112 public PlatformServiceBridge createPlatformServiceBridge() { |
116 return PlatformServiceBridge.getInstance(mContext); | 113 return PlatformServiceBridge.getInstance(mContext); |
117 } | 114 } |
118 } | 115 } |
OLD | NEW |