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

Side by Side Diff: components/pairing/bluetooth_host_pairing_controller.h

Issue 469613002: Add bluetooth host and controller delegates for pairing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROMEOS_PAIRING_BLUETOOTH_HOST_PAIRING_CONTROLLER_H_
6 #define CHROMEOS_PAIRING_BLUETOOTH_HOST_PAIRING_CONTROLLER_H_
7
8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h"
11 #include "base/observer_list.h"
12 #include "components/pairing/host_pairing_controller.h"
13 #include "components/pairing/proto_decoder.h"
14 #include "device/bluetooth/bluetooth_device.h"
15 #include "device/bluetooth/bluetooth_socket.h"
16
17 namespace device {
18 class BluetoothAdapter;
19 }
20
21 namespace net {
22 class IOBuffer;
23 }
24
25 namespace pairing_chromeos {
26
27 class BluetoothHostPairingController
28 : public HostPairingController,
29 public ProtoDecoder::Observer,
30 public device::BluetoothDevice::PairingDelegate {
31 public:
32 typedef HostPairingController::Observer Observer;
33
34 BluetoothHostPairingController();
35 virtual ~BluetoothHostPairingController();
36
37 private:
38 void ChangeStage(Stage new_stage);
39 void SendHostStatus();
40 void AbortWithError(int code, const std::string& message);
41 void Reset();
42
43 void OnGetAdapter(scoped_refptr<device::BluetoothAdapter> adapter);
44 void OnSetName();
45 void OnSetPowered();
46 void OnCreateService(scoped_refptr<device::BluetoothSocket> socket);
47 void OnSetDiscoverable(bool change_stage);
48 void OnAccept(const device::BluetoothDevice* device,
49 scoped_refptr<device::BluetoothSocket> socket);
50 void OnSendComplete(int bytes_sent);
51 void OnReceiveComplete(int bytes, scoped_refptr<net::IOBuffer> io_buffer);
52
53 void OnCreateServiceError(const std::string& message);
54 void OnSetError();
55 void OnAcceptError(const std::string& error_message);
56 void OnSendError(const std::string& error_message);
57 void OnReceiveError(device::BluetoothSocket::ErrorReason reason,
58 const std::string& error_message);
59
60 // HostPairingFlow:
achuithb 2014/08/20 21:52:34 HostPairingController
Zachary Kuznia 2014/08/21 00:42:08 Done.
61 virtual void AddObserver(Observer* observer) OVERRIDE;
62 virtual void RemoveObserver(Observer* observer) OVERRIDE;
63 virtual Stage GetCurrentStage() OVERRIDE;
64 virtual void StartPairing() OVERRIDE;
65 virtual std::string GetDeviceName() OVERRIDE;
66 virtual std::string GetConfirmationCode() OVERRIDE;
67 virtual std::string GetEnrollmentDomain() OVERRIDE;
68
69 // ProtoDecoder::Observer:
70 virtual void OnHostStatusMessage(
71 const pairing_api::HostStatus& message) OVERRIDE;
72 virtual void OnConfigureHostMessage(
73 const pairing_api::ConfigureHost& message) OVERRIDE;
74 virtual void OnPairDevicesMessage(
75 const pairing_api::PairDevices& message) OVERRIDE;
76 virtual void OnCompleteSetupMessage(
77 const pairing_api::CompleteSetup& message) OVERRIDE;
78 virtual void OnErrorMessage(const pairing_api::Error& message) OVERRIDE;
79
80 // device::BluetoothDevice::PairingDelegate:
81 virtual void RequestPinCode(device::BluetoothDevice* device) OVERRIDE;
82 virtual void RequestPasskey(device::BluetoothDevice* device) OVERRIDE;
83 virtual void DisplayPinCode(device::BluetoothDevice* device,
84 const std::string& pincode) OVERRIDE;
85 virtual void DisplayPasskey(device::BluetoothDevice* device,
86 uint32 passkey) OVERRIDE;
87 virtual void KeysEntered(device::BluetoothDevice* device,
88 uint32 entered) OVERRIDE;
89 virtual void ConfirmPasskey(device::BluetoothDevice* device,
90 uint32 passkey) OVERRIDE;
91 virtual void AuthorizePairing(device::BluetoothDevice* device) OVERRIDE;
92
93 base::WeakPtrFactory<BluetoothHostPairingController> ptr_factory_;
achuithb 2014/08/20 21:52:34 Move to the end.
Zachary Kuznia 2014/08/21 00:42:08 Done.
94 ObserverList<Observer> observers_;
achuithb 2014/08/20 21:52:34 second from end
Zachary Kuznia 2014/08/21 00:42:08 Done.
95 Stage current_stage_;
96 std::string device_name_;
97 std::string confirmation_code_;
98 std::string enrollment_domain_;
99
100 scoped_refptr<device::BluetoothAdapter> adapter_;
101 device::BluetoothDevice* device_;
102 scoped_refptr<device::BluetoothSocket> service_socket_;
103 scoped_refptr<device::BluetoothSocket> controller_socket_;
104 scoped_ptr<ProtoDecoder> proto_decoder_;
105
106 DISALLOW_COPY_AND_ASSIGN(BluetoothHostPairingController);
107 };
108
109 } // namespace pairing_chromeos
110
111 #endif // CHROMEOS_PAIRING_BLUETOOTH_HOST_PAIRING_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698