Move top_sites_impl.{cc,h} into history component
[chromium-blink-merge.git] / components / pairing / bluetooth_host_pairing_controller.h
blob20ba506637773c6ac49a1eba6d34b13cf4abd839
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.
5 #ifndef CHROMEOS_PAIRING_BLUETOOTH_HOST_PAIRING_CONTROLLER_H_
6 #define CHROMEOS_PAIRING_BLUETOOTH_HOST_PAIRING_CONTROLLER_H_
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 "base/threading/thread_checker.h"
13 #include "components/pairing/host_pairing_controller.h"
14 #include "components/pairing/proto_decoder.h"
15 #include "device/bluetooth/bluetooth_adapter.h"
16 #include "device/bluetooth/bluetooth_device.h"
17 #include "device/bluetooth/bluetooth_socket.h"
19 namespace device {
20 class BluetoothAdapter;
23 namespace net {
24 class IOBuffer;
27 namespace pairing_chromeos {
29 class BluetoothHostPairingController
30 : public HostPairingController,
31 public ProtoDecoder::Observer,
32 public device::BluetoothAdapter::Observer,
33 public device::BluetoothDevice::PairingDelegate {
34 public:
35 typedef HostPairingController::Observer Observer;
37 BluetoothHostPairingController();
38 ~BluetoothHostPairingController() override;
40 private:
41 void ChangeStage(Stage new_stage);
42 void SendHostStatus();
43 void AbortWithError(int code, const std::string& message);
44 void Reset();
46 void OnGetAdapter(scoped_refptr<device::BluetoothAdapter> adapter);
47 void SetName();
48 void OnSetName();
49 void OnSetPowered();
50 void OnCreateService(scoped_refptr<device::BluetoothSocket> socket);
51 void OnSetDiscoverable(bool change_stage);
52 void OnAccept(const device::BluetoothDevice* device,
53 scoped_refptr<device::BluetoothSocket> socket);
54 void OnSendComplete(int bytes_sent);
55 void OnReceiveComplete(int bytes, scoped_refptr<net::IOBuffer> io_buffer);
57 void OnCreateServiceError(const std::string& message);
58 void OnSetError();
59 void OnAcceptError(const std::string& error_message);
60 void OnSendError(const std::string& error_message);
61 void OnReceiveError(device::BluetoothSocket::ErrorReason reason,
62 const std::string& error_message);
64 // HostPairingController:
65 void AddObserver(Observer* observer) override;
66 void RemoveObserver(Observer* observer) override;
67 Stage GetCurrentStage() override;
68 void StartPairing() override;
69 std::string GetDeviceName() override;
70 std::string GetConfirmationCode() override;
71 std::string GetEnrollmentDomain() override;
72 void OnUpdateStatusChanged(UpdateStatus update_status) override;
73 void OnEnrollmentStatusChanged(EnrollmentStatus enrollment_status) override;
75 // ProtoDecoder::Observer:
76 void OnHostStatusMessage(const pairing_api::HostStatus& message) override;
77 void OnConfigureHostMessage(
78 const pairing_api::ConfigureHost& message) override;
79 void OnPairDevicesMessage(const pairing_api::PairDevices& message) override;
80 void OnCompleteSetupMessage(
81 const pairing_api::CompleteSetup& message) override;
82 void OnErrorMessage(const pairing_api::Error& message) override;
83 void OnAddNetworkMessage(const pairing_api::AddNetwork& message) override;
85 // BluetoothAdapter::Observer:
86 void AdapterPresentChanged(device::BluetoothAdapter* adapter,
87 bool present) override;
89 // device::BluetoothDevice::PairingDelegate:
90 void RequestPinCode(device::BluetoothDevice* device) override;
91 void RequestPasskey(device::BluetoothDevice* device) override;
92 void DisplayPinCode(device::BluetoothDevice* device,
93 const std::string& pincode) override;
94 void DisplayPasskey(device::BluetoothDevice* device, uint32 passkey) override;
95 void KeysEntered(device::BluetoothDevice* device, uint32 entered) override;
96 void ConfirmPasskey(device::BluetoothDevice* device, uint32 passkey) override;
97 void AuthorizePairing(device::BluetoothDevice* device) override;
99 Stage current_stage_;
100 std::string device_name_;
101 std::string confirmation_code_;
102 std::string enrollment_domain_;
103 UpdateStatus update_status_;
104 EnrollmentStatus enrollment_status_;
106 scoped_refptr<device::BluetoothAdapter> adapter_;
107 scoped_refptr<device::BluetoothSocket> service_socket_;
108 scoped_refptr<device::BluetoothSocket> controller_socket_;
109 scoped_ptr<ProtoDecoder> proto_decoder_;
111 base::ThreadChecker thread_checker_;
112 ObserverList<Observer> observers_;
113 base::WeakPtrFactory<BluetoothHostPairingController> ptr_factory_;
115 DISALLOW_COPY_AND_ASSIGN(BluetoothHostPairingController);
118 } // namespace pairing_chromeos
120 #endif // CHROMEOS_PAIRING_BLUETOOTH_HOST_PAIRING_CONTROLLER_H_