| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "extensions/browser/api/bluetooth/bluetooth_api.h" | 5 #include "extensions/browser/api/bluetooth/bluetooth_api.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/profiler/scoped_profile.h" | |
| 13 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 14 #include "device/bluetooth/bluetooth_adapter.h" | 13 #include "device/bluetooth/bluetooth_adapter.h" |
| 15 #include "device/bluetooth/bluetooth_device.h" | 14 #include "device/bluetooth/bluetooth_device.h" |
| 16 #include "extensions/browser/api/bluetooth/bluetooth_api_utils.h" | 15 #include "extensions/browser/api/bluetooth/bluetooth_api_utils.h" |
| 17 #include "extensions/browser/api/bluetooth/bluetooth_event_router.h" | 16 #include "extensions/browser/api/bluetooth/bluetooth_event_router.h" |
| 18 #include "extensions/browser/event_router.h" | 17 #include "extensions/browser/event_router.h" |
| 19 #include "extensions/common/api/bluetooth.h" | 18 #include "extensions/common/api/bluetooth.h" |
| 20 | 19 |
| 21 using content::BrowserContext; | 20 using content::BrowserContext; |
| 22 using content::BrowserThread; | 21 using content::BrowserThread; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 } | 78 } |
| 80 return event_router_.get(); | 79 return event_router_.get(); |
| 81 } | 80 } |
| 82 | 81 |
| 83 void BluetoothAPI::Shutdown() { | 82 void BluetoothAPI::Shutdown() { |
| 84 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 83 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 85 EventRouter::Get(browser_context_)->UnregisterObserver(this); | 84 EventRouter::Get(browser_context_)->UnregisterObserver(this); |
| 86 } | 85 } |
| 87 | 86 |
| 88 void BluetoothAPI::OnListenerAdded(const EventListenerInfo& details) { | 87 void BluetoothAPI::OnListenerAdded(const EventListenerInfo& details) { |
| 89 // TODO(vadimt): Remove ScopedProfile below once crbug.com/417106 is fixed. | |
| 90 tracked_objects::ScopedProfile tracking_profile( | |
| 91 FROM_HERE_WITH_EXPLICIT_FUNCTION("BluetoothAPI::OnListenerAdded")); | |
| 92 | |
| 93 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 88 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 94 if (event_router()->IsBluetoothSupported()) | 89 if (event_router()->IsBluetoothSupported()) |
| 95 event_router()->OnListenerAdded(); | 90 event_router()->OnListenerAdded(); |
| 96 } | 91 } |
| 97 | 92 |
| 98 void BluetoothAPI::OnListenerRemoved(const EventListenerInfo& details) { | 93 void BluetoothAPI::OnListenerRemoved(const EventListenerInfo& details) { |
| 99 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 94 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 100 if (event_router()->IsBluetoothSupported()) | 95 if (event_router()->IsBluetoothSupported()) |
| 101 event_router()->OnListenerRemoved(); | 96 event_router()->OnListenerRemoved(); |
| 102 } | 97 } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 adapter.get(), | 194 adapter.get(), |
| 200 extension_id(), | 195 extension_id(), |
| 201 base::Bind(&BluetoothStopDiscoveryFunction::OnSuccessCallback, this), | 196 base::Bind(&BluetoothStopDiscoveryFunction::OnSuccessCallback, this), |
| 202 base::Bind(&BluetoothStopDiscoveryFunction::OnErrorCallback, this)); | 197 base::Bind(&BluetoothStopDiscoveryFunction::OnErrorCallback, this)); |
| 203 | 198 |
| 204 return true; | 199 return true; |
| 205 } | 200 } |
| 206 | 201 |
| 207 } // namespace core_api | 202 } // namespace core_api |
| 208 } // namespace extensions | 203 } // namespace extensions |
| OLD | NEW |