security/sandbox/win/src/sandbox_factory.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
michael@0 2 // Use of this source code is governed by a BSD-style license that can be
michael@0 3 // found in the LICENSE file.
michael@0 4
michael@0 5 #ifndef SANDBOX_SRC_SANDBOX_FACTORY_H__
michael@0 6 #define SANDBOX_SRC_SANDBOX_FACTORY_H__
michael@0 7
michael@0 8 #include "sandbox/win/src/sandbox.h"
michael@0 9
michael@0 10 // SandboxFactory is a set of static methods to get access to the broker
michael@0 11 // or target services object. Only one of the two methods (GetBrokerServices,
michael@0 12 // GetTargetServices) will return a non-null pointer and that should be used
michael@0 13 // as the indication that the process is the broker or the target:
michael@0 14 //
michael@0 15 // BrokerServices* broker_services = SandboxFactory::GetBrokerServices();
michael@0 16 // if (NULL != broker_services) {
michael@0 17 // //we are the broker, call broker api here
michael@0 18 // broker_services->Init();
michael@0 19 // } else {
michael@0 20 // TargetServices* target_services = SandboxFactory::GetTargetServices();
michael@0 21 // if (NULL != target_services) {
michael@0 22 // //we are the target, call target api here
michael@0 23 // target_services->Init();
michael@0 24 // }
michael@0 25 //
michael@0 26 // The methods in this class are expected to be called from a single thread
michael@0 27 //
michael@0 28 // The Sandbox library needs to be linked against the main executable, but
michael@0 29 // sometimes the API calls are issued from a DLL that loads into the exe
michael@0 30 // process. These factory methods then need to be called from the main
michael@0 31 // exe and the interface pointers then can be safely passed to the DLL where
michael@0 32 // the Sandbox API calls are made.
michael@0 33 namespace sandbox {
michael@0 34
michael@0 35 class SandboxFactory {
michael@0 36 public:
michael@0 37 // Returns the Broker API interface, returns NULL if this process is the
michael@0 38 // target.
michael@0 39 static BrokerServices* GetBrokerServices();
michael@0 40
michael@0 41 // Returns the Target API interface, returns NULL if this process is the
michael@0 42 // broker.
michael@0 43 static TargetServices* GetTargetServices();
michael@0 44 private:
michael@0 45 DISALLOW_IMPLICIT_CONSTRUCTORS(SandboxFactory);
michael@0 46 };
michael@0 47
michael@0 48 } // namespace sandbox
michael@0 49
michael@0 50 #endif // SANDBOX_SRC_SANDBOX_FACTORY_H__

mercurial