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.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     3  * You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 #ifndef mozilla_ipc_backgroundparent_h__
     6 #define mozilla_ipc_backgroundparent_h__
     8 #include "base/process.h"
     9 #include "mozilla/Attributes.h"
    10 #include "mozilla/ipc/Transport.h"
    12 template <class> class already_AddRefed;
    14 namespace mozilla {
    15 namespace dom {
    17 class ContentParent;
    19 } // namespace dom
    21 namespace ipc {
    23 class PBackgroundParent;
    25 // This class is not designed for public consumption beyond the few static
    26 // member functions.
    27 class BackgroundParent MOZ_FINAL
    28 {
    29   friend class mozilla::dom::ContentParent;
    31   typedef base::ProcessId ProcessId;
    32   typedef mozilla::dom::ContentParent ContentParent;
    33   typedef mozilla::ipc::Transport Transport;
    35 public:
    36   // This function allows the caller to determine if the given parent actor
    37   // corresponds to a child actor from another process or a child actor from a
    38   // different thread in the same process.
    39   // This function may only be called on the background thread.
    40   static bool
    41   IsOtherProcessActor(PBackgroundParent* aBackgroundActor);
    43   // This function returns the ContentParent associated with the parent actor if
    44   // the parent actor corresponds to a child actor from another process. If the
    45   // parent actor corresponds to a child actor from a different thread in the
    46   // same process then this function returns null.
    47   // This function may only be called on the background thread. However,
    48   // ContentParent is not threadsafe and the returned pointer may not be used on
    49   // any thread other than the main thread. Callers must take care to use (and
    50   // release) the returned pointer appropriately.
    51   static already_AddRefed<ContentParent>
    52   GetContentParent(PBackgroundParent* aBackgroundActor);
    54 private:
    55   // Only called by ContentParent for cross-process actors.
    56   static PBackgroundParent*
    57   Alloc(ContentParent* aContent,
    58         Transport* aTransport,
    59         ProcessId aOtherProcess);
    60 };
    62 // Implemented in BackgroundImpl.cpp.
    63 bool
    64 IsOnBackgroundThread();
    66 #ifdef DEBUG
    68 // Implemented in BackgroundImpl.cpp.
    69 void
    70 AssertIsOnBackgroundThread();
    72 #else
    74 inline void
    75 AssertIsOnBackgroundThread()
    76 { }
    78 #endif // DEBUG
    80 } // namespace ipc
    81 } // namespace mozilla
    83 #endif // mozilla_ipc_backgroundparent_h__

mercurial