2012-07-18 07:41:54 +04:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
|
2012-08-21 07:21:24 +04:00
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
2012-07-18 07:41:54 +04:00
|
|
|
/* 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__
|
|
|
|
|
2013-06-05 20:15:48 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2012-07-18 07:41:54 +04:00
|
|
|
#include "BluetoothCommon.h"
|
|
|
|
#include "nsThreadUtils.h"
|
2013-08-20 10:43:47 +04:00
|
|
|
#include "js/Value.h"
|
2012-07-18 07:41:54 +04:00
|
|
|
|
2012-08-25 20:33:51 +04:00
|
|
|
class nsIDOMDOMRequest;
|
|
|
|
|
2012-07-18 07:41:54 +04:00
|
|
|
BEGIN_BLUETOOTH_NAMESPACE
|
|
|
|
|
|
|
|
class BluetoothReply;
|
|
|
|
|
|
|
|
class BluetoothReplyRunnable : public nsRunnable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_NSIRUNNABLE
|
|
|
|
|
2012-08-25 20:33:51 +04:00
|
|
|
BluetoothReplyRunnable(nsIDOMDOMRequest* aReq);
|
2012-07-18 07:41:54 +04:00
|
|
|
|
2012-08-25 20:33:51 +04:00
|
|
|
void SetReply(BluetoothReply* aReply);
|
2012-07-18 07:41:54 +04:00
|
|
|
|
|
|
|
void SetError(const nsAString& aError)
|
|
|
|
{
|
|
|
|
mErrorString = aError;
|
|
|
|
}
|
|
|
|
|
2012-08-25 20:33:51 +04:00
|
|
|
virtual void ReleaseMembers();
|
2012-07-18 07:41:54 +04:00
|
|
|
|
|
|
|
protected:
|
2012-08-25 20:33:51 +04:00
|
|
|
virtual ~BluetoothReplyRunnable();
|
|
|
|
|
2013-10-16 21:44:50 +04:00
|
|
|
virtual bool ParseSuccessfulReply(JS::MutableHandle<JS::Value> aValue) = 0;
|
2012-07-18 07:41:54 +04:00
|
|
|
|
|
|
|
// 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:
|
2013-10-16 21:44:50 +04:00
|
|
|
nsresult FireReply(JS::Handle<JS::Value> aVal);
|
2012-07-18 07:41:54 +04:00
|
|
|
nsresult FireErrorString();
|
2012-08-25 20:33:51 +04:00
|
|
|
|
2012-07-18 07:41:54 +04:00
|
|
|
nsCOMPtr<nsIDOMDOMRequest> mDOMRequest;
|
|
|
|
nsString mErrorString;
|
|
|
|
};
|
|
|
|
|
|
|
|
class BluetoothVoidReplyRunnable : public BluetoothReplyRunnable
|
|
|
|
{
|
|
|
|
public:
|
2012-08-25 20:33:51 +04:00
|
|
|
BluetoothVoidReplyRunnable(nsIDOMDOMRequest* aReq);
|
|
|
|
~BluetoothVoidReplyRunnable();
|
2012-07-18 07:41:54 +04:00
|
|
|
|
|
|
|
protected:
|
2013-10-16 21:44:50 +04:00
|
|
|
virtual bool ParseSuccessfulReply(JS::MutableHandle<JS::Value> aValue) MOZ_OVERRIDE
|
2012-07-18 07:41:54 +04:00
|
|
|
{
|
2013-10-16 21:44:50 +04:00
|
|
|
aValue.setUndefined();
|
2012-07-18 07:41:54 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
END_BLUETOOTH_NAMESPACE
|
|
|
|
|
|
|
|
#endif
|