|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* vim: set ts=8 sts=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_UDPSocketParent_h__ |
|
8 #define mozilla_dom_UDPSocketParent_h__ |
|
9 |
|
10 #include "mozilla/net/PUDPSocketParent.h" |
|
11 #include "nsCOMPtr.h" |
|
12 #include "nsIUDPSocket.h" |
|
13 #include "nsIUDPSocketFilter.h" |
|
14 |
|
15 namespace mozilla { |
|
16 namespace dom { |
|
17 |
|
18 class UDPSocketParent : public mozilla::net::PUDPSocketParent |
|
19 , public nsIUDPSocketListener |
|
20 { |
|
21 public: |
|
22 NS_DECL_THREADSAFE_ISUPPORTS |
|
23 NS_DECL_NSIUDPSOCKETLISTENER |
|
24 |
|
25 UDPSocketParent(nsIUDPSocketFilter* filter) : |
|
26 mIPCOpen(true), |
|
27 mFilter(filter) {} |
|
28 |
|
29 virtual ~UDPSocketParent(); |
|
30 |
|
31 bool Init(const nsCString& aHost, const uint16_t aPort); |
|
32 |
|
33 virtual bool RecvClose() MOZ_OVERRIDE; |
|
34 virtual bool RecvData(const InfallibleTArray<uint8_t>& aData, |
|
35 const nsCString& aRemoteAddress, |
|
36 const uint16_t& aPort) MOZ_OVERRIDE; |
|
37 virtual bool RecvDataWithAddress( const InfallibleTArray<uint8_t>& data, |
|
38 const mozilla::net::NetAddr& addr); |
|
39 virtual bool RecvRequestDelete() MOZ_OVERRIDE; |
|
40 |
|
41 private: |
|
42 virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE; |
|
43 |
|
44 bool mIPCOpen; |
|
45 nsCOMPtr<nsIUDPSocket> mSocket; |
|
46 nsCOMPtr<nsIUDPSocketFilter> mFilter; |
|
47 }; |
|
48 |
|
49 } // namespace dom |
|
50 } // namespace mozilla |
|
51 |
|
52 #endif // !defined(mozilla_dom_UDPSocketParent_h__) |