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.android_webview.command_line.CommandLineUtil; |
9 import org.chromium.base.Log; | 10 import org.chromium.base.Log; |
10 import org.chromium.base.VisibleForTesting; | 11 import org.chromium.base.VisibleForTesting; |
11 import org.chromium.components.minidump_uploader.CrashFileManager; | 12 import org.chromium.components.minidump_uploader.CrashFileManager; |
12 import org.chromium.components.minidump_uploader.MinidumpUploadCallable; | 13 import org.chromium.components.minidump_uploader.MinidumpUploadCallable; |
13 import org.chromium.components.minidump_uploader.util.CrashReportingPermissionMa
nager; | 14 import org.chromium.components.minidump_uploader.util.CrashReportingPermissionMa
nager; |
14 | 15 |
15 import java.io.File; | 16 import java.io.File; |
16 | 17 |
17 /** | 18 /** |
18 * Class in charge of uploading Minidumps from WebView's data directory. | 19 * Class in charge of uploading Minidumps from WebView's data directory. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 /** | 99 /** |
99 * This method is already represented by isClientInMetricsSample() a
nd | 100 * This method is already represented by isClientInMetricsSample() a
nd |
100 * isNetworkAvailableForCrashUploads(). | 101 * isNetworkAvailableForCrashUploads(). |
101 */ | 102 */ |
102 @Override | 103 @Override |
103 public boolean isMetricsUploadPermitted() { | 104 public boolean isMetricsUploadPermitted() { |
104 return true; | 105 return true; |
105 } | 106 } |
106 @Override | 107 @Override |
107 public boolean isUsageAndCrashReportingPermittedByUser() { | 108 public boolean isUsageAndCrashReportingPermittedByUser() { |
108 // TODO(gsennton): make this depend on Android Checkbox when we
can read that | 109 // We ensure we have user permission before starting to upload m
inidumps - so always |
109 // through GmsCore. | 110 // return true here. |
110 return false; | 111 return true; |
111 } | 112 } |
112 @Override | 113 @Override |
113 public boolean isUploadEnabledForTests() { | 114 public boolean isUploadEnabledForTests() { |
114 return SynchronizedWebViewCommandLine.hasSwitch( | 115 return SynchronizedWebViewCommandLine.getInstance().hasSwitch( |
115 CrashReceiverService.CRASH_UPLOADS_ENABLED_FOR_TESTING_S
WITCH); | 116 CommandLineUtil.CRASH_UPLOADS_ENABLED_FOR_TESTING_SWITCH
); |
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 |