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

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

Issue 12018024: Implemented Asynchronous Initialization of BluetoothAdapter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Replaced bluetooth_includes_win.h with bluetooth_init_win.h Created 7 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 | Annotate | Revision Log
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 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_WIN_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_WIN_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_WIN_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_WIN_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/threading/thread_checker.h" 12 #include "base/threading/thread_checker.h"
13 #include "device/bluetooth/bluetooth_adapter.h" 13 #include "device/bluetooth/bluetooth_adapter.h"
14 #include "device/bluetooth/bluetooth_task_manager_win.h" 14 #include "device/bluetooth/bluetooth_task_manager_win.h"
15 15
16 namespace device { 16 namespace device {
17 17
18 class BluetoothAdapterFactory; 18 class BluetoothAdapterFactory;
19 class BluetoothAdapterWinTest; 19 class BluetoothAdapterWinTest;
20 class BluetoothDevice; 20 class BluetoothDevice;
21 21
22 class BluetoothAdapterWin : public BluetoothAdapter, 22 class BluetoothAdapterWin : public BluetoothAdapter,
23 public BluetoothTaskManagerWin::Observer { 23 public BluetoothTaskManagerWin::Observer {
24 public: 24 public:
25 typedef base::Callback<void()> InitCallback;
26
25 // BluetoothAdapter override 27 // BluetoothAdapter override
26 virtual void AddObserver(BluetoothAdapter::Observer* observer) OVERRIDE; 28 virtual void AddObserver(BluetoothAdapter::Observer* observer) OVERRIDE;
27 virtual void RemoveObserver(BluetoothAdapter::Observer* observer) OVERRIDE; 29 virtual void RemoveObserver(BluetoothAdapter::Observer* observer) OVERRIDE;
28 virtual bool IsInitialized() const OVERRIDE; 30 virtual bool IsInitialized() const OVERRIDE;
29 virtual bool IsPresent() const OVERRIDE; 31 virtual bool IsPresent() const OVERRIDE;
30 virtual bool IsPowered() const OVERRIDE; 32 virtual bool IsPowered() const OVERRIDE;
31 virtual void SetPowered( 33 virtual void SetPowered(
32 bool powered, 34 bool powered,
33 const base::Closure& callback, 35 const base::Closure& callback,
34 const ErrorCallback& error_callback) OVERRIDE; 36 const ErrorCallback& error_callback) OVERRIDE;
(...skipping 10 matching lines...) Expand all
45 const BluetoothOutOfBandPairingDataCallback& callback, 47 const BluetoothOutOfBandPairingDataCallback& callback,
46 const ErrorCallback& error_callback) OVERRIDE; 48 const ErrorCallback& error_callback) OVERRIDE;
47 49
48 // BluetoothTaskManagerWin::Observer override 50 // BluetoothTaskManagerWin::Observer override
49 virtual void AdapterStateChanged( 51 virtual void AdapterStateChanged(
50 const BluetoothTaskManagerWin::AdapterState& state) OVERRIDE; 52 const BluetoothTaskManagerWin::AdapterState& state) OVERRIDE;
51 53
52 protected: 54 protected:
53 friend class BluetoothAdapterWinTest; 55 friend class BluetoothAdapterWinTest;
54 56
55 BluetoothAdapterWin(); 57 BluetoothAdapterWin(const InitCallback& init_callback);
56 virtual ~BluetoothAdapterWin(); 58 virtual ~BluetoothAdapterWin();
57 59
58 private: 60 private:
59 friend class BluetoothAdapterFactory; 61 friend class BluetoothAdapterFactory;
60 62
61 void TrackDefaultAdapter(); 63 void TrackDefaultAdapter();
62 64
65 InitCallback init_callback_;
66 bool initialized_;
63 bool powered_; 67 bool powered_;
64 68
65 scoped_refptr<BluetoothTaskManagerWin> task_manager_; 69 scoped_refptr<BluetoothTaskManagerWin> task_manager_;
66 70
67 base::ThreadChecker thread_checker_; 71 base::ThreadChecker thread_checker_;
68 72
69 // List of observers interested in event notifications from us. 73 // List of observers interested in event notifications from us.
70 ObserverList<BluetoothAdapter::Observer> observers_; 74 ObserverList<BluetoothAdapter::Observer> observers_;
71 75
72 // NOTE: This should remain the last member so it'll be destroyed and 76 // NOTE: This should remain the last member so it'll be destroyed and
73 // invalidate its weak pointers before any other members are destroyed. 77 // invalidate its weak pointers before any other members are destroyed.
74 base::WeakPtrFactory<BluetoothAdapterWin> weak_ptr_factory_; 78 base::WeakPtrFactory<BluetoothAdapterWin> weak_ptr_factory_;
75 79
76 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterWin); 80 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterWin);
77 }; 81 };
78 82
79 } // namespace device 83 } // namespace device
80 84
81 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_WIN_H_ 85 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698