Commit c39517b0 authored by mgiuca's avatar mgiuca Committed by Commit bot

Add detailed histograms for navigator.share.

WebShare.ApiCount is needed (in addition to the existing use counter) to
get the total number of calls to the API, not de-duplicated per page
view.

BUG=636288

Review-Url: https://codereview.chromium.org/2228403002
Cr-Commit-Position: refs/heads/master@{#418760}
parent 39074032
......@@ -8,6 +8,7 @@ import android.app.Activity;
import android.content.ComponentName;
import android.support.annotation.Nullable;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.chrome.browser.share.ShareHelper;
import org.chromium.content.browser.ContentViewCore;
import org.chromium.content_public.browser.WebContents;
......@@ -23,6 +24,20 @@ import org.chromium.ui.base.WindowAndroid;
public class ShareServiceImpl implements ShareService {
private final Activity mActivity;
// These numbers are written to histograms. Keep in sync with WebShareMethod enum in
// histograms.xml, and don't reuse or renumber entries (except for the _COUNT entry).
private static final int WEBSHARE_METHOD_SHARE = 0;
// Count is technically 1, but recordEnumeratedHistogram requires a boundary of at least 2
// (https://crbug.com/645032).
private static final int WEBSHARE_METHOD_COUNT = 2;
// These numbers are written to histograms. Keep in sync with WebShareOutcome enum in
// histograms.xml, and don't reuse or renumber entries (except for the _COUNT entry).
private static final int WEBSHARE_OUTCOME_SUCCESS = 0;
private static final int WEBSHARE_OUTCOME_UNKNOWN_FAILURE = 1;
private static final int WEBSHARE_OUTCOME_CANCELED = 2;
private static final int WEBSHARE_OUTCOME_COUNT = 3;
public ShareServiceImpl(@Nullable WebContents webContents) {
mActivity = activityFromWebContents(webContents);
}
......@@ -35,17 +50,26 @@ public class ShareServiceImpl implements ShareService {
@Override
public void share(String title, String text, Url url, final ShareResponse callback) {
RecordHistogram.recordEnumeratedHistogram("WebShare.ApiCount", WEBSHARE_METHOD_SHARE,
WEBSHARE_METHOD_COUNT);
if (mActivity == null) {
RecordHistogram.recordEnumeratedHistogram("WebShare.ShareOutcome",
WEBSHARE_OUTCOME_UNKNOWN_FAILURE, WEBSHARE_OUTCOME_COUNT);
callback.call("Share failed");
return;
}
ShareHelper.TargetChosenCallback innerCallback = new ShareHelper.TargetChosenCallback() {
public void onTargetChosen(ComponentName chosenComponent) {
RecordHistogram.recordEnumeratedHistogram("WebShare.ShareOutcome",
WEBSHARE_OUTCOME_SUCCESS, WEBSHARE_OUTCOME_COUNT);
callback.call(null);
}
public void onCancel() {
RecordHistogram.recordEnumeratedHistogram("WebShare.ShareOutcome",
WEBSHARE_OUTCOME_CANCELED, WEBSHARE_OUTCOME_COUNT);
callback.call("Share canceled");
}
};
......
......@@ -68988,6 +68988,28 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
<summary>Time for capturing one frame in window capturing.</summary>
</histogram>
<histogram name="WebShare.ApiCount" enum="WebShareMethod">
<owner>mgiuca@chromium.org</owner>
<summary>
Counts the number of calls to navigator.share. Includes both successful and
failed shares.
</summary>
</histogram>
<histogram name="WebShare.ShareOutcome" enum="WebShareOutcome">
<owner>mgiuca@chromium.org</owner>
<summary>
Records the outcome of calls to navigator.share. This will not count any
calls that never complete (e.g., if the page closes while the picker is
open). Therefore, DO NOT look at the raw percentages of this histogram;
instead, compare these numbers with the WebShare.ApiCount.Share total.
NOTE: At the moment, if the user cancels the picker, its recording will be
delayed, and possibly never recorded (https://crbug.com/636274), so that
will account for a discrepancy between ShareOutcome and ApiCount.Share.
</summary>
</histogram>
<histogram name="WebsiteSettings.Action" enum="WebsiteSettingsAction">
<owner>lgarron@chromium.org</owner>
<summary>
......@@ -98915,6 +98937,16 @@ To add a new entry, add it with any value and run test to compute valid value.
<int value="3" label="H264"/>
</enum>
<enum name="WebShareMethod" type="int">
<int value="0" label="Share"/>
</enum>
<enum name="WebShareOutcome" type="int">
<int value="0" label="Success"/>
<int value="1" label="UnknownFailure"/>
<int value="2" label="Canceled"/>
</enum>
<enum name="WebsiteSettingsAction" type="int">
<int value="0" label="Opened"/>
<int value="1" label="Selected Permissions tab"/>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment