Commit 2d924f0d authored by ortuno's avatar ortuno Committed by Commit bot

bluetooth: Fix layering violation in BluetoothChooserController

BluetoothChooserController, which is in chrome/, was including BluetoothMetrics
which is in content/. To avoid this we create a new histogram specifically
for interactions with the chooser.

BUG=641105

Review-Url: https://codereview.chromium.org/2278003003
Cr-Commit-Position: refs/heads/master@{#414758}
parent 2b47da8b
include_rules = [
"+content/browser/bluetooth",
]
......@@ -7,6 +7,7 @@
#include <algorithm>
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/net/referrer.h"
#include "chrome/browser/profiles/profile_manager.h"
......@@ -15,7 +16,6 @@
#include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "content/browser/bluetooth/bluetooth_metrics.h"
#include "ui/base/l10n/l10n_util.h"
#include "url/gurl.h"
......@@ -28,6 +28,10 @@ Browser* GetBrowser() {
return browser_displayer.browser();
}
void RecordInteractionWithChooser(bool has_null_handler) {
UMA_HISTOGRAM_BOOLEAN("Bluetooth.Web.ChooserInteraction", has_null_handler);
}
} // namespace
BluetoothChooserController::BluetoothChooserController(
......@@ -78,6 +82,7 @@ base::string16 BluetoothChooserController::GetOption(size_t index) const {
}
void BluetoothChooserController::RefreshOptions() {
RecordInteractionWithChooser(event_handler_.is_null());
if (event_handler_.is_null())
return;
ClearAllDevices();
......@@ -89,10 +94,8 @@ base::string16 BluetoothChooserController::GetStatus() const {
}
void BluetoothChooserController::Select(size_t index) {
RecordInteractionWithChooser(event_handler_.is_null());
if (event_handler_.is_null()) {
content::RecordRequestDeviceOutcome(
content::UMARequestDeviceOutcome::
BLUETOOTH_CHOOSER_EVENT_HANDLER_INVALID);
return;
}
DCHECK_LT(index, devices_.size());
......@@ -101,6 +104,7 @@ void BluetoothChooserController::Select(size_t index) {
}
void BluetoothChooserController::Cancel() {
RecordInteractionWithChooser(event_handler_.is_null());
if (event_handler_.is_null())
return;
event_handler_.Run(content::BluetoothChooser::Event::CANCELLED,
......@@ -108,6 +112,7 @@ void BluetoothChooserController::Cancel() {
}
void BluetoothChooserController::Close() {
RecordInteractionWithChooser(event_handler_.is_null());
if (event_handler_.is_null())
return;
event_handler_.Run(content::BluetoothChooser::Event::CANCELLED,
......
......@@ -4431,6 +4431,16 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary>
</histogram>
<histogram name="Bluetooth.Web.ChooserInteraction" enum="BooleanInvalid">
<owner>jyasskin@chromium.org</owner>
<owner>ortuno@chromium.org</owner>
<owner>scheib@chromium.org</owner>
<summary>
Counts how many times users interact with a regular chooser vs. an invalid
chooser. (A chooser is invalid when it's event handler becomes null.)
</summary>
</histogram>
<histogram name="Bluetooth.Web.ConnectGATT.Outcome"
enum="WebBluetoothConnectGATTOutcome">
<owner>jyasskin@chromium.org</owner>
......@@ -70316,6 +70326,11 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
<int value="1" label="Foreground"/>
</enum>
<enum name="BooleanInvalid" type="int">
<int value="0" label="Valid"/>
<int value="1" label="Invalid"/>
</enum>
<enum name="BooleanIsLastSharedAppInfoRetrieved" type="int">
<int value="0" label="Not retrieved"/>
<int value="1" label="Retrieved"/>
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