gecko-dev/dom/bluetooth/bluetooth2/BluetoothReplyRunnable.h
Thomas Zimmermann d55044fb9f Bug 1146355: Import Bluetooth v2 implementation, r=joliu
This patch moves all files from bluetooth2/ into bluetooth/bluetooth2;
except the backend code.

--HG--
rename : dom/bluetooth2/BluetoothAdapter.cpp => dom/bluetooth/bluetooth2/BluetoothAdapter.cpp
rename : dom/bluetooth2/BluetoothAdapter.h => dom/bluetooth/bluetooth2/BluetoothAdapter.h
rename : dom/bluetooth2/BluetoothClassOfDevice.cpp => dom/bluetooth/bluetooth2/BluetoothClassOfDevice.cpp
rename : dom/bluetooth2/BluetoothClassOfDevice.h => dom/bluetooth/bluetooth2/BluetoothClassOfDevice.h
rename : dom/bluetooth2/BluetoothCommon.h => dom/bluetooth/bluetooth2/BluetoothCommon.h
rename : dom/bluetooth2/BluetoothDevice.cpp => dom/bluetooth/bluetooth2/BluetoothDevice.cpp
rename : dom/bluetooth2/BluetoothDevice.h => dom/bluetooth/bluetooth2/BluetoothDevice.h
rename : dom/bluetooth2/BluetoothDiscoveryHandle.cpp => dom/bluetooth/bluetooth2/BluetoothDiscoveryHandle.cpp
rename : dom/bluetooth2/BluetoothDiscoveryHandle.h => dom/bluetooth/bluetooth2/BluetoothDiscoveryHandle.h
rename : dom/bluetooth2/BluetoothGatt.cpp => dom/bluetooth/bluetooth2/BluetoothGatt.cpp
rename : dom/bluetooth2/BluetoothGatt.h => dom/bluetooth/bluetooth2/BluetoothGatt.h
rename : dom/bluetooth2/BluetoothGattCharacteristic.cpp => dom/bluetooth/bluetooth2/BluetoothGattCharacteristic.cpp
rename : dom/bluetooth2/BluetoothGattCharacteristic.h => dom/bluetooth/bluetooth2/BluetoothGattCharacteristic.h
rename : dom/bluetooth2/BluetoothGattDescriptor.cpp => dom/bluetooth/bluetooth2/BluetoothGattDescriptor.cpp
rename : dom/bluetooth2/BluetoothGattDescriptor.h => dom/bluetooth/bluetooth2/BluetoothGattDescriptor.h
rename : dom/bluetooth2/BluetoothGattService.cpp => dom/bluetooth/bluetooth2/BluetoothGattService.cpp
rename : dom/bluetooth2/BluetoothGattService.h => dom/bluetooth/bluetooth2/BluetoothGattService.h
rename : dom/bluetooth2/BluetoothHfpManagerBase.h => dom/bluetooth/bluetooth2/BluetoothHfpManagerBase.h
rename : dom/bluetooth2/BluetoothHidManager.cpp => dom/bluetooth/bluetooth2/BluetoothHidManager.cpp
rename : dom/bluetooth2/BluetoothHidManager.h => dom/bluetooth/bluetooth2/BluetoothHidManager.h
rename : dom/bluetooth2/BluetoothInterface.cpp => dom/bluetooth/bluetooth2/BluetoothInterface.cpp
rename : dom/bluetooth2/BluetoothInterface.h => dom/bluetooth/bluetooth2/BluetoothInterface.h
rename : dom/bluetooth2/BluetoothInterfaceHelpers.h => dom/bluetooth/bluetooth2/BluetoothInterfaceHelpers.h
rename : dom/bluetooth2/BluetoothManager.cpp => dom/bluetooth/bluetooth2/BluetoothManager.cpp
rename : dom/bluetooth2/BluetoothManager.h => dom/bluetooth/bluetooth2/BluetoothManager.h
rename : dom/bluetooth2/BluetoothPairingHandle.cpp => dom/bluetooth/bluetooth2/BluetoothPairingHandle.cpp
rename : dom/bluetooth2/BluetoothPairingHandle.h => dom/bluetooth/bluetooth2/BluetoothPairingHandle.h
rename : dom/bluetooth2/BluetoothPairingListener.cpp => dom/bluetooth/bluetooth2/BluetoothPairingListener.cpp
rename : dom/bluetooth2/BluetoothPairingListener.h => dom/bluetooth/bluetooth2/BluetoothPairingListener.h
rename : dom/bluetooth2/BluetoothProfileController.cpp => dom/bluetooth/bluetooth2/BluetoothProfileController.cpp
rename : dom/bluetooth2/BluetoothProfileController.h => dom/bluetooth/bluetooth2/BluetoothProfileController.h
rename : dom/bluetooth2/BluetoothProfileManagerBase.h => dom/bluetooth/bluetooth2/BluetoothProfileManagerBase.h
rename : dom/bluetooth2/BluetoothReplyRunnable.cpp => dom/bluetooth/bluetooth2/BluetoothReplyRunnable.cpp
rename : dom/bluetooth2/BluetoothReplyRunnable.h => dom/bluetooth/bluetooth2/BluetoothReplyRunnable.h
rename : dom/bluetooth2/BluetoothRilListener.cpp => dom/bluetooth/bluetooth2/BluetoothRilListener.cpp
rename : dom/bluetooth2/BluetoothRilListener.h => dom/bluetooth/bluetooth2/BluetoothRilListener.h
rename : dom/bluetooth2/BluetoothService.cpp => dom/bluetooth/bluetooth2/BluetoothService.cpp
rename : dom/bluetooth2/BluetoothService.h => dom/bluetooth/bluetooth2/BluetoothService.h
rename : dom/bluetooth2/BluetoothSocketObserver.h => dom/bluetooth/bluetooth2/BluetoothSocketObserver.h
rename : dom/bluetooth2/BluetoothUtils.cpp => dom/bluetooth/bluetooth2/BluetoothUtils.cpp
rename : dom/bluetooth2/BluetoothUtils.h => dom/bluetooth/bluetooth2/BluetoothUtils.h
rename : dom/bluetooth2/BluetoothUuid.cpp => dom/bluetooth/bluetooth2/BluetoothUuid.cpp
rename : dom/bluetooth2/BluetoothUuid.h => dom/bluetooth/bluetooth2/BluetoothUuid.h
rename : dom/bluetooth2/ObexBase.cpp => dom/bluetooth/bluetooth2/ObexBase.cpp
rename : dom/bluetooth2/ObexBase.h => dom/bluetooth/bluetooth2/ObexBase.h
rename : dom/bluetooth2/ipc/BluetoothChild.cpp => dom/bluetooth/bluetooth2/ipc/BluetoothChild.cpp
rename : dom/bluetooth2/ipc/BluetoothChild.h => dom/bluetooth/bluetooth2/ipc/BluetoothChild.h
rename : dom/bluetooth2/ipc/BluetoothMessageUtils.h => dom/bluetooth/bluetooth2/ipc/BluetoothMessageUtils.h
rename : dom/bluetooth2/ipc/BluetoothParent.cpp => dom/bluetooth/bluetooth2/ipc/BluetoothParent.cpp
rename : dom/bluetooth2/ipc/BluetoothParent.h => dom/bluetooth/bluetooth2/ipc/BluetoothParent.h
rename : dom/bluetooth2/ipc/BluetoothServiceChildProcess.cpp => dom/bluetooth/bluetooth2/ipc/BluetoothServiceChildProcess.cpp
rename : dom/bluetooth2/ipc/BluetoothServiceChildProcess.h => dom/bluetooth/bluetooth2/ipc/BluetoothServiceChildProcess.h
rename : dom/bluetooth2/ipc/BluetoothTypes.ipdlh => dom/bluetooth/bluetooth2/ipc/BluetoothTypes.ipdlh
rename : dom/bluetooth2/ipc/PBluetooth.ipdl => dom/bluetooth/bluetooth2/ipc/PBluetooth.ipdl
rename : dom/bluetooth2/ipc/PBluetoothRequest.ipdl => dom/bluetooth/bluetooth2/ipc/PBluetoothRequest.ipdl
rename : dom/bluetooth2/tests/marionette/head.js => dom/bluetooth/bluetooth2/tests/marionette/head.js
rename : dom/bluetooth2/tests/marionette/manifest.ini => dom/bluetooth/bluetooth2/tests/marionette/manifest.ini
rename : dom/bluetooth2/tests/marionette/test_dom_BluetoothAdapter_discovery_API2.js => dom/bluetooth/bluetooth2/tests/marionette/test_dom_BluetoothAdapter_discovery_API2.js
rename : dom/bluetooth2/tests/marionette/test_dom_BluetoothAdapter_enable_API2.js => dom/bluetooth/bluetooth2/tests/marionette/test_dom_BluetoothAdapter_enable_API2.js
rename : dom/bluetooth2/tests/marionette/test_dom_BluetoothAdapter_pair_API2.js => dom/bluetooth/bluetooth2/tests/marionette/test_dom_BluetoothAdapter_pair_API2.js
rename : dom/bluetooth2/tests/marionette/test_dom_BluetoothAdapter_setters_API2.js => dom/bluetooth/bluetooth2/tests/marionette/test_dom_BluetoothAdapter_setters_API2.js
rename : dom/bluetooth2/tests/marionette/test_dom_BluetoothDevice_API2.js => dom/bluetooth/bluetooth2/tests/marionette/test_dom_BluetoothDevice_API2.js
rename : dom/bluetooth2/tests/marionette/test_dom_BluetoothManager_API2.js => dom/bluetooth/bluetooth2/tests/marionette/test_dom_BluetoothManager_API2.js
2015-04-09 15:57:40 +02:00

