| 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 "device/bluetooth/bluetooth_adapter_win.h" | 5 #include "device/bluetooth/bluetooth_adapter_win.h" |
| 6 | 6 |
| 7 #include <hash_set> | 7 #include <hash_set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/location.h" |
| 11 #include "base/logging.h" | 12 #include "base/logging.h" |
| 12 #include "base/sequenced_task_runner.h" | 13 #include "base/sequenced_task_runner.h" |
| 13 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
| 14 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
| 15 #include "base/thread_task_runner_handle.h" | 16 #include "base/thread_task_runner_handle.h" |
| 16 #include "device/bluetooth/bluetooth_device_win.h" | 17 #include "device/bluetooth/bluetooth_device_win.h" |
| 17 #include "device/bluetooth/bluetooth_socket_thread.h" | 18 #include "device/bluetooth/bluetooth_socket_thread.h" |
| 18 #include "device/bluetooth/bluetooth_socket_win.h" | 19 #include "device/bluetooth/bluetooth_socket_win.h" |
| 19 #include "device/bluetooth/bluetooth_task_manager_win.h" | 20 #include "device/bluetooth/bluetooth_task_manager_win.h" |
| 20 #include "device/bluetooth/bluetooth_uuid.h" | 21 #include "device/bluetooth/bluetooth_uuid.h" |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 if (!device_win->IsEqual(*device_state)) { | 276 if (!device_win->IsEqual(*device_state)) { |
| 276 device_win->Update(*device_state); | 277 device_win->Update(*device_state); |
| 277 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, | 278 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, |
| 278 observers_, | 279 observers_, |
| 279 DeviceChanged(this, device_win)); | 280 DeviceChanged(this, device_win)); |
| 280 } | 281 } |
| 281 } | 282 } |
| 282 } | 283 } |
| 283 } | 284 } |
| 284 | 285 |
| 286 void BluetoothAdapterWin::DeleteOnCorrectThread() const { |
| 287 if (!ui_task_runner_->DeleteSoon(FROM_HERE, this)) |
| 288 delete this; |
| 289 } |
| 290 |
| 285 // If the method is called when |discovery_status_| is DISCOVERY_STOPPING, | 291 // If the method is called when |discovery_status_| is DISCOVERY_STOPPING, |
| 286 // starting again is handled by BluetoothAdapterWin::DiscoveryStopped(). | 292 // starting again is handled by BluetoothAdapterWin::DiscoveryStopped(). |
| 287 void BluetoothAdapterWin::AddDiscoverySession( | 293 void BluetoothAdapterWin::AddDiscoverySession( |
| 288 const base::Closure& callback, | 294 const base::Closure& callback, |
| 289 const ErrorCallback& error_callback) { | 295 const ErrorCallback& error_callback) { |
| 290 if (discovery_status_ == DISCOVERING) { | 296 if (discovery_status_ == DISCOVERING) { |
| 291 num_discovery_listeners_++; | 297 num_discovery_listeners_++; |
| 292 callback.Run(); | 298 callback.Run(); |
| 293 return; | 299 return; |
| 294 } | 300 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 num_discovery_listeners_ -= on_stop_discovery_callbacks_.size(); | 355 num_discovery_listeners_ -= on_stop_discovery_callbacks_.size(); |
| 350 on_stop_discovery_callbacks_.clear(); | 356 on_stop_discovery_callbacks_.clear(); |
| 351 return; | 357 return; |
| 352 } | 358 } |
| 353 | 359 |
| 354 discovery_status_ = DISCOVERY_STOPPING; | 360 discovery_status_ = DISCOVERY_STOPPING; |
| 355 task_manager_->PostStopDiscoveryTask(); | 361 task_manager_->PostStopDiscoveryTask(); |
| 356 } | 362 } |
| 357 | 363 |
| 358 } // namespace device | 364 } // namespace device |
| OLD | NEW |