Bumping manifests a=b2g-bump
[gecko.git] / dom / bluetooth / BluetoothPropertyContainer.cpp
blob75d856cdbf53ccfce52bfe116b2730dcf4d5143e
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"
15 #include "js/Value.h"
17 USING_BLUETOOTH_NAMESPACE
19 already_AddRefed<mozilla::dom::DOMRequest>
20 BluetoothPropertyContainer::FirePropertyAlreadySet(nsPIDOMWindow* aOwner,
21 ErrorResult& aRv)
23 nsCOMPtr<nsIDOMRequestService> rs =
24 do_GetService(DOMREQUEST_SERVICE_CONTRACTID);
25 if (!rs) {
26 aRv.Throw(NS_ERROR_FAILURE);
27 return nullptr;
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,
39 ErrorResult& aRv)
41 nsRefPtr<mozilla::dom::DOMRequest> request = new DOMRequest(aOwner);
42 nsRefPtr<BluetoothReplyRunnable> task =
43 new BluetoothVoidReplyRunnable(request);
45 BluetoothService* bs = BluetoothService::Get();
46 if (!bs) {
47 BT_WARNING("Bluetooth service not available!");
48 aRv.Throw(NS_ERROR_FAILURE);
49 return nullptr;
52 nsresult rv = bs->SetProperty(mObjectType, aProperty, task);
53 if (NS_FAILED(rv)) {
54 aRv.Throw(rv);
55 return nullptr;
58 return request.forget();