ipc/glue/BackgroundChild.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/ipc/glue/BackgroundChild.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,72 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#ifndef mozilla_ipc_backgroundchild_h__
     1.9 +#define mozilla_ipc_backgroundchild_h__
    1.10 +
    1.11 +#include "base/process.h"
    1.12 +#include "mozilla/Attributes.h"
    1.13 +#include "mozilla/ipc/Transport.h"
    1.14 +
    1.15 +class nsIIPCBackgroundChildCreateCallback;
    1.16 +
    1.17 +namespace mozilla {
    1.18 +namespace dom {
    1.19 +
    1.20 +class ContentChild;
    1.21 +class ContentParent;
    1.22 +
    1.23 +} // namespace dom
    1.24 +
    1.25 +namespace ipc {
    1.26 +
    1.27 +class PBackgroundChild;
    1.28 +
    1.29 +// This class allows access to the PBackground protocol. PBackground allows
    1.30 +// communication between any thread (in the parent or a child process) and a
    1.31 +// single background thread in the parent process. Each PBackgroundChild
    1.32 +// instance is tied to the thread on which it is created and must not be shared
    1.33 +// across threads. Each PBackgroundChild is unique and valid as long as its
    1.34 +// designated thread lives.
    1.35 +//
    1.36 +// Creation of PBackground is asynchronous. GetForCurrentThread() will return
    1.37 +// null until the sequence is complete. GetOrCreateForCurrentThread() will start
    1.38 +// the creation sequence and will call back via the
    1.39 +// nsIIPCBackgroundChildCreateCallback interface when completed. Thereafter
    1.40 +// (assuming success) GetForCurrentThread() will return the same actor every
    1.41 +// time.
    1.42 +//
    1.43 +// The PBackgroundChild actor and all its sub-protocol actors will be
    1.44 +// automatically destroyed when its designated thread completes.
    1.45 +class BackgroundChild MOZ_FINAL
    1.46 +{
    1.47 +  friend class mozilla::dom::ContentChild;
    1.48 +  friend class mozilla::dom::ContentParent;
    1.49 +
    1.50 +  typedef base::ProcessId ProcessId;
    1.51 +  typedef mozilla::ipc::Transport Transport;
    1.52 +
    1.53 +public:
    1.54 +  // See above.
    1.55 +  static PBackgroundChild*
    1.56 +  GetForCurrentThread();
    1.57 +
    1.58 +  // See above.
    1.59 +  static bool
    1.60 +  GetOrCreateForCurrentThread(nsIIPCBackgroundChildCreateCallback* aCallback);
    1.61 +
    1.62 +private:
    1.63 +  // Only called by ContentChild or ContentParent.
    1.64 +  static void
    1.65 +  Startup();
    1.66 +
    1.67 +  // Only called by ContentChild.
    1.68 +  static PBackgroundChild*
    1.69 +  Alloc(Transport* aTransport, ProcessId aOtherProcess);
    1.70 +};
    1.71 +
    1.72 +} // namespace ipc
    1.73 +} // namespace mozilla
    1.74 +
    1.75 +#endif // mozilla_ipc_backgroundchild_h__

mercurial