security/sandbox/win/src/sandbox_factory.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/sandbox/win/src/sandbox_factory.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,50 @@
     1.4 +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
     1.5 +// Use of this source code is governed by a BSD-style license that can be
     1.6 +// found in the LICENSE file.
     1.7 +
     1.8 +#ifndef SANDBOX_SRC_SANDBOX_FACTORY_H__
     1.9 +#define SANDBOX_SRC_SANDBOX_FACTORY_H__
    1.10 +
    1.11 +#include "sandbox/win/src/sandbox.h"
    1.12 +
    1.13 +// SandboxFactory is a set of static methods to get access to the broker
    1.14 +// or target services object. Only one of the two methods (GetBrokerServices,
    1.15 +// GetTargetServices) will return a non-null pointer and that should be used
    1.16 +// as the indication that the process is the broker or the target:
    1.17 +//
    1.18 +// BrokerServices* broker_services = SandboxFactory::GetBrokerServices();
    1.19 +// if (NULL != broker_services) {
    1.20 +//   //we are the broker, call broker api here
    1.21 +//   broker_services->Init();
    1.22 +// } else {
    1.23 +//   TargetServices* target_services = SandboxFactory::GetTargetServices();
    1.24 +//   if (NULL != target_services) {
    1.25 +//    //we are the target, call target api here
    1.26 +//    target_services->Init();
    1.27 +//  }
    1.28 +//
    1.29 +// The methods in this class are expected to be called from a single thread
    1.30 +//
    1.31 +// The Sandbox library needs to be linked against the main executable, but
    1.32 +// sometimes the API calls are issued from a DLL that loads into the exe
    1.33 +// process. These factory methods then need to be called from the main
    1.34 +// exe and the interface pointers then can be safely passed to the DLL where
    1.35 +// the Sandbox API calls are made.
    1.36 +namespace sandbox {
    1.37 +
    1.38 +class SandboxFactory {
    1.39 + public:
    1.40 +  // Returns the Broker API interface, returns NULL if this process is the
    1.41 +  // target.
    1.42 +  static BrokerServices* GetBrokerServices();
    1.43 +
    1.44 +  // Returns the Target API interface, returns NULL if this process is the
    1.45 +  // broker.
    1.46 +  static TargetServices* GetTargetServices();
    1.47 + private:
    1.48 +  DISALLOW_IMPLICIT_CONSTRUCTORS(SandboxFactory);
    1.49 +};
    1.50 +
    1.51 +}  // namespace sandbox
    1.52 +
    1.53 +#endif  // SANDBOX_SRC_SANDBOX_FACTORY_H__

mercurial