dom/bluetooth/BluetoothPropertyContainer.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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)
    22 {
    23   nsCOMPtr<nsIDOMRequestService> rs =
    24     do_GetService(DOMREQUEST_SERVICE_CONTRACTID);
    25   if (!rs) {
    26     aRv.Throw(NS_ERROR_FAILURE);
    27     return nullptr;
    28   }
    30   nsRefPtr<mozilla::dom::DOMRequest> request = new DOMRequest(aOwner);
    31   rs->FireSuccess(request, JS::UndefinedHandleValue);
    33   return request.forget();
    34 }
    36 already_AddRefed<mozilla::dom::DOMRequest>
    37 BluetoothPropertyContainer::SetProperty(nsPIDOMWindow* aOwner,
    38                                         const BluetoothNamedValue& aProperty,
    39                                         ErrorResult& aRv)
    40 {
    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;
    50   }
    52   nsresult rv = bs->SetProperty(mObjectType, aProperty, task);
    53   if (NS_FAILED(rv)) {
    54     aRv.Throw(rv);
    55     return nullptr;
    56   }
    58   return request.forget();
    59 }

mercurial