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.feedback; | 5 package org.chromium.chrome.browser.feedback; |
6 | 6 |
7 import android.app.Activity; | 7 import android.app.Activity; |
8 import android.graphics.Bitmap; | 8 import android.graphics.Bitmap; |
9 import android.os.Bundle; | 9 import android.os.Bundle; |
10 import android.os.SystemClock; | 10 import android.os.SystemClock; |
11 import android.text.TextUtils; | 11 import android.text.TextUtils; |
12 | 12 |
13 import org.chromium.base.ThreadUtils; | 13 import org.chromium.base.ThreadUtils; |
14 import org.chromium.base.VisibleForTesting; | 14 import org.chromium.base.VisibleForTesting; |
| 15 import org.chromium.base.metrics.StatisticsRecorderAndroid; |
15 import org.chromium.blimp_public.BlimpClientContext; | 16 import org.chromium.blimp_public.BlimpClientContext; |
16 import org.chromium.chrome.browser.blimp.BlimpClientContextFactory; | 17 import org.chromium.chrome.browser.blimp.BlimpClientContextFactory; |
17 import org.chromium.chrome.browser.net.spdyproxy.DataReductionProxySettings; | 18 import org.chromium.chrome.browser.net.spdyproxy.DataReductionProxySettings; |
18 import org.chromium.chrome.browser.profiles.Profile; | 19 import org.chromium.chrome.browser.profiles.Profile; |
19 import org.chromium.components.variations.VariationsAssociatedData; | 20 import org.chromium.components.variations.VariationsAssociatedData; |
20 | 21 |
21 import java.util.HashMap; | 22 import java.util.HashMap; |
22 import java.util.Map; | 23 import java.util.Map; |
23 | 24 |
24 import javax.annotation.Nullable; | 25 import javax.annotation.Nullable; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 * An optional description for the feedback report. | 66 * An optional description for the feedback report. |
66 */ | 67 */ |
67 private String mDescription; | 68 private String mDescription; |
68 | 69 |
69 /** | 70 /** |
70 * An optional screenshot for the feedback report. | 71 * An optional screenshot for the feedback report. |
71 */ | 72 */ |
72 private Bitmap mScreenshot; | 73 private Bitmap mScreenshot; |
73 | 74 |
74 /** | 75 /** |
| 76 * All the registered histograms as JSON text. |
| 77 */ |
| 78 private String mHistograms; |
| 79 |
| 80 /** |
75 * A flag indicating whether gathering connection data has finished. | 81 * A flag indicating whether gathering connection data has finished. |
76 */ | 82 */ |
77 private boolean mConnectivityTaskFinished; | 83 private boolean mConnectivityTaskFinished; |
78 | 84 |
79 /** | 85 /** |
80 * A flag indicating whether taking a screenshot has finished. | 86 * A flag indicating whether taking a screenshot has finished. |
81 */ | 87 */ |
82 private boolean mScreenshotTaskFinished; | 88 private boolean mScreenshotTaskFinished; |
83 | 89 |
84 /** | 90 /** |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 mCallback = callback; | 127 mCallback = callback; |
122 mCollectionStartTime = SystemClock.elapsedRealtime(); | 128 mCollectionStartTime = SystemClock.elapsedRealtime(); |
123 init(activity); | 129 init(activity); |
124 } | 130 } |
125 | 131 |
126 @VisibleForTesting | 132 @VisibleForTesting |
127 void init(Activity activity) { | 133 void init(Activity activity) { |
128 postTimeoutTask(); | 134 postTimeoutTask(); |
129 mConnectivityTask = ConnectivityTask.create(mProfile, CONNECTIVITY_CHECK
_TIMEOUT_MS, this); | 135 mConnectivityTask = ConnectivityTask.create(mProfile, CONNECTIVITY_CHECK
_TIMEOUT_MS, this); |
130 ScreenshotTask.create(activity, this); | 136 ScreenshotTask.create(activity, this); |
| 137 if (!mProfile.isOffTheRecord()) { |
| 138 mHistograms = StatisticsRecorderAndroid.toJson(); |
| 139 } |
131 } | 140 } |
132 | 141 |
133 /** | 142 /** |
134 * {@link ConnectivityTask.ConnectivityResult} implementation. | 143 * {@link ConnectivityTask.ConnectivityResult} implementation. |
135 */ | 144 */ |
136 @Override | 145 @Override |
137 public void onResult(ConnectivityTask.FeedbackData feedbackData) { | 146 public void onResult(ConnectivityTask.FeedbackData feedbackData) { |
138 ThreadUtils.assertOnUiThread(); | 147 ThreadUtils.assertOnUiThread(); |
139 mConnectivityTaskFinished = true; | 148 mConnectivityTaskFinished = true; |
140 Map<String, String> connectivityMap = feedbackData.toMap(); | 149 Map<String, String> connectivityMap = feedbackData.toMap(); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 /** | 235 /** |
227 * @return the screenshot to use for the feedback report. | 236 * @return the screenshot to use for the feedback report. |
228 */ | 237 */ |
229 @VisibleForTesting | 238 @VisibleForTesting |
230 public Bitmap getScreenshot() { | 239 public Bitmap getScreenshot() { |
231 ThreadUtils.assertOnUiThread(); | 240 ThreadUtils.assertOnUiThread(); |
232 return mScreenshot; | 241 return mScreenshot; |
233 } | 242 } |
234 | 243 |
235 /** | 244 /** |
| 245 * @return All the registered histograms as JSON text. |
| 246 */ |
| 247 public String getHistograms() { |
| 248 return mHistograms; |
| 249 } |
| 250 |
| 251 /** |
236 * @return the collected data as a {@link Bundle}. | 252 * @return the collected data as a {@link Bundle}. |
237 */ | 253 */ |
238 @VisibleForTesting | 254 @VisibleForTesting |
239 public Bundle getBundle() { | 255 public Bundle getBundle() { |
240 ThreadUtils.assertOnUiThread(); | 256 ThreadUtils.assertOnUiThread(); |
241 addUrl(); | 257 addUrl(); |
242 addConnectivityData(); | 258 addConnectivityData(); |
243 addDataReductionProxyData(); | 259 addDataReductionProxyData(); |
244 addVariationsData(); | 260 addVariationsData(); |
245 addBlimpData(); | 261 addBlimpData(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 } | 295 } |
280 | 296 |
281 private Bundle asBundle() { | 297 private Bundle asBundle() { |
282 Bundle bundle = new Bundle(); | 298 Bundle bundle = new Bundle(); |
283 for (Map.Entry<String, String> entry : mData.entrySet()) { | 299 for (Map.Entry<String, String> entry : mData.entrySet()) { |
284 bundle.putString(entry.getKey(), entry.getValue()); | 300 bundle.putString(entry.getKey(), entry.getValue()); |
285 } | 301 } |
286 return bundle; | 302 return bundle; |
287 } | 303 } |
288 } | 304 } |
OLD | NEW |