Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim: set ts=2 et sw=2 tw=80: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef mozilla_plugins_MiniShmParent_h |
michael@0 | 8 | #define mozilla_plugins_MiniShmParent_h |
michael@0 | 9 | |
michael@0 | 10 | #include "MiniShmBase.h" |
michael@0 | 11 | |
michael@0 | 12 | #include <string> |
michael@0 | 13 | |
michael@0 | 14 | namespace mozilla { |
michael@0 | 15 | namespace plugins { |
michael@0 | 16 | |
michael@0 | 17 | /** |
michael@0 | 18 | * This class provides a lightweight shared memory interface for a parent |
michael@0 | 19 | * process in Win32. |
michael@0 | 20 | * This code assumes that there is a parent-child relationship between |
michael@0 | 21 | * processes, as it creates inheritable handles. |
michael@0 | 22 | * Note that this class is *not* an IPDL actor. |
michael@0 | 23 | * |
michael@0 | 24 | * @see MiniShmChild |
michael@0 | 25 | */ |
michael@0 | 26 | class MiniShmParent : public MiniShmBase |
michael@0 | 27 | { |
michael@0 | 28 | public: |
michael@0 | 29 | MiniShmParent(); |
michael@0 | 30 | virtual ~MiniShmParent(); |
michael@0 | 31 | |
michael@0 | 32 | static const unsigned int kDefaultMiniShmSectionSize; |
michael@0 | 33 | |
michael@0 | 34 | /** |
michael@0 | 35 | * Initialize shared memory on the parent side. |
michael@0 | 36 | * |
michael@0 | 37 | * @param aObserver A MiniShmObserver object to receive event notifications. |
michael@0 | 38 | * @param aTimeout Timeout in milliseconds. |
michael@0 | 39 | * @param aSectionSize Desired size of the shared memory section. This is |
michael@0 | 40 | * expected to be a multiple of 0x1000 (4KiB). |
michael@0 | 41 | * @return nsresult error code |
michael@0 | 42 | */ |
michael@0 | 43 | nsresult |
michael@0 | 44 | Init(MiniShmObserver* aObserver, const DWORD aTimeout, |
michael@0 | 45 | const unsigned int aSectionSize = kDefaultMiniShmSectionSize); |
michael@0 | 46 | |
michael@0 | 47 | /** |
michael@0 | 48 | * Destroys the shared memory section. Useful to explicitly release |
michael@0 | 49 | * resources if it is known that they won't be needed again. |
michael@0 | 50 | */ |
michael@0 | 51 | void |
michael@0 | 52 | CleanUp(); |
michael@0 | 53 | |
michael@0 | 54 | /** |
michael@0 | 55 | * Provides a cookie string that should be passed to MiniShmChild |
michael@0 | 56 | * during its initialization. |
michael@0 | 57 | * |
michael@0 | 58 | * @param aCookie A std::wstring variable to receive the cookie. |
michael@0 | 59 | * @return nsresult error code |
michael@0 | 60 | */ |
michael@0 | 61 | nsresult |
michael@0 | 62 | GetCookie(std::wstring& aCookie); |
michael@0 | 63 | |
michael@0 | 64 | virtual nsresult |
michael@0 | 65 | Send() MOZ_OVERRIDE; |
michael@0 | 66 | |
michael@0 | 67 | bool |
michael@0 | 68 | IsConnected() const; |
michael@0 | 69 | |
michael@0 | 70 | protected: |
michael@0 | 71 | void |
michael@0 | 72 | OnEvent() MOZ_OVERRIDE; |
michael@0 | 73 | |
michael@0 | 74 | private: |
michael@0 | 75 | void |
michael@0 | 76 | FinalizeConnection(); |
michael@0 | 77 | |
michael@0 | 78 | unsigned int mSectionSize; |
michael@0 | 79 | HANDLE mParentEvent; |
michael@0 | 80 | HANDLE mParentGuard; |
michael@0 | 81 | HANDLE mChildEvent; |
michael@0 | 82 | HANDLE mChildGuard; |
michael@0 | 83 | HANDLE mRegWait; |
michael@0 | 84 | HANDLE mFileMapping; |
michael@0 | 85 | LPVOID mView; |
michael@0 | 86 | bool mIsConnected; |
michael@0 | 87 | DWORD mTimeout; |
michael@0 | 88 | |
michael@0 | 89 | DISALLOW_COPY_AND_ASSIGN(MiniShmParent); |
michael@0 | 90 | }; |
michael@0 | 91 | |
michael@0 | 92 | } // namespace plugins |
michael@0 | 93 | } // namespace mozilla |
michael@0 | 94 | |
michael@0 | 95 | #endif // mozilla_plugins_MiniShmParent_h |
michael@0 | 96 |