OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "modules/bluetooth/BluetoothDevice.h" | 5 #include "modules/bluetooth/BluetoothDevice.h" |
6 | 6 |
7 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
10 #include "core/dom/DOMException.h" | 10 #include "core/dom/DOMException.h" |
11 #include "core/events/Event.h" | 11 #include "core/events/Event.h" |
12 #include "modules/bluetooth/BluetoothError.h" | 12 #include "modules/bluetooth/BluetoothError.h" |
13 #include "modules/bluetooth/BluetoothRemoteGATTServer.h" | 13 #include "modules/bluetooth/BluetoothRemoteGATTServer.h" |
14 #include "modules/bluetooth/BluetoothSupplement.h" | 14 #include "modules/bluetooth/BluetoothSupplement.h" |
15 #include "public/platform/modules/bluetooth/WebBluetooth.h" | 15 #include "public/platform/modules/bluetooth/WebBluetooth.h" |
16 #include <memory> | |
17 | 16 |
18 namespace blink { | 17 namespace blink { |
19 | 18 |
20 BluetoothDevice::BluetoothDevice(ExecutionContext* context, std::unique_ptr<WebB
luetoothDeviceInit> webDevice) | 19 BluetoothDevice::BluetoothDevice(ExecutionContext* context, PassOwnPtr<WebBlueto
othDeviceInit> webDevice) |
21 : ActiveDOMObject(context) | 20 : ActiveDOMObject(context) |
22 , m_webDevice(std::move(webDevice)) | 21 , m_webDevice(std::move(webDevice)) |
23 , m_gatt(BluetoothRemoteGATTServer::create(this)) | 22 , m_gatt(BluetoothRemoteGATTServer::create(this)) |
24 { | 23 { |
25 // See example in Source/platform/heap/ThreadState.h | 24 // See example in Source/platform/heap/ThreadState.h |
26 ThreadState::current()->registerPreFinalizer(this); | 25 ThreadState::current()->registerPreFinalizer(this); |
27 } | 26 } |
28 | 27 |
29 BluetoothDevice* BluetoothDevice::take(ScriptPromiseResolver* resolver, std::uni
que_ptr<WebBluetoothDeviceInit> webDevice) | 28 BluetoothDevice* BluetoothDevice::take(ScriptPromiseResolver* resolver, PassOwnP
tr<WebBluetoothDeviceInit> webDevice) |
30 { | 29 { |
31 ASSERT(webDevice); | 30 ASSERT(webDevice); |
32 BluetoothDevice* device = new BluetoothDevice(resolver->getExecutionContext(
), std::move(webDevice)); | 31 BluetoothDevice* device = new BluetoothDevice(resolver->getExecutionContext(
), std::move(webDevice)); |
33 device->suspendIfNeeded(); | 32 device->suspendIfNeeded(); |
34 return device; | 33 return device; |
35 } | 34 } |
36 | 35 |
37 void BluetoothDevice::dispose() | 36 void BluetoothDevice::dispose() |
38 { | 37 { |
39 disconnectGATTIfConnected(); | 38 disconnectGATTIfConnected(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 80 |
82 Vector<String> BluetoothDevice::uuids() | 81 Vector<String> BluetoothDevice::uuids() |
83 { | 82 { |
84 Vector<String> uuids(m_webDevice->uuids.size()); | 83 Vector<String> uuids(m_webDevice->uuids.size()); |
85 for (size_t i = 0; i < m_webDevice->uuids.size(); ++i) | 84 for (size_t i = 0; i < m_webDevice->uuids.size(); ++i) |
86 uuids[i] = m_webDevice->uuids[i]; | 85 uuids[i] = m_webDevice->uuids[i]; |
87 return uuids; | 86 return uuids; |
88 } | 87 } |
89 | 88 |
90 } // namespace blink | 89 } // namespace blink |
OLD | NEW |