dom/bluetooth/BluetoothReplyRunnable.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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 #ifndef mozilla_dom_bluetooth_bluetoothreplyrunnable_h__
     8 #define mozilla_dom_bluetooth_bluetoothreplyrunnable_h__
    10 #include "mozilla/Attributes.h"
    11 #include "BluetoothCommon.h"
    12 #include "nsThreadUtils.h"
    13 #include "js/Value.h"
    15 class nsIDOMDOMRequest;
    17 BEGIN_BLUETOOTH_NAMESPACE
    19 class BluetoothReply;
    21 class BluetoothReplyRunnable : public nsRunnable
    22 {
    23 public:
    24   NS_DECL_NSIRUNNABLE
    26   BluetoothReplyRunnable(nsIDOMDOMRequest* aReq);
    28   void SetReply(BluetoothReply* aReply);
    30   void SetError(const nsAString& aError)
    31   {
    32     mErrorString = aError;
    33   }
    35   virtual void ReleaseMembers();
    37 protected:
    38   virtual ~BluetoothReplyRunnable();
    40   virtual bool ParseSuccessfulReply(JS::MutableHandle<JS::Value> aValue) = 0;
    42   // This is an autoptr so we don't have to bring the ipdl include into the
    43   // header. We assume we'll only be running this once and it should die on
    44   // scope out of Run() anyways.
    45   nsAutoPtr<BluetoothReply> mReply;
    47 private:
    48   nsresult FireReply(JS::Handle<JS::Value> aVal);
    49   nsresult FireErrorString();
    51   nsCOMPtr<nsIDOMDOMRequest> mDOMRequest;
    52   nsString mErrorString;
    53 };
    55 class BluetoothVoidReplyRunnable : public BluetoothReplyRunnable
    56 {
    57 public:
    58   BluetoothVoidReplyRunnable(nsIDOMDOMRequest* aReq);
    59  ~BluetoothVoidReplyRunnable();
    61 protected:
    62   virtual bool ParseSuccessfulReply(JS::MutableHandle<JS::Value> aValue) MOZ_OVERRIDE
    63   {
    64     aValue.setUndefined();
    65     return true;
    66   }
    67 };
    69 END_BLUETOOTH_NAMESPACE
    71 #endif

mercurial