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