| 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 | 8 |
| 9 import org.chromium.base.Log; | 9 import org.chromium.base.Log; |
| 10 import org.chromium.base.VisibleForTesting; | 10 import org.chromium.base.VisibleForTesting; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 /** | 98 /** |
| 99 * This method is already represented by isClientInMetricsSample() a
nd | 99 * This method is already represented by isClientInMetricsSample() a
nd |
| 100 * isNetworkAvailableForCrashUploads(). | 100 * isNetworkAvailableForCrashUploads(). |
| 101 */ | 101 */ |
| 102 @Override | 102 @Override |
| 103 public boolean isMetricsUploadPermitted() { | 103 public boolean isMetricsUploadPermitted() { |
| 104 return true; | 104 return true; |
| 105 } | 105 } |
| 106 @Override | 106 @Override |
| 107 public boolean isUsageAndCrashReportingPermittedByUser() { | 107 public boolean isUsageAndCrashReportingPermittedByUser() { |
| 108 // TODO(gsennton): make this depend on Android Checkbox when we
can read that | 108 // We ensure we have user permission before copying minidumps to
the directory used |
| 109 // through GmsCore. | 109 // by this process - so always return true here. |
| 110 return false; | 110 return true; |
| 111 } | 111 } |
| 112 @Override | 112 @Override |
| 113 public boolean isUploadEnabledForTests() { | 113 public boolean isUploadEnabledForTests() { |
| 114 return SynchronizedWebViewCommandLine.hasSwitch( | 114 // We are already checking whether this feature is enabled for m
anual testing before |
| 115 CrashReceiverService.CRASH_UPLOADS_ENABLED_FOR_TESTING_S
WITCH); | 115 // copying minidumps. |
| 116 return false; |
| 116 } | 117 } |
| 117 }; | 118 }; |
| 118 } | 119 } |
| 119 | 120 |
| 120 /** | 121 /** |
| 121 * Runnable that upload minidumps. | 122 * Runnable that upload minidumps. |
| 122 * This is where the actual uploading happens - an upload job consists of po
sting this Runnable | 123 * This is where the actual uploading happens - an upload job consists of po
sting this Runnable |
| 123 * to the worker thread. | 124 * to the worker thread. |
| 124 */ | 125 */ |
| 125 private class UploadRunnable implements Runnable { | 126 private class UploadRunnable implements Runnable { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 159 |
| 159 // Reschedule if there are still minidumps to upload. | 160 // Reschedule if there are still minidumps to upload. |
| 160 boolean reschedule = | 161 boolean reschedule = |
| 161 mFileManager.getAllMinidumpFiles(MAX_UPLOAD_TRIES_ALLOWED).l
ength > 0; | 162 mFileManager.getAllMinidumpFiles(MAX_UPLOAD_TRIES_ALLOWED).l
ength > 0; |
| 162 mUploadsFinishedCallback.uploadsFinished(reschedule); | 163 mUploadsFinishedCallback.uploadsFinished(reschedule); |
| 163 } | 164 } |
| 164 } | 165 } |
| 165 | 166 |
| 166 @Override | 167 @Override |
| 167 public void uploadAllMinidumps( | 168 public void uploadAllMinidumps( |
| 168 MinidumpUploader.UploadsFinishedCallback uploadsFinishedCallback) { | 169 final MinidumpUploader.UploadsFinishedCallback uploadsFinishedCallba
ck) { |
| 169 if (mWorkerThread != null) { | 170 if (mWorkerThread != null) { |
| 170 throw new RuntimeException("Only one upload-job should be active at
a time"); | 171 throw new RuntimeException("Only one upload-job should be active at
a time"); |
| 171 } | 172 } |
| 172 mWorkerThread = new Thread(new UploadRunnable(uploadsFinishedCallback),
"mWorkerThread"); | 173 mWorkerThread = new Thread(new UploadRunnable(uploadsFinishedCallback),
"mWorkerThread"); |
| 173 setCancelUpload(false); | 174 setCancelUpload(false); |
| 174 mWorkerThread.start(); | 175 mWorkerThread.start(); |
| 175 } | 176 } |
| 176 | 177 |
| 177 /** | 178 /** |
| 178 * @return whether to reschedule the uploads. | 179 * @return whether to reschedule the uploads. |
| 179 */ | 180 */ |
| 180 @Override | 181 @Override |
| 181 public boolean cancelUploads() { | 182 public boolean cancelUploads() { |
| 182 setCancelUpload(true); | 183 setCancelUpload(true); |
| 183 | 184 |
| 184 // Reschedule if there are still minidumps to upload. | 185 // Reschedule if there are still minidumps to upload. |
| 185 return mFileManager.getAllMinidumpFiles(MAX_UPLOAD_TRIES_ALLOWED).length
> 0; | 186 return mFileManager.getAllMinidumpFiles(MAX_UPLOAD_TRIES_ALLOWED).length
> 0; |
| 186 } | 187 } |
| 187 } | 188 } |
| OLD | NEW |