Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2895)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/feedback/FeedbackCollector.java

Issue 2897323002: VR feedback reports should go directly to the Feedback activity (Closed)
Patch Set: apply nits Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/feedback/FeedbackCollector.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/feedback/FeedbackCollector.java b/chrome/android/java/src/org/chromium/chrome/browser/feedback/FeedbackCollector.java
index fc9296f5f0a592bf02dc84f36ed7eac82bd8ce93..53fc04f378f21660bd88f39fd1911a2cc22cb050 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/feedback/FeedbackCollector.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/feedback/FeedbackCollector.java
@@ -57,6 +57,7 @@ public class FeedbackCollector
private final String mUrl;
private final FeedbackResult mCallback;
private final long mCollectionStartTime;
+ private final boolean mTakeScreenshot;
// Not final because created during init. Should be used as a final member.
protected ConnectivityTask mConnectivityTask;
@@ -92,6 +93,11 @@ public class FeedbackCollector
private boolean mResultPosted;
/**
+ * The CategoryTag for the report. This allows Feedback systems to route the report accordingly.
+ */
+ private String mCategoryTag;
+
+ /**
* A callback for when the gathering of feedback data has finished. This may be called either
* when all data has been collected, or after a timeout.
*/
@@ -113,17 +119,25 @@ public class FeedbackCollector
*/
public static FeedbackCollector create(
Activity activity, Profile profile, @Nullable String url, FeedbackResult callback) {
+ // TODO(ymalik): Remove this constructor once all the references are removed.
+ return create(activity, profile, url, true, callback);
+ }
+
+ public static FeedbackCollector create(Activity activity, Profile profile, @Nullable String url,
+ boolean takeScreenshot, FeedbackResult callback) {
ThreadUtils.assertOnUiThread();
- return new FeedbackCollector(activity, profile, url, callback);
+ return new FeedbackCollector(activity, profile, url, takeScreenshot, callback);
}
@VisibleForTesting
- FeedbackCollector(Activity activity, Profile profile, String url, FeedbackResult callback) {
+ FeedbackCollector(Activity activity, Profile profile, String url, boolean takeScreenshot,
+ FeedbackResult callback) {
mData = new HashMap<>();
mProfile = profile;
mUrl = url;
mCallback = callback;
mCollectionStartTime = SystemClock.elapsedRealtime();
+ mTakeScreenshot = takeScreenshot;
init(activity);
}
@@ -131,7 +145,9 @@ public class FeedbackCollector
void init(Activity activity) {
postTimeoutTask();
mConnectivityTask = ConnectivityTask.create(mProfile, CONNECTIVITY_CHECK_TIMEOUT_MS, this);
- ScreenshotTask.create(activity, this);
+ if (mTakeScreenshot) {
+ ScreenshotTask.create(activity, this);
+ }
if (!mProfile.isOffTheRecord()) {
mHistograms = StatisticsRecorderAndroid.toJson();
}
@@ -169,14 +185,21 @@ public class FeedbackCollector
}, TIMEOUT_MS);
}
+ private boolean shouldWaitForScreenshot() {
+ return mTakeScreenshot && !mScreenshotTaskFinished;
+ }
+
+ private boolean shouldWaitForConnectivityTask() {
+ return !mConnectivityTaskFinished && !hasTimedOut();
+ }
+
@VisibleForTesting
void maybePostResult() {
ThreadUtils.assertOnUiThread();
if (mCallback == null) return;
if (mResultPosted) return;
- // Always wait for screenshot.
- if (!mScreenshotTaskFinished) return;
- if (!mConnectivityTaskFinished && !hasTimedOut()) return;
+ if (shouldWaitForScreenshot() || shouldWaitForConnectivityTask()) return;
+
mResultPosted = true;
ThreadUtils.postOnUiThread(new Runnable() {
@Override
@@ -221,6 +244,23 @@ public class FeedbackCollector
}
/**
+ * Sets the CategoryTag to invoke feedback with.
+ * @param categoryTag the user visible description.
+ */
+ public void setCategoryTag(String categoryTag) {
+ ThreadUtils.assertOnUiThread();
+ mCategoryTag = categoryTag;
+ }
+
+ /**
+ * @return the CategoryTag for the feedback report.
+ */
+ public String getCategoryTag() {
+ ThreadUtils.assertOnUiThread();
+ return mCategoryTag;
+ }
+
+ /**
* Sets the screenshot to use for the feedback report.
* @param screenshot the user visible screenshot.
*/

Powered by Google App Engine
This is Rietveld 408576698