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

Side by Side Diff: third_party/WebKit/Source/modules/bluetooth/BluetoothRemoteGATTCharacteristic.cpp

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/BluetoothRemoteGATTCharacteristic.h" 5 #include "modules/bluetooth/BluetoothRemoteGATTCharacteristic.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/DOMDataView.h" 10 #include "core/dom/DOMDataView.h"
11 #include "core/dom/DOMException.h" 11 #include "core/dom/DOMException.h"
12 #include "core/dom/ExceptionCode.h" 12 #include "core/dom/ExceptionCode.h"
13 #include "core/events/Event.h" 13 #include "core/events/Event.h"
14 #include "core/inspector/ConsoleMessage.h" 14 #include "core/inspector/ConsoleMessage.h"
15 #include "modules/bluetooth/BluetoothCharacteristicProperties.h" 15 #include "modules/bluetooth/BluetoothCharacteristicProperties.h"
16 #include "modules/bluetooth/BluetoothError.h" 16 #include "modules/bluetooth/BluetoothError.h"
17 #include "modules/bluetooth/BluetoothSupplement.h" 17 #include "modules/bluetooth/BluetoothSupplement.h"
18 #include "public/platform/modules/bluetooth/WebBluetooth.h" 18 #include "public/platform/modules/bluetooth/WebBluetooth.h"
19 #include <memory>
20 19
21 namespace blink { 20 namespace blink {
22 21
23 namespace { 22 namespace {
24 23
25 DOMDataView* ConvertWebVectorToDataView(const WebVector<uint8_t>& webVector) 24 DOMDataView* ConvertWebVectorToDataView(const WebVector<uint8_t>& webVector)
26 { 25 {
27 static_assert(sizeof(*webVector.data()) == 1, "uint8_t should be a single by te"); 26 static_assert(sizeof(*webVector.data()) == 1, "uint8_t should be a single by te");
28 DOMArrayBuffer* domBuffer = DOMArrayBuffer::create(webVector.data(), webVect or.size()); 27 DOMArrayBuffer* domBuffer = DOMArrayBuffer::create(webVector.data(), webVect or.size());
29 return DOMDataView::create(domBuffer, 0, webVector.size()); 28 return DOMDataView::create(domBuffer, 0, webVector.size());
30 } 29 }
31 30
32 } // anonymous namespace 31 } // anonymous namespace
33 32
34 BluetoothRemoteGATTCharacteristic::BluetoothRemoteGATTCharacteristic(ExecutionCo ntext* context, std::unique_ptr<WebBluetoothRemoteGATTCharacteristicInit> webCha racteristic) 33 BluetoothRemoteGATTCharacteristic::BluetoothRemoteGATTCharacteristic(ExecutionCo ntext* context, PassOwnPtr<WebBluetoothRemoteGATTCharacteristicInit> webCharacte ristic)
35 : ActiveDOMObject(context) 34 : ActiveDOMObject(context)
36 , m_webCharacteristic(std::move(webCharacteristic)) 35 , m_webCharacteristic(std::move(webCharacteristic))
37 , m_stopped(false) 36 , m_stopped(false)
38 { 37 {
39 m_properties = BluetoothCharacteristicProperties::create(m_webCharacteristic ->characteristicProperties); 38 m_properties = BluetoothCharacteristicProperties::create(m_webCharacteristic ->characteristicProperties);
40 // See example in Source/platform/heap/ThreadState.h 39 // See example in Source/platform/heap/ThreadState.h
41 ThreadState::current()->registerPreFinalizer(this); 40 ThreadState::current()->registerPreFinalizer(this);
42 } 41 }
43 42
44 BluetoothRemoteGATTCharacteristic* BluetoothRemoteGATTCharacteristic::take(Scrip tPromiseResolver* resolver, std::unique_ptr<WebBluetoothRemoteGATTCharacteristic Init> webCharacteristic) 43 BluetoothRemoteGATTCharacteristic* BluetoothRemoteGATTCharacteristic::take(Scrip tPromiseResolver* resolver, PassOwnPtr<WebBluetoothRemoteGATTCharacteristicInit> webCharacteristic)
45 { 44 {
46 if (!webCharacteristic) { 45 if (!webCharacteristic) {
47 return nullptr; 46 return nullptr;
48 } 47 }
49 BluetoothRemoteGATTCharacteristic* characteristic = new BluetoothRemoteGATTC haracteristic(resolver->getExecutionContext(), std::move(webCharacteristic)); 48 BluetoothRemoteGATTCharacteristic* characteristic = new BluetoothRemoteGATTC haracteristic(resolver->getExecutionContext(), std::move(webCharacteristic));
50 // See note in ActiveDOMObject about suspendIfNeeded. 49 // See note in ActiveDOMObject about suspendIfNeeded.
51 characteristic->suspendIfNeeded(); 50 characteristic->suspendIfNeeded();
52 return characteristic; 51 return characteristic;
53 } 52 }
54 53
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 241
243 DEFINE_TRACE(BluetoothRemoteGATTCharacteristic) 242 DEFINE_TRACE(BluetoothRemoteGATTCharacteristic)
244 { 243 {
245 visitor->trace(m_properties); 244 visitor->trace(m_properties);
246 visitor->trace(m_value); 245 visitor->trace(m_value);
247 EventTargetWithInlineData::trace(visitor); 246 EventTargetWithInlineData::trace(visitor);
248 ActiveDOMObject::trace(visitor); 247 ActiveDOMObject::trace(visitor);
249 } 248 }
250 249
251 } // namespace blink 250 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698