Thu, 15 Jan 2015 15:55:04 +0100
Back out 97036ab72558 which inappropriately compared turds to third parties.
michael@0 | 1 | /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ |
michael@0 | 2 | /* vim: set ts=2 et sw=2 tw=80: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 5 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef mozilla_dom_bluetooth_bluetoothreplyrunnable_h__ |
michael@0 | 8 | #define mozilla_dom_bluetooth_bluetoothreplyrunnable_h__ |
michael@0 | 9 | |
michael@0 | 10 | #include "mozilla/Attributes.h" |
michael@0 | 11 | #include "BluetoothCommon.h" |
michael@0 | 12 | #include "nsThreadUtils.h" |
michael@0 | 13 | #include "js/Value.h" |
michael@0 | 14 | |
michael@0 | 15 | class nsIDOMDOMRequest; |
michael@0 | 16 | |
michael@0 | 17 | BEGIN_BLUETOOTH_NAMESPACE |
michael@0 | 18 | |
michael@0 | 19 | class BluetoothReply; |
michael@0 | 20 | |
michael@0 | 21 | class BluetoothReplyRunnable : public nsRunnable |
michael@0 | 22 | { |
michael@0 | 23 | public: |
michael@0 | 24 | NS_DECL_NSIRUNNABLE |
michael@0 | 25 | |
michael@0 | 26 | BluetoothReplyRunnable(nsIDOMDOMRequest* aReq); |
michael@0 | 27 | |
michael@0 | 28 | void SetReply(BluetoothReply* aReply); |
michael@0 | 29 | |
michael@0 | 30 | void SetError(const nsAString& aError) |
michael@0 | 31 | { |
michael@0 | 32 | mErrorString = aError; |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | virtual void ReleaseMembers(); |
michael@0 | 36 | |
michael@0 | 37 | protected: |
michael@0 | 38 | virtual ~BluetoothReplyRunnable(); |
michael@0 | 39 | |
michael@0 | 40 | virtual bool ParseSuccessfulReply(JS::MutableHandle<JS::Value> aValue) = 0; |
michael@0 | 41 | |
michael@0 | 42 | // This is an autoptr so we don't have to bring the ipdl include into the |
michael@0 | 43 | // header. We assume we'll only be running this once and it should die on |
michael@0 | 44 | // scope out of Run() anyways. |
michael@0 | 45 | nsAutoPtr<BluetoothReply> mReply; |
michael@0 | 46 | |
michael@0 | 47 | private: |
michael@0 | 48 | nsresult FireReply(JS::Handle<JS::Value> aVal); |
michael@0 | 49 | nsresult FireErrorString(); |
michael@0 | 50 | |
michael@0 | 51 | nsCOMPtr<nsIDOMDOMRequest> mDOMRequest; |
michael@0 | 52 | nsString mErrorString; |
michael@0 | 53 | }; |
michael@0 | 54 | |
michael@0 | 55 | class BluetoothVoidReplyRunnable : public BluetoothReplyRunnable |
michael@0 | 56 | { |
michael@0 | 57 | public: |
michael@0 | 58 | BluetoothVoidReplyRunnable(nsIDOMDOMRequest* aReq); |
michael@0 | 59 | ~BluetoothVoidReplyRunnable(); |
michael@0 | 60 | |
michael@0 | 61 | protected: |
michael@0 | 62 | virtual bool ParseSuccessfulReply(JS::MutableHandle<JS::Value> aValue) MOZ_OVERRIDE |
michael@0 | 63 | { |
michael@0 | 64 | aValue.setUndefined(); |
michael@0 | 65 | return true; |
michael@0 | 66 | } |
michael@0 | 67 | }; |
michael@0 | 68 | |
michael@0 | 69 | END_BLUETOOTH_NAMESPACE |
michael@0 | 70 | |
michael@0 | 71 | #endif |