dom/bluetooth/ipc/BluetoothParent.h

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:bfe71c075590
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/. */
6
7 #ifndef mozilla_dom_bluetooth_ipc_bluetoothparent_h__
8 #define mozilla_dom_bluetooth_ipc_bluetoothparent_h__
9
10 #include "mozilla/dom/bluetooth/BluetoothCommon.h"
11
12 #include "mozilla/dom/bluetooth/PBluetoothParent.h"
13 #include "mozilla/dom/bluetooth/PBluetoothRequestParent.h"
14
15 #include "mozilla/Attributes.h"
16 #include "mozilla/Observer.h"
17 #include "nsAutoPtr.h"
18 #include "nsTArray.h"
19 #include "nsThreadUtils.h"
20
21 template <class T>
22 class nsRevocableEventPtr;
23
24 namespace mozilla {
25 namespace dom {
26
27 class ContentParent;
28
29 } // namespace dom
30 } // namespace mozilla
31
32 BEGIN_BLUETOOTH_NAMESPACE
33
34 class BluetoothService;
35
36 /*******************************************************************************
37 * BluetoothParent
38 ******************************************************************************/
39
40 class BluetoothParent : public PBluetoothParent,
41 public mozilla::Observer<BluetoothSignal>
42 {
43 friend class mozilla::dom::ContentParent;
44
45 enum ShutdownState
46 {
47 Running = 0,
48 SentBeginShutdown,
49 ReceivedStopNotifying,
50 SentNotificationsStopped,
51 Dead
52 };
53
54 nsRefPtr<BluetoothService> mService;
55 ShutdownState mShutdownState;
56 bool mReceivedStopNotifying;
57 bool mSentBeginShutdown;
58
59 public:
60 void
61 BeginShutdown();
62
63 protected:
64 BluetoothParent();
65 virtual ~BluetoothParent();
66
67 bool
68 InitWithService(BluetoothService* aService);
69
70 virtual void
71 ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
72
73 virtual bool
74 RecvRegisterSignalHandler(const nsString& aNode) MOZ_OVERRIDE;
75
76 virtual bool
77 RecvUnregisterSignalHandler(const nsString& aNode) MOZ_OVERRIDE;
78
79 virtual bool
80 RecvStopNotifying() MOZ_OVERRIDE;
81
82 virtual bool
83 RecvPBluetoothRequestConstructor(PBluetoothRequestParent* aActor,
84 const Request& aRequest) MOZ_OVERRIDE;
85
86 virtual PBluetoothRequestParent*
87 AllocPBluetoothRequestParent(const Request& aRequest) MOZ_OVERRIDE;
88
89 virtual bool
90 DeallocPBluetoothRequestParent(PBluetoothRequestParent* aActor) MOZ_OVERRIDE;
91
92 virtual void
93 Notify(const BluetoothSignal& aSignal) MOZ_OVERRIDE;
94
95 private:
96 void
97 UnregisterAllSignalHandlers();
98 };
99
100 /*******************************************************************************
101 * BluetoothAdapterRequestParent
102 ******************************************************************************/
103
104 class BluetoothRequestParent : public PBluetoothRequestParent
105 {
106 class ReplyRunnable;
107 friend class BluetoothParent;
108
109 friend class ReplyRunnable;
110
111 nsRefPtr<BluetoothService> mService;
112 nsRevocableEventPtr<ReplyRunnable> mReplyRunnable;
113
114 #ifdef DEBUG
115 Request::Type mRequestType;
116 #endif
117
118 protected:
119 BluetoothRequestParent(BluetoothService* aService);
120 virtual ~BluetoothRequestParent();
121
122 virtual void
123 ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
124
125 void
126 RequestComplete();
127
128 bool
129 DoRequest(const DefaultAdapterPathRequest& aRequest);
130
131 bool
132 DoRequest(const SetPropertyRequest& aRequest);
133
134 bool
135 DoRequest(const GetPropertyRequest& aRequest);
136
137 bool
138 DoRequest(const StartDiscoveryRequest& aRequest);
139
140 bool
141 DoRequest(const StopDiscoveryRequest& aRequest);
142
143 bool
144 DoRequest(const PairRequest& aRequest);
145
146 bool
147 DoRequest(const UnpairRequest& aRequest);
148
149 bool
150 DoRequest(const PairedDevicePropertiesRequest& aRequest);
151 bool
152 DoRequest(const ConnectedDevicePropertiesRequest& aRequest);
153
154 bool
155 DoRequest(const SetPinCodeRequest& aRequest);
156
157 bool
158 DoRequest(const SetPasskeyRequest& aRequest);
159
160 bool
161 DoRequest(const ConfirmPairingConfirmationRequest& aRequest);
162
163 bool
164 DoRequest(const DenyPairingConfirmationRequest& aRequest);
165
166 bool
167 DoRequest(const ConnectRequest& aRequest);
168
169 bool
170 DoRequest(const DisconnectRequest& aRequest);
171
172 bool
173 DoRequest(const SendFileRequest& aRequest);
174
175 bool
176 DoRequest(const StopSendingFileRequest& aRequest);
177
178 bool
179 DoRequest(const ConfirmReceivingFileRequest& aRequest);
180
181 bool
182 DoRequest(const DenyReceivingFileRequest& aRequest);
183
184 bool
185 DoRequest(const ConnectScoRequest& aRequest);
186
187 bool
188 DoRequest(const DisconnectScoRequest& aRequest);
189
190 bool
191 DoRequest(const IsScoConnectedRequest& aRequest);
192
193 #ifdef MOZ_B2G_RIL
194 bool
195 DoRequest(const AnswerWaitingCallRequest& aRequest);
196
197 bool
198 DoRequest(const IgnoreWaitingCallRequest& aRequest);
199
200 bool
201 DoRequest(const ToggleCallsRequest& aRequest);
202 #endif
203
204 bool
205 DoRequest(const SendMetaDataRequest& aRequest);
206
207 bool
208 DoRequest(const SendPlayStatusRequest& aRequest);
209 };
210
211 END_BLUETOOTH_NAMESPACE
212
213 #endif // mozilla_dom_bluetooth_ipc_bluetoothparent_h__

mercurial