1 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
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 file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "base/basictypes.h"
8 #include "BluetoothPropertyContainer.h"
9 #include "BluetoothService.h"
10 #include "DOMRequest.h"
11 #include "mozilla/ErrorResult.h"
12 #include "mozilla/dom/bluetooth/BluetoothTypes.h"
13 #include "nsServiceManagerUtils.h"
17 USING_BLUETOOTH_NAMESPACE
19 already_AddRefed
<mozilla::dom::DOMRequest
>
20 BluetoothPropertyContainer::FirePropertyAlreadySet(nsPIDOMWindow
* aOwner
,
23 nsCOMPtr
<nsIDOMRequestService
> rs
=
24 do_GetService(DOMREQUEST_SERVICE_CONTRACTID
);
26 aRv
.Throw(NS_ERROR_FAILURE
);
30 nsRefPtr
<mozilla::dom::DOMRequest
> request
= new DOMRequest(aOwner
);
31 rs
->FireSuccess(request
, JS::UndefinedHandleValue
);
33 return request
.forget();
36 already_AddRefed
<mozilla::dom::DOMRequest
>
37 BluetoothPropertyContainer::SetProperty(nsPIDOMWindow
* aOwner
,
38 const BluetoothNamedValue
& aProperty
,
41 nsRefPtr
<mozilla::dom::DOMRequest
> request
= new DOMRequest(aOwner
);
42 nsRefPtr
<BluetoothReplyRunnable
> task
=
43 new BluetoothVoidReplyRunnable(request
);
45 BluetoothService
* bs
= BluetoothService::Get();
47 BT_WARNING("Bluetooth service not available!");
48 aRv
.Throw(NS_ERROR_FAILURE
);
52 nsresult rv
= bs
->SetProperty(mObjectType
, aProperty
, task
);
58 return request
.forget();