OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.chrome.browser.crash; | 5 package org.chromium.chrome.browser.crash; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.content.SharedPreferences; | 8 import android.content.SharedPreferences; |
9 import android.support.annotation.IntDef; | 9 import android.support.annotation.IntDef; |
10 | 10 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 protected static final String PREF_LAST_UPLOAD_DAY = "crash_dump_last_upload _day"; | 45 protected static final String PREF_LAST_UPLOAD_DAY = "crash_dump_last_upload _day"; |
46 protected static final String PREF_LAST_UPLOAD_WEEK = "crash_dump_last_uploa d_week"; | 46 protected static final String PREF_LAST_UPLOAD_WEEK = "crash_dump_last_uploa d_week"; |
47 protected static final String PREF_WEEK_UPLOAD_SIZE = "crash_dump_week_uploa d_size"; | 47 protected static final String PREF_WEEK_UPLOAD_SIZE = "crash_dump_week_uploa d_size"; |
48 | 48 |
49 @VisibleForTesting | 49 @VisibleForTesting |
50 protected static final String CRASH_URL_STRING = "https://clients2.google.co m/cr/report"; | 50 protected static final String CRASH_URL_STRING = "https://clients2.google.co m/cr/report"; |
51 | 51 |
52 @VisibleForTesting | 52 @VisibleForTesting |
53 protected static final String CONTENT_TYPE_TMPL = "multipart/form-data; boun dary=%s"; | 53 protected static final String CONTENT_TYPE_TMPL = "multipart/form-data; boun dary=%s"; |
54 | 54 |
55 @IntDef({ | 55 @IntDef({UPLOAD_SUCCESS, UPLOAD_FAILURE, UPLOAD_USER_DISABLED, UPLOAD_COMMAN DLINE_DISABLED, |
56 UPLOAD_SUCCESS, | 56 UPLOAD_DISABLED_BY_SAMPLING}) |
Ilya Sherman
2016/08/24 05:02:50
Could you please revert the format change here? O
jwd
2016/08/24 15:06:28
Yeah, it's the result of git cl format. I reverted
| |
57 UPLOAD_FAILURE, | |
58 UPLOAD_USER_DISABLED, | |
59 UPLOAD_COMMANDLINE_DISABLED | |
60 }) | |
61 public @interface MinidumpUploadStatus {} | 57 public @interface MinidumpUploadStatus {} |
62 public static final int UPLOAD_SUCCESS = 0; | 58 public static final int UPLOAD_SUCCESS = 0; |
63 public static final int UPLOAD_FAILURE = 1; | 59 public static final int UPLOAD_FAILURE = 1; |
64 public static final int UPLOAD_USER_DISABLED = 2; | 60 public static final int UPLOAD_USER_DISABLED = 2; |
65 public static final int UPLOAD_COMMANDLINE_DISABLED = 3; | 61 public static final int UPLOAD_COMMANDLINE_DISABLED = 3; |
62 public static final int UPLOAD_DISABLED_BY_SAMPLING = 4; | |
66 | 63 |
67 private final File mFileToUpload; | 64 private final File mFileToUpload; |
68 private final File mLogfile; | 65 private final File mLogfile; |
69 private final HttpURLConnectionFactory mHttpURLConnectionFactory; | 66 private final HttpURLConnectionFactory mHttpURLConnectionFactory; |
70 private final CrashReportingPermissionManager mPermManager; | 67 private final CrashReportingPermissionManager mPermManager; |
71 | 68 |
72 public MinidumpUploadCallable(File fileToUpload, File logfile, Context conte xt) { | 69 public MinidumpUploadCallable(File fileToUpload, File logfile, Context conte xt) { |
73 this(fileToUpload, logfile, new HttpURLConnectionFactoryImpl(), | 70 this(fileToUpload, logfile, new HttpURLConnectionFactoryImpl(), |
74 PrivacyPreferencesManager.getInstance()); | 71 PrivacyPreferencesManager.getInstance()); |
75 removeOutdatedPrefs(ContextUtils.getAppSharedPreferences()); | 72 removeOutdatedPrefs(ContextUtils.getAppSharedPreferences()); |
(...skipping 19 matching lines...) Expand all Loading... | |
95 if (mPermManager.isUploadEnabledForTests()) { | 92 if (mPermManager.isUploadEnabledForTests()) { |
96 Log.i(TAG, "Minidump upload enabled for tests, skipping other checks ."); | 93 Log.i(TAG, "Minidump upload enabled for tests, skipping other checks ."); |
97 } else { | 94 } else { |
98 if (!mPermManager.isUploadUserPermitted()) { | 95 if (!mPermManager.isUploadUserPermitted()) { |
99 Log.i(TAG, "Minidump upload is not permitted by user. Marking fi le as uploaded for " | 96 Log.i(TAG, "Minidump upload is not permitted by user. Marking fi le as uploaded for " |
100 + "cleanup to prevent future uploads."); | 97 + "cleanup to prevent future uploads."); |
101 cleanupMinidumpFile(); | 98 cleanupMinidumpFile(); |
102 return UPLOAD_USER_DISABLED; | 99 return UPLOAD_USER_DISABLED; |
103 } | 100 } |
104 | 101 |
102 if (!mPermManager.isClientInMetricsSample()) { | |
103 Log.i(TAG, "Minidump cannot be uploaded due to sampling."); | |
Ilya Sherman
2016/08/24 05:02:50
nit: This is super nitpicky, but I'd log something
jwd
2016/08/24 15:06:28
Done.
| |
104 return UPLOAD_DISABLED_BY_SAMPLING; | |
105 } | |
106 | |
105 boolean isLimited = mPermManager.isUploadLimited(); | 107 boolean isLimited = mPermManager.isUploadLimited(); |
106 if (isLimited || !mPermManager.isUploadPermitted()) { | 108 if (isLimited || !mPermManager.isUploadPermitted()) { |
107 Log.i(TAG, "Minidump cannot currently be uploaded due to constra ints."); | 109 Log.i(TAG, "Minidump cannot currently be uploaded due to constra ints."); |
108 return UPLOAD_FAILURE; | 110 return UPLOAD_FAILURE; |
109 } | 111 } |
110 } | 112 } |
111 | 113 |
112 HttpURLConnection connection = | 114 HttpURLConnection connection = |
113 mHttpURLConnectionFactory.createHttpURLConnection(CRASH_URL_STRI NG); | 115 mHttpURLConnectionFactory.createHttpURLConnection(CRASH_URL_STRI NG); |
114 if (connection == null) { | 116 if (connection == null) { |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
316 // TODO(gayane): Remove this function and unused prefs in M51. crbug.com/555 022 | 318 // TODO(gayane): Remove this function and unused prefs in M51. crbug.com/555 022 |
317 private void removeOutdatedPrefs(SharedPreferences sharedPreferences) { | 319 private void removeOutdatedPrefs(SharedPreferences sharedPreferences) { |
318 SharedPreferences.Editor editor = sharedPreferences.edit(); | 320 SharedPreferences.Editor editor = sharedPreferences.edit(); |
319 editor.remove(PREF_DAY_UPLOAD_COUNT) | 321 editor.remove(PREF_DAY_UPLOAD_COUNT) |
320 .remove(PREF_LAST_UPLOAD_DAY) | 322 .remove(PREF_LAST_UPLOAD_DAY) |
321 .remove(PREF_LAST_UPLOAD_WEEK) | 323 .remove(PREF_LAST_UPLOAD_WEEK) |
322 .remove(PREF_WEEK_UPLOAD_SIZE) | 324 .remove(PREF_WEEK_UPLOAD_SIZE) |
323 .apply(); | 325 .apply(); |
324 } | 326 } |
325 } | 327 } |
OLD | NEW |