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_event_router.h" | 5 #include "extensions/browser/api/bluetooth/bluetooth_event_router.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 continue; | 322 continue; |
323 } | 323 } |
324 delete session; | 324 delete session; |
325 } | 325 } |
326 discovery_session_map_.swap(active_session_map); | 326 discovery_session_map_.swap(active_session_map); |
327 } | 327 } |
328 | 328 |
329 DispatchAdapterStateEvent(); | 329 DispatchAdapterStateEvent(); |
330 | 330 |
331 // Release the adapter after dispatching the event. | 331 // Release the adapter after dispatching the event. |
332 if (!discovering) | 332 if (!discovering) { |
333 MaybeReleaseAdapter(); | 333 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 334 FROM_HERE, base::Bind(&BluetoothEventRouter::MaybeReleaseAdapter, |
| 335 weak_ptr_factory_.GetWeakPtr())); |
| 336 } |
334 } | 337 } |
335 | 338 |
336 void BluetoothEventRouter::DeviceAdded(device::BluetoothAdapter* adapter, | 339 void BluetoothEventRouter::DeviceAdded(device::BluetoothAdapter* adapter, |
337 device::BluetoothDevice* device) { | 340 device::BluetoothDevice* device) { |
338 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 341 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
339 if (adapter != adapter_.get()) { | 342 if (adapter != adapter_.get()) { |
340 BLUETOOTH_LOG(DEBUG) << "Ignoring event for adapter " | 343 BLUETOOTH_LOG(DEBUG) << "Ignoring event for adapter " |
341 << adapter->GetAddress(); | 344 << adapter->GetAddress(); |
342 return; | 345 return; |
343 } | 346 } |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 } | 502 } |
500 | 503 |
501 void BluetoothEventRouter::OnExtensionUnloaded( | 504 void BluetoothEventRouter::OnExtensionUnloaded( |
502 content::BrowserContext* browser_context, | 505 content::BrowserContext* browser_context, |
503 const Extension* extension, | 506 const Extension* extension, |
504 UnloadedExtensionInfo::Reason reason) { | 507 UnloadedExtensionInfo::Reason reason) { |
505 CleanUpForExtension(extension->id()); | 508 CleanUpForExtension(extension->id()); |
506 } | 509 } |
507 | 510 |
508 } // namespace extensions | 511 } // namespace extensions |
OLD | NEW |