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 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 3 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #ifndef mozilla_ipc_backgroundchild_h__ |
michael@0 | 6 | #define mozilla_ipc_backgroundchild_h__ |
michael@0 | 7 | |
michael@0 | 8 | #include "base/process.h" |
michael@0 | 9 | #include "mozilla/Attributes.h" |
michael@0 | 10 | #include "mozilla/ipc/Transport.h" |
michael@0 | 11 | |
michael@0 | 12 | class nsIIPCBackgroundChildCreateCallback; |
michael@0 | 13 | |
michael@0 | 14 | namespace mozilla { |
michael@0 | 15 | namespace dom { |
michael@0 | 16 | |
michael@0 | 17 | class ContentChild; |
michael@0 | 18 | class ContentParent; |
michael@0 | 19 | |
michael@0 | 20 | } // namespace dom |
michael@0 | 21 | |
michael@0 | 22 | namespace ipc { |
michael@0 | 23 | |
michael@0 | 24 | class PBackgroundChild; |
michael@0 | 25 | |
michael@0 | 26 | // This class allows access to the PBackground protocol. PBackground allows |
michael@0 | 27 | // communication between any thread (in the parent or a child process) and a |
michael@0 | 28 | // single background thread in the parent process. Each PBackgroundChild |
michael@0 | 29 | // instance is tied to the thread on which it is created and must not be shared |
michael@0 | 30 | // across threads. Each PBackgroundChild is unique and valid as long as its |
michael@0 | 31 | // designated thread lives. |
michael@0 | 32 | // |
michael@0 | 33 | // Creation of PBackground is asynchronous. GetForCurrentThread() will return |
michael@0 | 34 | // null until the sequence is complete. GetOrCreateForCurrentThread() will start |
michael@0 | 35 | // the creation sequence and will call back via the |
michael@0 | 36 | // nsIIPCBackgroundChildCreateCallback interface when completed. Thereafter |
michael@0 | 37 | // (assuming success) GetForCurrentThread() will return the same actor every |
michael@0 | 38 | // time. |
michael@0 | 39 | // |
michael@0 | 40 | // The PBackgroundChild actor and all its sub-protocol actors will be |
michael@0 | 41 | // automatically destroyed when its designated thread completes. |
michael@0 | 42 | class BackgroundChild MOZ_FINAL |
michael@0 | 43 | { |
michael@0 | 44 | friend class mozilla::dom::ContentChild; |
michael@0 | 45 | friend class mozilla::dom::ContentParent; |
michael@0 | 46 | |
michael@0 | 47 | typedef base::ProcessId ProcessId; |
michael@0 | 48 | typedef mozilla::ipc::Transport Transport; |
michael@0 | 49 | |
michael@0 | 50 | public: |
michael@0 | 51 | // See above. |
michael@0 | 52 | static PBackgroundChild* |
michael@0 | 53 | GetForCurrentThread(); |
michael@0 | 54 | |
michael@0 | 55 | // See above. |
michael@0 | 56 | static bool |
michael@0 | 57 | GetOrCreateForCurrentThread(nsIIPCBackgroundChildCreateCallback* aCallback); |
michael@0 | 58 | |
michael@0 | 59 | private: |
michael@0 | 60 | // Only called by ContentChild or ContentParent. |
michael@0 | 61 | static void |
michael@0 | 62 | Startup(); |
michael@0 | 63 | |
michael@0 | 64 | // Only called by ContentChild. |
michael@0 | 65 | static PBackgroundChild* |
michael@0 | 66 | Alloc(Transport* aTransport, ProcessId aOtherProcess); |
michael@0 | 67 | }; |
michael@0 | 68 | |
michael@0 | 69 | } // namespace ipc |
michael@0 | 70 | } // namespace mozilla |
michael@0 | 71 | |
michael@0 | 72 | #endif // mozilla_ipc_backgroundchild_h__ |