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