security/sandbox/win/src/sandboxtarget/sandboxTarget.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/sandbox/win/src/sandboxtarget/sandboxTarget.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,65 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim: set ts=2 et sw=2 tw=80: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef __SECURITY_SANDBOX_SANDBOXTARGET_H__
    1.11 +#define __SECURITY_SANDBOX_SANDBOXTARGET_H__
    1.12 +
    1.13 +#ifdef TARGET_SANDBOX_EXPORTS
    1.14 +#define TARGET_SANDBOX_EXPORT __declspec(dllexport)
    1.15 +#else
    1.16 +#define TARGET_SANDBOX_EXPORT __declspec(dllimport)
    1.17 +#endif
    1.18 +namespace mozilla {
    1.19 +
    1.20 +
    1.21 +class TARGET_SANDBOX_EXPORT SandboxTarget
    1.22 +{
    1.23 +public:
    1.24 +  typedef void (*StartSandboxPtr)();
    1.25 +
    1.26 +  /**
    1.27 +   * Obtains a pointer to the singleton instance
    1.28 +   */
    1.29 +  static SandboxTarget* Instance()
    1.30 +  {
    1.31 +    static SandboxTarget sb;
    1.32 +    return &sb;
    1.33 +  }
    1.34 +
    1.35 +  /**
    1.36 +   * Called by the application that will lower the sandbox token
    1.37 +   *
    1.38 +   * @param aStartSandboxCallback A callback function which will lower privs
    1.39 +   */
    1.40 +  void SetStartSandboxCallback(StartSandboxPtr aStartSandboxCallback)
    1.41 +  {
    1.42 +    mStartSandboxCallback = aStartSandboxCallback;
    1.43 +  }
    1.44 +
    1.45 +  /**
    1.46 +   * Called by the library that wants to start the sandbox, which in turn
    1.47 +   * calls into the previously set StartSandboxCallback.
    1.48 +   */
    1.49 +  void StartSandbox()
    1.50 +  {
    1.51 +    if (mStartSandboxCallback) {
    1.52 +      mStartSandboxCallback();
    1.53 +    }
    1.54 +  }
    1.55 +
    1.56 +protected:
    1.57 +  SandboxTarget() :
    1.58 +    mStartSandboxCallback(nullptr)
    1.59 +  {
    1.60 +  }
    1.61 +
    1.62 +  StartSandboxPtr mStartSandboxCallback;
    1.63 +};
    1.64 +
    1.65 +
    1.66 +} // mozilla
    1.67 +
    1.68 +#endif

mercurial