Gallery.app: Remove the video related code from Gallery.
[chromium-blink-merge.git] / device / bluetooth / bluetooth_device_win.cc
blob47376bcdae0afbfa7d60ac68a797fb448198277e
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
3 // found in the LICENSE file.
5 #include "device/bluetooth/bluetooth_device_win.h"
7 #include <string>
9 #include "base/basictypes.h"
10 #include "base/logging.h"
11 #include "base/memory/scoped_vector.h"
12 #include "base/sequenced_task_runner.h"
13 #include "base/strings/stringprintf.h"
14 #include "device/bluetooth/bluetooth_service_record_win.h"
15 #include "device/bluetooth/bluetooth_socket_thread.h"
16 #include "device/bluetooth/bluetooth_socket_win.h"
17 #include "device/bluetooth/bluetooth_task_manager_win.h"
18 #include "device/bluetooth/bluetooth_uuid.h"
20 namespace {
22 const int kSdpBytesBufferSize = 1024;
24 } // namespace
26 namespace device {
28 BluetoothDeviceWin::BluetoothDeviceWin(
29 const BluetoothTaskManagerWin::DeviceState& state,
30 scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
31 scoped_refptr<BluetoothSocketThread> socket_thread,
32 net::NetLog* net_log,
33 const net::NetLog::Source& net_log_source)
34 : BluetoothDevice(),
35 ui_task_runner_(ui_task_runner),
36 socket_thread_(socket_thread),
37 net_log_(net_log),
38 net_log_source_(net_log_source) {
39 name_ = state.name;
40 address_ = CanonicalizeAddress(state.address);
41 bluetooth_class_ = state.bluetooth_class;
42 visible_ = state.visible;
43 connected_ = state.connected;
44 paired_ = state.authenticated;
46 for (ScopedVector<BluetoothTaskManagerWin::ServiceRecordState>::const_iterator
47 iter = state.service_record_states.begin();
48 iter != state.service_record_states.end();
49 ++iter) {
50 uint8 sdp_bytes_buffer[kSdpBytesBufferSize];
51 std::copy((*iter)->sdp_bytes.begin(),
52 (*iter)->sdp_bytes.end(),
53 sdp_bytes_buffer);
54 BluetoothServiceRecordWin* service_record = new BluetoothServiceRecordWin(
55 (*iter)->name,
56 (*iter)->address,
57 (*iter)->sdp_bytes.size(),
58 sdp_bytes_buffer);
59 service_record_list_.push_back(service_record);
60 uuids_.push_back(service_record->uuid());
64 BluetoothDeviceWin::~BluetoothDeviceWin() {
67 void BluetoothDeviceWin::SetVisible(bool visible) {
68 visible_ = visible;
71 void BluetoothDeviceWin::AddObserver(
72 device::BluetoothDevice::Observer* observer) {
73 DCHECK(observer);
74 observers_.AddObserver(observer);
77 void BluetoothDeviceWin::RemoveObserver(
78 device::BluetoothDevice::Observer* observer) {
79 DCHECK(observer);
80 observers_.RemoveObserver(observer);
84 uint32 BluetoothDeviceWin::GetBluetoothClass() const {
85 return bluetooth_class_;
88 std::string BluetoothDeviceWin::GetDeviceName() const {
89 return name_;
92 std::string BluetoothDeviceWin::GetAddress() const {
93 return address_;
96 BluetoothDevice::VendorIDSource
97 BluetoothDeviceWin::GetVendorIDSource() const {
98 return VENDOR_ID_UNKNOWN;
101 uint16 BluetoothDeviceWin::GetVendorID() const {
102 return 0;
105 uint16 BluetoothDeviceWin::GetProductID() const {
106 return 0;
109 uint16 BluetoothDeviceWin::GetDeviceID() const {
110 return 0;
113 int BluetoothDeviceWin::GetRSSI() const {
114 NOTIMPLEMENTED();
115 return kUnknownPower;
118 int BluetoothDeviceWin::GetCurrentHostTransmitPower() const {
119 NOTIMPLEMENTED();
120 return kUnknownPower;
123 int BluetoothDeviceWin::GetMaximumHostTransmitPower() const {
124 NOTIMPLEMENTED();
125 return kUnknownPower;
128 bool BluetoothDeviceWin::IsPaired() const {
129 return paired_;
132 bool BluetoothDeviceWin::IsConnected() const {
133 return connected_;
136 bool BluetoothDeviceWin::IsConnectable() const {
137 return false;
140 bool BluetoothDeviceWin::IsConnecting() const {
141 return false;
144 BluetoothDevice::UUIDList BluetoothDeviceWin::GetUUIDs() const {
145 return uuids_;
148 bool BluetoothDeviceWin::ExpectingPinCode() const {
149 NOTIMPLEMENTED();
150 return false;
153 bool BluetoothDeviceWin::ExpectingPasskey() const {
154 NOTIMPLEMENTED();
155 return false;
158 bool BluetoothDeviceWin::ExpectingConfirmation() const {
159 NOTIMPLEMENTED();
160 return false;
163 void BluetoothDeviceWin::Connect(
164 PairingDelegate* pairing_delegate,
165 const base::Closure& callback,
166 const ConnectErrorCallback& error_callback) {
167 NOTIMPLEMENTED();
170 void BluetoothDeviceWin::SetPinCode(const std::string& pincode) {
171 NOTIMPLEMENTED();
174 void BluetoothDeviceWin::SetPasskey(uint32 passkey) {
175 NOTIMPLEMENTED();
178 void BluetoothDeviceWin::ConfirmPairing() {
179 NOTIMPLEMENTED();
182 void BluetoothDeviceWin::RejectPairing() {
183 NOTIMPLEMENTED();
186 void BluetoothDeviceWin::CancelPairing() {
187 NOTIMPLEMENTED();
190 void BluetoothDeviceWin::Disconnect(
191 const base::Closure& callback,
192 const ErrorCallback& error_callback) {
193 NOTIMPLEMENTED();
196 void BluetoothDeviceWin::Forget(const ErrorCallback& error_callback) {
197 NOTIMPLEMENTED();
200 void BluetoothDeviceWin::ConnectToService(
201 const BluetoothUUID& uuid,
202 const ConnectToServiceCallback& callback,
203 const ConnectToServiceErrorCallback& error_callback) {
204 scoped_refptr<BluetoothSocketWin> socket(
205 BluetoothSocketWin::CreateBluetoothSocket(
206 ui_task_runner_, socket_thread_, NULL, net::NetLog::Source()));
207 socket->Connect(this, uuid, base::Bind(callback, socket), error_callback);
210 void BluetoothDeviceWin::CreateGattConnection(
211 const GattConnectionCallback& callback,
212 const ConnectErrorCallback& error_callback) {
213 // TODO(armansito): Implement.
214 error_callback.Run(ERROR_UNSUPPORTED_DEVICE);
217 void BluetoothDeviceWin::StartConnectionMonitor(
218 const base::Closure& callback,
219 const ErrorCallback& error_callback) {
220 NOTIMPLEMENTED();
223 const BluetoothServiceRecordWin* BluetoothDeviceWin::GetServiceRecord(
224 const device::BluetoothUUID& uuid) const {
225 for (ServiceRecordList::const_iterator iter = service_record_list_.begin();
226 iter != service_record_list_.end();
227 ++iter) {
228 if ((*iter)->uuid() == uuid)
229 return *iter;
231 return NULL;
234 } // namespace device