1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/bluetooth/ipc/BluetoothParent.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,213 @@ 1.4 +/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ 1.5 +/* vim: set ts=2 et sw=2 tw=80: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.8 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef mozilla_dom_bluetooth_ipc_bluetoothparent_h__ 1.11 +#define mozilla_dom_bluetooth_ipc_bluetoothparent_h__ 1.12 + 1.13 +#include "mozilla/dom/bluetooth/BluetoothCommon.h" 1.14 + 1.15 +#include "mozilla/dom/bluetooth/PBluetoothParent.h" 1.16 +#include "mozilla/dom/bluetooth/PBluetoothRequestParent.h" 1.17 + 1.18 +#include "mozilla/Attributes.h" 1.19 +#include "mozilla/Observer.h" 1.20 +#include "nsAutoPtr.h" 1.21 +#include "nsTArray.h" 1.22 +#include "nsThreadUtils.h" 1.23 + 1.24 +template <class T> 1.25 +class nsRevocableEventPtr; 1.26 + 1.27 +namespace mozilla { 1.28 +namespace dom { 1.29 + 1.30 +class ContentParent; 1.31 + 1.32 +} // namespace dom 1.33 +} // namespace mozilla 1.34 + 1.35 +BEGIN_BLUETOOTH_NAMESPACE 1.36 + 1.37 +class BluetoothService; 1.38 + 1.39 +/******************************************************************************* 1.40 + * BluetoothParent 1.41 + ******************************************************************************/ 1.42 + 1.43 +class BluetoothParent : public PBluetoothParent, 1.44 + public mozilla::Observer<BluetoothSignal> 1.45 +{ 1.46 + friend class mozilla::dom::ContentParent; 1.47 + 1.48 + enum ShutdownState 1.49 + { 1.50 + Running = 0, 1.51 + SentBeginShutdown, 1.52 + ReceivedStopNotifying, 1.53 + SentNotificationsStopped, 1.54 + Dead 1.55 + }; 1.56 + 1.57 + nsRefPtr<BluetoothService> mService; 1.58 + ShutdownState mShutdownState; 1.59 + bool mReceivedStopNotifying; 1.60 + bool mSentBeginShutdown; 1.61 + 1.62 +public: 1.63 + void 1.64 + BeginShutdown(); 1.65 + 1.66 +protected: 1.67 + BluetoothParent(); 1.68 + virtual ~BluetoothParent(); 1.69 + 1.70 + bool 1.71 + InitWithService(BluetoothService* aService); 1.72 + 1.73 + virtual void 1.74 + ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE; 1.75 + 1.76 + virtual bool 1.77 + RecvRegisterSignalHandler(const nsString& aNode) MOZ_OVERRIDE; 1.78 + 1.79 + virtual bool 1.80 + RecvUnregisterSignalHandler(const nsString& aNode) MOZ_OVERRIDE; 1.81 + 1.82 + virtual bool 1.83 + RecvStopNotifying() MOZ_OVERRIDE; 1.84 + 1.85 + virtual bool 1.86 + RecvPBluetoothRequestConstructor(PBluetoothRequestParent* aActor, 1.87 + const Request& aRequest) MOZ_OVERRIDE; 1.88 + 1.89 + virtual PBluetoothRequestParent* 1.90 + AllocPBluetoothRequestParent(const Request& aRequest) MOZ_OVERRIDE; 1.91 + 1.92 + virtual bool 1.93 + DeallocPBluetoothRequestParent(PBluetoothRequestParent* aActor) MOZ_OVERRIDE; 1.94 + 1.95 + virtual void 1.96 + Notify(const BluetoothSignal& aSignal) MOZ_OVERRIDE; 1.97 + 1.98 +private: 1.99 + void 1.100 + UnregisterAllSignalHandlers(); 1.101 +}; 1.102 + 1.103 +/******************************************************************************* 1.104 + * BluetoothAdapterRequestParent 1.105 + ******************************************************************************/ 1.106 + 1.107 +class BluetoothRequestParent : public PBluetoothRequestParent 1.108 +{ 1.109 + class ReplyRunnable; 1.110 + friend class BluetoothParent; 1.111 + 1.112 + friend class ReplyRunnable; 1.113 + 1.114 + nsRefPtr<BluetoothService> mService; 1.115 + nsRevocableEventPtr<ReplyRunnable> mReplyRunnable; 1.116 + 1.117 +#ifdef DEBUG 1.118 + Request::Type mRequestType; 1.119 +#endif 1.120 + 1.121 +protected: 1.122 + BluetoothRequestParent(BluetoothService* aService); 1.123 + virtual ~BluetoothRequestParent(); 1.124 + 1.125 + virtual void 1.126 + ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE; 1.127 + 1.128 + void 1.129 + RequestComplete(); 1.130 + 1.131 + bool 1.132 + DoRequest(const DefaultAdapterPathRequest& aRequest); 1.133 + 1.134 + bool 1.135 + DoRequest(const SetPropertyRequest& aRequest); 1.136 + 1.137 + bool 1.138 + DoRequest(const GetPropertyRequest& aRequest); 1.139 + 1.140 + bool 1.141 + DoRequest(const StartDiscoveryRequest& aRequest); 1.142 + 1.143 + bool 1.144 + DoRequest(const StopDiscoveryRequest& aRequest); 1.145 + 1.146 + bool 1.147 + DoRequest(const PairRequest& aRequest); 1.148 + 1.149 + bool 1.150 + DoRequest(const UnpairRequest& aRequest); 1.151 + 1.152 + bool 1.153 + DoRequest(const PairedDevicePropertiesRequest& aRequest); 1.154 + bool 1.155 + DoRequest(const ConnectedDevicePropertiesRequest& aRequest); 1.156 + 1.157 + bool 1.158 + DoRequest(const SetPinCodeRequest& aRequest); 1.159 + 1.160 + bool 1.161 + DoRequest(const SetPasskeyRequest& aRequest); 1.162 + 1.163 + bool 1.164 + DoRequest(const ConfirmPairingConfirmationRequest& aRequest); 1.165 + 1.166 + bool 1.167 + DoRequest(const DenyPairingConfirmationRequest& aRequest); 1.168 + 1.169 + bool 1.170 + DoRequest(const ConnectRequest& aRequest); 1.171 + 1.172 + bool 1.173 + DoRequest(const DisconnectRequest& aRequest); 1.174 + 1.175 + bool 1.176 + DoRequest(const SendFileRequest& aRequest); 1.177 + 1.178 + bool 1.179 + DoRequest(const StopSendingFileRequest& aRequest); 1.180 + 1.181 + bool 1.182 + DoRequest(const ConfirmReceivingFileRequest& aRequest); 1.183 + 1.184 + bool 1.185 + DoRequest(const DenyReceivingFileRequest& aRequest); 1.186 + 1.187 + bool 1.188 + DoRequest(const ConnectScoRequest& aRequest); 1.189 + 1.190 + bool 1.191 + DoRequest(const DisconnectScoRequest& aRequest); 1.192 + 1.193 + bool 1.194 + DoRequest(const IsScoConnectedRequest& aRequest); 1.195 + 1.196 +#ifdef MOZ_B2G_RIL 1.197 + bool 1.198 + DoRequest(const AnswerWaitingCallRequest& aRequest); 1.199 + 1.200 + bool 1.201 + DoRequest(const IgnoreWaitingCallRequest& aRequest); 1.202 + 1.203 + bool 1.204 + DoRequest(const ToggleCallsRequest& aRequest); 1.205 +#endif 1.206 + 1.207 + bool 1.208 + DoRequest(const SendMetaDataRequest& aRequest); 1.209 + 1.210 + bool 1.211 + DoRequest(const SendPlayStatusRequest& aRequest); 1.212 +}; 1.213 + 1.214 +END_BLUETOOTH_NAMESPACE 1.215 + 1.216 +#endif // mozilla_dom_bluetooth_ipc_bluetoothparent_h__