ipc/glue/BackgroundChild.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_backgroundchild_h__
     6 #define mozilla_ipc_backgroundchild_h__
     8 #include "base/process.h"
     9 #include "mozilla/Attributes.h"
    10 #include "mozilla/ipc/Transport.h"
    12 class nsIIPCBackgroundChildCreateCallback;
    14 namespace mozilla {
    15 namespace dom {
    17 class ContentChild;
    18 class ContentParent;
    20 } // namespace dom
    22 namespace ipc {
    24 class PBackgroundChild;
    26 // This class allows access to the PBackground protocol. PBackground allows
    27 // communication between any thread (in the parent or a child process) and a
    28 // single background thread in the parent process. Each PBackgroundChild
    29 // instance is tied to the thread on which it is created and must not be shared
    30 // across threads. Each PBackgroundChild is unique and valid as long as its
    31 // designated thread lives.
    32 //
    33 // Creation of PBackground is asynchronous. GetForCurrentThread() will return
    34 // null until the sequence is complete. GetOrCreateForCurrentThread() will start
    35 // the creation sequence and will call back via the
    36 // nsIIPCBackgroundChildCreateCallback interface when completed. Thereafter
    37 // (assuming success) GetForCurrentThread() will return the same actor every
    38 // time.
    39 //
    40 // The PBackgroundChild actor and all its sub-protocol actors will be
    41 // automatically destroyed when its designated thread completes.
    42 class BackgroundChild MOZ_FINAL
    43 {
    44   friend class mozilla::dom::ContentChild;
    45   friend class mozilla::dom::ContentParent;
    47   typedef base::ProcessId ProcessId;
    48   typedef mozilla::ipc::Transport Transport;
    50 public:
    51   // See above.
    52   static PBackgroundChild*
    53   GetForCurrentThread();
    55   // See above.
    56   static bool
    57   GetOrCreateForCurrentThread(nsIIPCBackgroundChildCreateCallback* aCallback);
    59 private:
    60   // Only called by ContentChild or ContentParent.
    61   static void
    62   Startup();
    64   // Only called by ContentChild.
    65   static PBackgroundChild*
    66   Alloc(Transport* aTransport, ProcessId aOtherProcess);
    67 };
    69 } // namespace ipc
    70 } // namespace mozilla
    72 #endif // mozilla_ipc_backgroundchild_h__

mercurial