| 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 7cfe4523f0a4e34f94a5c673e667e67f7bd7728e..da4b694d47d1d91c0468b87c83c0d0ccb3d9d258 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;
|
| }
|
| @@ -118,6 +129,10 @@ class EasyUnlockService::BluetoothDetector
|
| service_->OnBluetoothAdapterPresentChanged();
|
| }
|
|
|
| + device::BluetoothAdapter* getAdapter() {
|
| + return adapter_.get();
|
| + }
|
| +
|
| private:
|
| void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter) {
|
| adapter_ = adapter;
|
| @@ -129,6 +144,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:
|
| @@ -664,20 +690,31 @@ 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();
|
| +
|
| + // Whether we've already passed Bluetooth availability information to UMA.
|
| + // This is static because there may be multiple instances and we want to
|
| + // report this system-level stat only once per run of Chrome.
|
| + static bool bluetooth_adapter_has_been_reported = false;
|
| +
|
| + 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(
|
|
|