97 lines
2.6 KiB
C++

/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_bluetooth_bluetoothreplyrunnable_h__
#define mozilla_dom_bluetooth_bluetoothreplyrunnable_h__
#include "mozilla/Attributes.h"
#include "BluetoothCommon.h"
#include "nsThreadUtils.h"
#include "js/Value.h"
class nsIDOMDOMRequest;
namespace mozilla {
namespace dom {
class Promise;
}
}
BEGIN_BLUETOOTH_NAMESPACE
class BluetoothReply;
class BluetoothReplyRunnable : public nsRunnable
{
public:
NS_DECL_NSIRUNNABLE
BluetoothReplyRunnable(nsIDOMDOMRequest* aReq,
Promise* aPromise = nullptr,
const nsAString& aName = EmptyString());
void SetReply(BluetoothReply* aReply);
void SetError(const nsAString& aErrorString,
const enum BluetoothStatus aErrorStatus = STATUS_FAIL)
{
mErrorString = aErrorString;
mErrorStatus = aErrorStatus;
}
virtual void ReleaseMembers();
protected:
virtual ~BluetoothReplyRunnable();
virtual bool ParseSuccessfulReply(JS::MutableHandle<JS::Value> aValue) = 0;
// This is an autoptr so we don't have to bring the ipdl include into the
// header. We assume we'll only be running this once and it should die on
// scope out of Run() anyways.
nsAutoPtr<BluetoothReply> mReply;
private:
nsresult FireReplySuccess(JS::Handle<JS::Value> aVal);
nsresult FireErrorString();
/**
* Either mDOMRequest or mPromise is not nullptr to reply applications
* success or error string. One special case is internal IPC that require
* neither mDOMRequest nor mPromise to reply applications.
* E.g., GetAdaptersTask triggered by BluetoothManager
*
* TODO: remove mDOMRequest once all methods adopt Promise.
*/
nsCOMPtr<nsIDOMDOMRequest> mDOMRequest;
nsRefPtr<Promise> mPromise;
BluetoothStatus mErrorStatus;
nsString mErrorString;
nsString mName; // for debugging
};
class BluetoothVoidReplyRunnable : public BluetoothReplyRunnable
{
public:
BluetoothVoidReplyRunnable(nsIDOMDOMRequest* aReq,
Promise* aPromise = nullptr,
const nsAString& aName = EmptyString());
~BluetoothVoidReplyRunnable();
protected:
virtual bool
ParseSuccessfulReply(JS::MutableHandle<JS::Value> aValue) override
{
aValue.setUndefined();
return true;
}
};
END_BLUETOOTH_NAMESPACE
#endif