1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "BluetoothDiscoveryHandle.h"
8 #include "BluetoothService.h"
10 #include "mozilla/dom/bluetooth/BluetoothTypes.h"
11 #include "mozilla/dom/BluetoothDeviceEvent.h"
12 #include "mozilla/dom/BluetoothDiscoveryHandleBinding.h"
13 #include "nsThreadUtils.h"
15 USING_BLUETOOTH_NAMESPACE
17 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(BluetoothDiscoveryHandle
)
18 NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper
)
20 NS_IMPL_ADDREF_INHERITED(BluetoothDiscoveryHandle
, DOMEventTargetHelper
)
21 NS_IMPL_RELEASE_INHERITED(BluetoothDiscoveryHandle
, DOMEventTargetHelper
)
23 BluetoothDiscoveryHandle::BluetoothDiscoveryHandle(nsPIDOMWindow
* aWindow
)
24 : DOMEventTargetHelper(aWindow
)
29 BluetoothDiscoveryHandle::~BluetoothDiscoveryHandle()
34 already_AddRefed
<BluetoothDiscoveryHandle
>
35 BluetoothDiscoveryHandle::Create(nsPIDOMWindow
* aWindow
)
37 MOZ_ASSERT(NS_IsMainThread());
40 nsRefPtr
<BluetoothDiscoveryHandle
> handle
=
41 new BluetoothDiscoveryHandle(aWindow
);
42 return handle
.forget();
46 BluetoothDiscoveryHandle::DispatchDeviceEvent(BluetoothDevice
* aDevice
)
50 BluetoothDeviceEventInit init
;
51 init
.mDevice
= aDevice
;
53 nsRefPtr
<BluetoothDeviceEvent
> event
=
54 BluetoothDeviceEvent::Constructor(this,
55 NS_LITERAL_STRING("devicefound"),
57 DispatchTrustedEvent(event
);
61 BluetoothDiscoveryHandle::WrapObject(JSContext
* aCx
)
63 return BluetoothDiscoveryHandleBinding::Wrap(aCx
, this);