dom/bluetooth/ipc/BluetoothParent.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_ipc_bluetoothparent_h__
     8 #define mozilla_dom_bluetooth_ipc_bluetoothparent_h__
    10 #include "mozilla/dom/bluetooth/BluetoothCommon.h"
    12 #include "mozilla/dom/bluetooth/PBluetoothParent.h"
    13 #include "mozilla/dom/bluetooth/PBluetoothRequestParent.h"
    15 #include "mozilla/Attributes.h"
    16 #include "mozilla/Observer.h"
    17 #include "nsAutoPtr.h"
    18 #include "nsTArray.h"
    19 #include "nsThreadUtils.h"
    21 template <class T>
    22 class nsRevocableEventPtr;
    24 namespace mozilla {
    25 namespace dom {
    27 class ContentParent;
    29 } // namespace dom
    30 } // namespace mozilla
    32 BEGIN_BLUETOOTH_NAMESPACE
    34 class BluetoothService;
    36 /*******************************************************************************
    37  * BluetoothParent
    38  ******************************************************************************/
    40 class BluetoothParent : public PBluetoothParent,
    41                         public mozilla::Observer<BluetoothSignal>
    42 {
    43   friend class mozilla::dom::ContentParent;
    45   enum ShutdownState
    46   {
    47     Running = 0,
    48     SentBeginShutdown,
    49     ReceivedStopNotifying,
    50     SentNotificationsStopped,
    51     Dead
    52   };
    54   nsRefPtr<BluetoothService> mService;
    55   ShutdownState mShutdownState;
    56   bool mReceivedStopNotifying;
    57   bool mSentBeginShutdown;
    59 public:
    60   void
    61   BeginShutdown();
    63 protected:
    64   BluetoothParent();
    65   virtual ~BluetoothParent();
    67   bool
    68   InitWithService(BluetoothService* aService);
    70   virtual void
    71   ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
    73   virtual bool
    74   RecvRegisterSignalHandler(const nsString& aNode) MOZ_OVERRIDE;
    76   virtual bool
    77   RecvUnregisterSignalHandler(const nsString& aNode) MOZ_OVERRIDE;
    79   virtual bool
    80   RecvStopNotifying() MOZ_OVERRIDE;
    82   virtual bool
    83   RecvPBluetoothRequestConstructor(PBluetoothRequestParent* aActor,
    84                                    const Request& aRequest) MOZ_OVERRIDE;
    86   virtual PBluetoothRequestParent*
    87   AllocPBluetoothRequestParent(const Request& aRequest) MOZ_OVERRIDE;
    89   virtual bool
    90   DeallocPBluetoothRequestParent(PBluetoothRequestParent* aActor) MOZ_OVERRIDE;
    92   virtual void
    93   Notify(const BluetoothSignal& aSignal) MOZ_OVERRIDE;
    95 private:
    96   void
    97   UnregisterAllSignalHandlers();
    98 };
   100 /*******************************************************************************
   101  * BluetoothAdapterRequestParent
   102  ******************************************************************************/
   104 class BluetoothRequestParent : public PBluetoothRequestParent
   105 {
   106   class ReplyRunnable;
   107   friend class BluetoothParent;
   109   friend class ReplyRunnable;
   111   nsRefPtr<BluetoothService> mService;
   112   nsRevocableEventPtr<ReplyRunnable> mReplyRunnable;
   114 #ifdef DEBUG
   115   Request::Type mRequestType;
   116 #endif
   118 protected:
   119   BluetoothRequestParent(BluetoothService* aService);
   120   virtual ~BluetoothRequestParent();
   122   virtual void
   123   ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
   125   void
   126   RequestComplete();
   128   bool
   129   DoRequest(const DefaultAdapterPathRequest& aRequest);
   131   bool
   132   DoRequest(const SetPropertyRequest& aRequest);
   134   bool
   135   DoRequest(const GetPropertyRequest& aRequest);
   137   bool
   138   DoRequest(const StartDiscoveryRequest& aRequest);
   140   bool
   141   DoRequest(const StopDiscoveryRequest& aRequest);
   143   bool
   144   DoRequest(const PairRequest& aRequest);
   146   bool
   147   DoRequest(const UnpairRequest& aRequest);
   149   bool
   150   DoRequest(const PairedDevicePropertiesRequest& aRequest);
   151   bool
   152   DoRequest(const ConnectedDevicePropertiesRequest& aRequest);
   154   bool
   155   DoRequest(const SetPinCodeRequest& aRequest);
   157   bool
   158   DoRequest(const SetPasskeyRequest& aRequest);
   160   bool
   161   DoRequest(const ConfirmPairingConfirmationRequest& aRequest);
   163   bool
   164   DoRequest(const DenyPairingConfirmationRequest& aRequest);
   166   bool
   167   DoRequest(const ConnectRequest& aRequest);
   169   bool
   170   DoRequest(const DisconnectRequest& aRequest);
   172   bool
   173   DoRequest(const SendFileRequest& aRequest);
   175   bool
   176   DoRequest(const StopSendingFileRequest& aRequest);
   178   bool
   179   DoRequest(const ConfirmReceivingFileRequest& aRequest);
   181   bool
   182   DoRequest(const DenyReceivingFileRequest& aRequest);
   184   bool
   185   DoRequest(const ConnectScoRequest& aRequest);
   187   bool
   188   DoRequest(const DisconnectScoRequest& aRequest);
   190   bool
   191   DoRequest(const IsScoConnectedRequest& aRequest);
   193 #ifdef MOZ_B2G_RIL
   194   bool
   195   DoRequest(const AnswerWaitingCallRequest& aRequest);
   197   bool
   198   DoRequest(const IgnoreWaitingCallRequest& aRequest);
   200   bool
   201   DoRequest(const ToggleCallsRequest& aRequest);
   202 #endif
   204   bool
   205   DoRequest(const SendMetaDataRequest& aRequest);
   207   bool
   208   DoRequest(const SendPlayStatusRequest& aRequest);
   209 };
   211 END_BLUETOOTH_NAMESPACE
   213 #endif // mozilla_dom_bluetooth_ipc_bluetoothparent_h__

mercurial