Line data Source code
1 : /* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #ifndef mozilla_plugins_BrowserStreamParent_h
7 : #define mozilla_plugins_BrowserStreamParent_h
8 :
9 : #include "mozilla/plugins/PBrowserStreamParent.h"
10 : #include "mozilla/plugins/AStream.h"
11 : #include "nsNPAPIPluginStreamListener.h"
12 : #include "nsPluginStreamListenerPeer.h"
13 :
14 : namespace mozilla {
15 : namespace plugins {
16 :
17 : class PluginInstanceParent;
18 :
19 : class BrowserStreamParent : public PBrowserStreamParent, public AStream
20 : {
21 : friend class PluginModuleParent;
22 : friend class PluginInstanceParent;
23 :
24 : public:
25 : BrowserStreamParent(PluginInstanceParent* npp,
26 : NPStream* stream);
27 : virtual ~BrowserStreamParent();
28 :
29 0 : virtual bool IsBrowserStream() override { return true; }
30 :
31 : virtual void ActorDestroy(ActorDestroyReason aWhy) override;
32 :
33 : virtual mozilla::ipc::IPCResult AnswerNPN_RequestRead(const IPCByteRanges& ranges,
34 : NPError* result) override;
35 :
36 : virtual mozilla::ipc::IPCResult RecvNPN_DestroyStream(const NPReason& reason) override;
37 :
38 : virtual mozilla::ipc::IPCResult RecvStreamDestroyed() override;
39 :
40 : int32_t WriteReady();
41 : int32_t Write(int32_t offset, int32_t len, void* buffer);
42 : void StreamAsFile(const char* fname);
43 :
44 : void NPP_DestroyStream(NPReason reason);
45 :
46 0 : void SetAlive()
47 : {
48 0 : if (mState == INITIALIZING) {
49 0 : mState = ALIVE;
50 : }
51 0 : }
52 :
53 : private:
54 : using PBrowserStreamParent::SendNPP_DestroyStream;
55 :
56 : PluginInstanceParent* mNPP;
57 : NPStream* mStream;
58 : nsCOMPtr<nsISupports> mStreamPeer;
59 : RefPtr<nsNPAPIPluginStreamListener> mStreamListener;
60 :
61 : enum {
62 : INITIALIZING,
63 : DEFERRING_DESTROY,
64 : ALIVE,
65 : DYING,
66 : DELETING
67 : } mState;
68 : };
69 :
70 : } // namespace plugins
71 : } // namespace mozilla
72 :
73 : #endif
|