/src/mozilla-central/dom/presentation/PresentationTCPSessionTransport.h
Line | Count | Source (jump to first uncovered line) |
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 |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef mozilla_dom_PresentationSessionTransport_h |
8 | | #define mozilla_dom_PresentationSessionTransport_h |
9 | | |
10 | | #include "mozilla/RefPtr.h" |
11 | | #include "nsCOMPtr.h" |
12 | | #include "nsIAsyncInputStream.h" |
13 | | #include "nsIPresentationSessionTransport.h" |
14 | | #include "nsIPresentationSessionTransportBuilder.h" |
15 | | #include "nsIStreamListener.h" |
16 | | #include "nsISupportsImpl.h" |
17 | | #include "nsITransport.h" |
18 | | |
19 | | class nsISocketTransport; |
20 | | class nsIInputStreamPump; |
21 | | class nsIScriptableInputStream; |
22 | | class nsIMultiplexInputStream; |
23 | | class nsIAsyncStreamCopier; |
24 | | class nsIInputStream; |
25 | | |
26 | | namespace mozilla { |
27 | | namespace dom { |
28 | | |
29 | | /* |
30 | | * App-to-App transport channel for the presentation session. It's usually |
31 | | * initialized with an |InitWithSocketTransport| call if at the presenting sender |
32 | | * side; whereas it's initialized with an |InitWithChannelDescription| if at the |
33 | | * presenting receiver side. The lifetime is managed in either |
34 | | * |PresentationControllingInfo| (sender side) or |PresentationPresentingInfo| |
35 | | * (receiver side) in PresentationSessionInfo.cpp. |
36 | | */ |
37 | | class PresentationTCPSessionTransport final : public nsIPresentationSessionTransport |
38 | | , public nsIPresentationTCPSessionTransportBuilder |
39 | | , public nsITransportEventSink |
40 | | , public nsIInputStreamCallback |
41 | | , public nsIStreamListener |
42 | | { |
43 | | public: |
44 | | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
45 | | NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(PresentationTCPSessionTransport, |
46 | | nsIPresentationSessionTransport) |
47 | | |
48 | | NS_DECL_NSIPRESENTATIONSESSIONTRANSPORT |
49 | | NS_DECL_NSIPRESENTATIONSESSIONTRANSPORTBUILDER |
50 | | NS_DECL_NSIPRESENTATIONTCPSESSIONTRANSPORTBUILDER |
51 | | NS_DECL_NSITRANSPORTEVENTSINK |
52 | | NS_DECL_NSIINPUTSTREAMCALLBACK |
53 | | NS_DECL_NSIREQUESTOBSERVER |
54 | | NS_DECL_NSISTREAMLISTENER |
55 | | |
56 | | PresentationTCPSessionTransport(); |
57 | | |
58 | | void NotifyCopyComplete(nsresult aStatus); |
59 | | |
60 | | private: |
61 | | ~PresentationTCPSessionTransport(); |
62 | | |
63 | | nsresult CreateStream(); |
64 | | |
65 | | nsresult CreateInputStreamPump(); |
66 | | |
67 | | nsresult EnsureCopying(); |
68 | | |
69 | | enum class ReadyState { |
70 | | CONNECTING, |
71 | | OPEN, |
72 | | CLOSING, |
73 | | CLOSED |
74 | | }; |
75 | | |
76 | | void SetReadyState(ReadyState aReadyState); |
77 | | |
78 | | bool IsReadyToNotifyData() |
79 | 0 | { |
80 | 0 | return mDataNotificationEnabled && mReadyState == ReadyState::OPEN; |
81 | 0 | } |
82 | | |
83 | | ReadyState mReadyState; |
84 | | bool mAsyncCopierActive; |
85 | | nsresult mCloseStatus; |
86 | | bool mDataNotificationEnabled; |
87 | | |
88 | | uint8_t mRole = 0; |
89 | | |
90 | | // Raw socket streams |
91 | | nsCOMPtr<nsISocketTransport> mTransport; |
92 | | nsCOMPtr<nsIInputStream> mSocketInputStream; |
93 | | nsCOMPtr<nsIOutputStream> mSocketOutputStream; |
94 | | |
95 | | // Input stream machinery |
96 | | nsCOMPtr<nsIInputStreamPump> mInputStreamPump; |
97 | | nsCOMPtr<nsIScriptableInputStream> mInputStreamScriptable; |
98 | | |
99 | | nsCOMPtr<nsIPresentationSessionTransportCallback> mCallback; |
100 | | nsCOMPtr<nsIPresentationSessionTransportBuilderListener> mListener; |
101 | | |
102 | | // The data to be sent. |
103 | | nsTArray<nsCOMPtr<nsIInputStream>> mPendingData; |
104 | | }; |
105 | | |
106 | | } // namespace dom |
107 | | } // namespace mozilla |
108 | | |
109 | | #endif // mozilla_dom_PresentationSessionTransport_h |