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

Side by Side Diff: device/bluetooth/bluetooth_adapter_win.cc

Issue 812673002: bluetooth: BluetoothAdapterDeleter used to control BluetoothAdapter destruction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: rebase Created 5 years, 11 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 unified diff | Download patch
OLDNEW
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
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_->RunsTasksOnCurrentThread() ||
288 !ui_task_runner_->DeleteSoon(FROM_HERE, this))
289 delete this;
290 }
291
285 // If the method is called when |discovery_status_| is DISCOVERY_STOPPING, 292 // If the method is called when |discovery_status_| is DISCOVERY_STOPPING,
286 // starting again is handled by BluetoothAdapterWin::DiscoveryStopped(). 293 // starting again is handled by BluetoothAdapterWin::DiscoveryStopped().
287 void BluetoothAdapterWin::AddDiscoverySession( 294 void BluetoothAdapterWin::AddDiscoverySession(
288 const base::Closure& callback, 295 const base::Closure& callback,
289 const ErrorCallback& error_callback) { 296 const ErrorCallback& error_callback) {
290 if (discovery_status_ == DISCOVERING) { 297 if (discovery_status_ == DISCOVERING) {
291 num_discovery_listeners_++; 298 num_discovery_listeners_++;
292 callback.Run(); 299 callback.Run();
293 return; 300 return;
294 } 301 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 num_discovery_listeners_ -= on_stop_discovery_callbacks_.size(); 356 num_discovery_listeners_ -= on_stop_discovery_callbacks_.size();
350 on_stop_discovery_callbacks_.clear(); 357 on_stop_discovery_callbacks_.clear();
351 return; 358 return;
352 } 359 }
353 360
354 discovery_status_ = DISCOVERY_STOPPING; 361 discovery_status_ = DISCOVERY_STOPPING;
355 task_manager_->PostStopDiscoveryTask(); 362 task_manager_->PostStopDiscoveryTask();
356 } 363 }
357 364
358 } // namespace device 365 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_adapter_win.h ('k') | device/bluetooth/test/mock_bluetooth_adapter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698