ipc/glue/BackgroundParent.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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_backgroundparent_h__
michael@0 6 #define mozilla_ipc_backgroundparent_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 template <class> class already_AddRefed;
michael@0 13
michael@0 14 namespace mozilla {
michael@0 15 namespace dom {
michael@0 16
michael@0 17 class ContentParent;
michael@0 18
michael@0 19 } // namespace dom
michael@0 20
michael@0 21 namespace ipc {
michael@0 22
michael@0 23 class PBackgroundParent;
michael@0 24
michael@0 25 // This class is not designed for public consumption beyond the few static
michael@0 26 // member functions.
michael@0 27 class BackgroundParent MOZ_FINAL
michael@0 28 {
michael@0 29 friend class mozilla::dom::ContentParent;
michael@0 30
michael@0 31 typedef base::ProcessId ProcessId;
michael@0 32 typedef mozilla::dom::ContentParent ContentParent;
michael@0 33 typedef mozilla::ipc::Transport Transport;
michael@0 34
michael@0 35 public:
michael@0 36 // This function allows the caller to determine if the given parent actor
michael@0 37 // corresponds to a child actor from another process or a child actor from a
michael@0 38 // different thread in the same process.
michael@0 39 // This function may only be called on the background thread.
michael@0 40 static bool
michael@0 41 IsOtherProcessActor(PBackgroundParent* aBackgroundActor);
michael@0 42
michael@0 43 // This function returns the ContentParent associated with the parent actor if
michael@0 44 // the parent actor corresponds to a child actor from another process. If the
michael@0 45 // parent actor corresponds to a child actor from a different thread in the
michael@0 46 // same process then this function returns null.
michael@0 47 // This function may only be called on the background thread. However,
michael@0 48 // ContentParent is not threadsafe and the returned pointer may not be used on
michael@0 49 // any thread other than the main thread. Callers must take care to use (and
michael@0 50 // release) the returned pointer appropriately.
michael@0 51 static already_AddRefed<ContentParent>
michael@0 52 GetContentParent(PBackgroundParent* aBackgroundActor);
michael@0 53
michael@0 54 private:
michael@0 55 // Only called by ContentParent for cross-process actors.
michael@0 56 static PBackgroundParent*
michael@0 57 Alloc(ContentParent* aContent,
michael@0 58 Transport* aTransport,
michael@0 59 ProcessId aOtherProcess);
michael@0 60 };
michael@0 61
michael@0 62 // Implemented in BackgroundImpl.cpp.
michael@0 63 bool
michael@0 64 IsOnBackgroundThread();
michael@0 65
michael@0 66 #ifdef DEBUG
michael@0 67
michael@0 68 // Implemented in BackgroundImpl.cpp.
michael@0 69 void
michael@0 70 AssertIsOnBackgroundThread();
michael@0 71
michael@0 72 #else
michael@0 73
michael@0 74 inline void
michael@0 75 AssertIsOnBackgroundThread()
michael@0 76 { }
michael@0 77
michael@0 78 #endif // DEBUG
michael@0 79
michael@0 80 } // namespace ipc
michael@0 81 } // namespace mozilla
michael@0 82
michael@0 83 #endif // mozilla_ipc_backgroundparent_h__

mercurial