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

Side by Side Diff: Source/modules/bluetooth/BluetoothGATTRemoteServer.cpp

Issue 1148283009: bluetooth: Remove deep copying of structs by using OwnPtr. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@bluetooth-get-primary-service-implementation
Patch Set: Created 5 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 "config.h" 5 #include "config.h"
6 #include "modules/bluetooth/BluetoothGATTRemoteServer.h" 6 #include "modules/bluetooth/BluetoothGATTRemoteServer.h"
7 7
8 #include "bindings/core/v8/CallbackPromiseAdapter.h" 8 #include "bindings/core/v8/CallbackPromiseAdapter.h"
9 #include "bindings/core/v8/ScriptPromise.h" 9 #include "bindings/core/v8/ScriptPromise.h"
10 #include "bindings/core/v8/ScriptPromiseResolver.h" 10 #include "bindings/core/v8/ScriptPromiseResolver.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 "modules/bluetooth/BluetoothError.h" 13 #include "modules/bluetooth/BluetoothError.h"
14 #include "modules/bluetooth/BluetoothGATTService.h" 14 #include "modules/bluetooth/BluetoothGATTService.h"
15 #include "public/platform/Platform.h" 15 #include "public/platform/Platform.h"
16 #include "public/platform/modules/bluetooth/WebBluetooth.h" 16 #include "public/platform/modules/bluetooth/WebBluetooth.h"
17 #include "wtf/OwnPtr.h" 17 #include "wtf/OwnPtr.h"
18 18
19 namespace blink { 19 namespace blink {
20 20
21 BluetoothGATTRemoteServer::BluetoothGATTRemoteServer(const WebBluetoothGATTRemot eServer& webGATT) 21 BluetoothGATTRemoteServer::BluetoothGATTRemoteServer(PassOwnPtr<WebBluetoothGATT RemoteServer> webGATT)
22 : m_webGATT(webGATT) 22 : m_webGATT(webGATT)
23 { 23 {
24 } 24 }
25 25
26 BluetoothGATTRemoteServer* BluetoothGATTRemoteServer::take(ScriptPromiseResolver *, WebBluetoothGATTRemoteServer* webGATTRawPointer) 26 BluetoothGATTRemoteServer* BluetoothGATTRemoteServer::take(ScriptPromiseResolver *, WebBluetoothGATTRemoteServer* webGATTRawPointer)
27 { 27 {
28 OwnPtr<WebBluetoothGATTRemoteServer> webGATT = adoptPtr(webGATTRawPointer); 28 return new BluetoothGATTRemoteServer(adoptPtr(webGATTRawPointer));
29 return new BluetoothGATTRemoteServer(*webGATT);
30 } 29 }
31 30
32 void BluetoothGATTRemoteServer::dispose(WebBluetoothGATTRemoteServer* webGATTRaw ) 31 void BluetoothGATTRemoteServer::dispose(WebBluetoothGATTRemoteServer* webGATTRaw )
33 { 32 {
34 delete webGATTRaw; 33 delete webGATTRaw;
35 } 34 }
36 35
37 ScriptPromise BluetoothGATTRemoteServer::getPrimaryService(ScriptState* scriptSt ate, String serviceUUID) 36 ScriptPromise BluetoothGATTRemoteServer::getPrimaryService(ScriptState* scriptSt ate, String serviceUUID)
38 { 37 {
39 // TODO(ortuno): BluetoothUUID.getService(serviceUUID) 38 // TODO(ortuno): BluetoothUUID.getService(serviceUUID)
40 // https://crbug.com/491441 39 // https://crbug.com/491441
41 WebBluetooth* webbluetooth = Platform::current()->bluetooth(); 40 WebBluetooth* webbluetooth = Platform::current()->bluetooth();
42 41
43 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState); 42 RefPtrWillBeRawPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver:: create(scriptState);
44 ScriptPromise promise = resolver->promise(); 43 ScriptPromise promise = resolver->promise();
45 webbluetooth->getPrimaryService(m_webGATT.deviceInstanceID, serviceUUID, new CallbackPromiseAdapter<BluetoothGATTService, BluetoothError>(resolver)); 44 webbluetooth->getPrimaryService(m_webGATT->deviceInstanceID, serviceUUID, ne w CallbackPromiseAdapter<BluetoothGATTService, BluetoothError>(resolver));
46 45
47 return promise; 46 return promise;
48 } 47 }
49 48
50 } // namespace blink 49 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698