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

Unified Diff: Source/modules/bluetooth/BluetoothDevice.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, 7 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 side-by-side diff with in-line comments
Download patch
Index: Source/modules/bluetooth/BluetoothDevice.cpp
diff --git a/Source/modules/bluetooth/BluetoothDevice.cpp b/Source/modules/bluetooth/BluetoothDevice.cpp
index 2d9552a950762b3fef6a4061330d912b48b4d6fb..ae59773cf0558e4759d2fa6bf78e3f0408130739 100644
--- a/Source/modules/bluetooth/BluetoothDevice.cpp
+++ b/Source/modules/bluetooth/BluetoothDevice.cpp
@@ -18,20 +18,14 @@
namespace blink {
-BluetoothDevice::BluetoothDevice(const WebBluetoothDevice& webDevice)
+BluetoothDevice::BluetoothDevice(PassOwnPtr<WebBluetoothDevice> webDevice)
Jeffrey Yasskin 2015/06/03 23:39:22 It does work to take OwnPtr<> here as long as you
: m_webDevice(webDevice)
{
}
-BluetoothDevice* BluetoothDevice::create(const WebBluetoothDevice& webDevice)
-{
- return new BluetoothDevice(webDevice);
-}
-
BluetoothDevice* BluetoothDevice::take(ScriptPromiseResolver*, WebBluetoothDevice* webDeviceRawPointer)
{
- OwnPtr<WebBluetoothDevice> webDevice = adoptPtr(webDeviceRawPointer);
- return BluetoothDevice::create(*webDevice);
+ return new BluetoothDevice(adoptPtr(webDeviceRawPointer));
}
void BluetoothDevice::dispose(WebBluetoothDevice* webDeviceRaw)
@@ -42,12 +36,12 @@ void BluetoothDevice::dispose(WebBluetoothDevice* webDeviceRaw)
unsigned BluetoothDevice::deviceClass(bool& isNull)
{
isNull = false;
- return m_webDevice.deviceClass;
+ return m_webDevice->deviceClass;
}
String BluetoothDevice::vendorIDSource()
{
- switch (m_webDevice.vendorIDSource) {
+ switch (m_webDevice->vendorIDSource) {
case WebBluetoothDevice::VendorIDSource::Unknown: return String();
case WebBluetoothDevice::VendorIDSource::Bluetooth: return "bluetooth";
case WebBluetoothDevice::VendorIDSource::USB: return "usb";
@@ -59,31 +53,31 @@ String BluetoothDevice::vendorIDSource()
unsigned BluetoothDevice::vendorID(bool& isNull)
{
isNull = false;
- return m_webDevice.vendorID;
+ return m_webDevice->vendorID;
}
unsigned BluetoothDevice::productID(bool& isNull)
{
isNull = false;
- return m_webDevice.productID;
+ return m_webDevice->productID;
}
unsigned BluetoothDevice::productVersion(bool& isNull)
{
isNull = false;
- return m_webDevice.productVersion;
+ return m_webDevice->productVersion;
}
bool BluetoothDevice::paired()
{
- return m_webDevice.paired;
+ return m_webDevice->paired;
}
Vector<String> BluetoothDevice::uuids()
{
- Vector<String> uuids(m_webDevice.uuids.size());
- for (size_t i = 0; i < m_webDevice.uuids.size(); ++i)
- uuids[i] = m_webDevice.uuids[i];
+ Vector<String> uuids(m_webDevice->uuids.size());
+ for (size_t i = 0; i < m_webDevice->uuids.size(); ++i)
+ uuids[i] = m_webDevice->uuids[i];
return uuids;
}

Powered by Google App Engine
This is Rietveld 408576698