Chromium Code Reviews| 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; | 9 import android.net.NetworkInfo; |
| 10 import android.webkit.ValueCallback; | 10 import android.webkit.ValueCallback; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 private boolean mPermittedByUser = false; | 29 private boolean mPermittedByUser = false; |
| 30 | 30 |
| 31 @VisibleForTesting | 31 @VisibleForTesting |
| 32 public AwMinidumpUploaderDelegate(Context context) { | 32 public AwMinidumpUploaderDelegate(Context context) { |
| 33 mContext = context; | 33 mContext = context; |
| 34 mConnectivityManager = | 34 mConnectivityManager = |
| 35 (ConnectivityManager) context.getSystemService(Context.CONNECTIV ITY_SERVICE); | 35 (ConnectivityManager) context.getSystemService(Context.CONNECTIV ITY_SERVICE); |
| 36 } | 36 } |
| 37 | 37 |
| 38 @Override | 38 @Override |
| 39 public File createCrashDir() { | 39 public File getCrashParentDir() { |
| 40 return CrashReceiverService.createWebViewCrashDir(mContext); | 40 return CrashReceiverService.createWebViewCrashDir(mContext); |
| 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 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 65 } | 65 } |
| 66 @Override | 66 @Override |
| 67 public boolean isCrashUploadDisabledByCommandLine() { | 67 public boolean isCrashUploadDisabledByCommandLine() { |
| 68 return false; | 68 return false; |
| 69 } | 69 } |
| 70 /** | 70 /** |
| 71 * This method is already represented by isClientInMetricsSample() a nd | 71 * This method is already represented by isClientInMetricsSample() a nd |
| 72 * isNetworkAvailableForCrashUploads(). | 72 * isNetworkAvailableForCrashUploads(). |
| 73 */ | 73 */ |
| 74 @Override | 74 @Override |
| 75 public boolean isMetricsUploadPermitted() { | 75 public boolean isMetricsUploadPermitted() { |
|
gsennton
2017/03/14 18:17:28
Why did you add this back?
Ilya Sherman
2017/03/15 02:13:34
Mmm, didn't you ask me to? Maybe I misunderstood
gsennton
2017/03/15 12:57:43
Oh, haha, that's right ;).
(I find navigating code
| |
| 76 return true; | 76 return true; |
| 77 } | 77 } |
| 78 @Override | 78 @Override |
| 79 public boolean isUsageAndCrashReportingPermittedByUser() { | 79 public boolean isUsageAndCrashReportingPermittedByUser() { |
| 80 return mPermittedByUser; | 80 return mPermittedByUser; |
| 81 } | 81 } |
| 82 @Override | 82 @Override |
| 83 public boolean isUploadEnabledForTests() { | 83 public boolean isUploadEnabledForTests() { |
| 84 // Note that CommandLine/CommandLineUtil are not thread safe. Th ey are initialized | 84 // Note that CommandLine/CommandLineUtil are not thread safe. Th ey are initialized |
| 85 // on the main thread, but before the current worker thread star ted - so this thread | 85 // on the main thread, but before the current worker thread star ted - so this thread |
| 86 // will have seen the initialization of the CommandLine. | 86 // will have seen the initialization of the CommandLine. |
| 87 return CommandLine.getInstance().hasSwitch( | 87 return CommandLine.getInstance().hasSwitch( |
| 88 CommandLineUtil.CRASH_UPLOADS_ENABLED_FOR_TESTING_SWITCH ); | 88 CommandLineUtil.CRASH_UPLOADS_ENABLED_FOR_TESTING_SWITCH ); |
| 89 } | 89 } |
| 90 }; | 90 }; |
| 91 } | 91 } |
| 92 | 92 |
| 93 @Override | 93 @Override |
| 94 public void prepareToUploadMinidumps(final Runnable startUploads) { | 94 public void prepareToUploadMinidumps(final Runnable startUploads) { |
| 95 createPlatformServiceBridge().queryMetricsSetting(new ValueCallback<Bool ean>() { | 95 createPlatformServiceBridge().queryMetricsSetting(new ValueCallback<Bool ean>() { |
| 96 public void onReceiveValue(Boolean enabled) { | 96 public void onReceiveValue(Boolean enabled) { |
| 97 ThreadUtils.assertOnUiThread(); | 97 ThreadUtils.assertOnUiThread(); |
| 98 mPermittedByUser = enabled; | 98 mPermittedByUser = enabled; |
| 99 startUploads.run(); | 99 startUploads.run(); |
| 100 } | 100 } |
| 101 }); | 101 }); |
| 102 } | 102 } |
| 103 | 103 |
| 104 @Override | |
| 105 public void recordUploadSuccess(File minidump) {} | |
| 106 | |
| 107 @Override | |
| 108 public void recordUploadFailure(File minidump) {} | |
| 109 | |
| 104 /** | 110 /** |
| 105 * Utility method to allow us to test the logic of this class by injecting | 111 * Utility method to allow us to test the logic of this class by injecting |
| 106 * a test-specific PlatformServiceBridge. | 112 * a test-specific PlatformServiceBridge. |
| 107 */ | 113 */ |
| 108 @VisibleForTesting | 114 @VisibleForTesting |
| 109 public PlatformServiceBridge createPlatformServiceBridge() { | 115 public PlatformServiceBridge createPlatformServiceBridge() { |
| 110 return PlatformServiceBridge.getInstance(mContext); | 116 return PlatformServiceBridge.getInstance(mContext); |
| 111 } | 117 } |
| 112 } | 118 } |
| OLD | NEW |