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

Unified Diff: chrome/browser/signin/easy_unlock_service.cc

Issue 1023823002: Report Bluetooth adapter status to UMA. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: disable BT after start on systems not yet supported Created 5 years, 9 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/browser/signin/easy_unlock_service.cc
diff --git a/chrome/browser/signin/easy_unlock_service.cc b/chrome/browser/signin/easy_unlock_service.cc
index 74b3da4b63ea76d67589f8f73afe9ba837a5e57b..2ab4edb947711990b6f84b503eb6a09838bf4189 100644
--- a/chrome/browser/signin/easy_unlock_service.cc
+++ b/chrome/browser/signin/easy_unlock_service.cc
@@ -44,8 +44,19 @@
#include "components/user_manager/user_manager.h"
#endif
+#if defined(OS_WIN)
+#include "base/win/windows_version.h"
+#endif
+
namespace {
+enum BluetoothType {
+ BT_NO_ADAPTER,
+ BT_NORMAL,
+ BT_LOW_ENERGY_CAPABLE,
+ BT_MAX_TYPE
+};
+
PrefService* GetLocalState() {
return g_browser_process ? g_browser_process->local_state() : NULL;
}
@@ -77,6 +88,8 @@ EasyUnlockService* EasyUnlockService::GetForUser(
#endif
}
+bool EasyUnlockService::bluetooth_adapter_has_been_reported;
+
// static
bool EasyUnlockService::IsSignInEnabled() {
return !base::CommandLine::ForCurrentProcess()->HasSwitch(
@@ -118,6 +131,10 @@ class EasyUnlockService::BluetoothDetector
service_->OnBluetoothAdapterPresentChanged();
}
+ device::BluetoothAdapter* getAdapter() {
+ return adapter_.get();
+ }
+
private:
void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter) {
adapter_ = adapter;
@@ -129,6 +146,17 @@ class EasyUnlockService::BluetoothDetector
// toes in the future then we need to revisit this guard.
if (adapter_->IsDiscoverable())
TurnOffBluetoothDiscoverability();
+
+#if !defined(OS_CHROMEOS)
+ // Bluetooth detection causes serious performance degradations on Mac
+ // and possibly other platforms as well: http://crbug.com/467316
+ // Since this feature is currently only offered for ChromeOS we just
+ // turn it off on other platforms once the inforamtion about the
+ // adapter has been gathered and reported.
+ // TODO(bcwhite,xiyuan): Revisit when non-chromeos platforms are supported.
+ adapter_->RemoveObserver(this);
+ adapter_ = NULL;
+#endif // !defined(OS_CHROMEOS)
}
// apps::AppLifetimeMonitor::Observer:
@@ -661,20 +689,26 @@ void EasyUnlockService::InitializeOnAppManagerReady() {
CHECK(app_manager_.get());
InitializeInternal();
-
-#if defined(OS_CHROMEOS)
- // Only start Bluetooth detection for ChromeOS since the feature is
- // only offered on ChromeOS. Enabling this on non-ChromeOS platforms
- // previously introduced a performance regression: http://crbug.com/404482
- // Make sure not to reintroduce a performance regression if re-enabling on
- // additional platforms.
- // TODO(xiyuan): Revisit when non-chromeos platforms are supported.
bluetooth_detector_->Initialize();
-#endif // defined(OS_CHROMEOS)
}
void EasyUnlockService::OnBluetoothAdapterPresentChanged() {
UpdateAppState();
+
+ if (!bluetooth_adapter_has_been_reported) {
+ bluetooth_adapter_has_been_reported = true;
+ int bttype = BT_NO_ADAPTER;
+ if (bluetooth_detector_->IsPresent()) {
+ bttype = BT_LOW_ENERGY_CAPABLE;
+#if defined(OS_WIN)
+ if (base::win::GetVersion() < base::win::VERSION_WIN8) {
+ bttype = BT_NORMAL;
+ }
+#endif
+ }
+ UMA_HISTOGRAM_ENUMERATION(
+ "EasyUnlock.BluetoothAvailability", bttype, BT_MAX_TYPE);
+ }
}
void EasyUnlockService::SetHardlockStateForUser(

Powered by Google App Engine
This is Rietveld 408576698