| 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 #include <stdio.h> | |
| 6 #include <windows.h> | |
| 7 #include "sandbox/src/sandbox.h" | |
| 8 #include "sandbox/src/sandbox_factory.h" | |
| 9 #include "sandbox/src/broker_services.h" | |
| 10 #include "sandbox/src/target_services.h" | |
| 11 | |
| 12 #if defined(_WIN64) && !defined(NACL_WIN64) | |
| 13 // We allow building this code for Win64 as part of NaCl to enable development | |
| 14 #error Sandbox code was not tested on 64-bit Windows. See \ | |
| 15 http://crbug.com/27218 for details and progress log. | |
| 16 #endif | |
| 17 | |
| 18 | |
| 19 namespace sandbox { | |
| 20 // The section for IPC and policy. | |
| 21 SANDBOX_INTERCEPT HANDLE g_shared_section = NULL; | |
| 22 | |
| 23 static bool s_is_broker = false; | |
| 24 | |
| 25 // GetBrokerServices: the current implementation relies on a shared section | |
| 26 // that is created by the broker and opened by the target. | |
| 27 BrokerServices* SandboxFactory::GetBrokerServices() { | |
| 28 // Can't be the broker if the shared section is open. | |
| 29 if (NULL != g_shared_section) { | |
| 30 return NULL; | |
| 31 } | |
| 32 // If the shared section does not exist we are the broker, then create | |
| 33 // the broker object. | |
| 34 s_is_broker = true; | |
| 35 return BrokerServicesBase::GetInstance(); | |
| 36 } | |
| 37 | |
| 38 // GetTargetServices implementation must follow the same technique as the | |
| 39 // GetBrokerServices, but in this case the logic is the opposite. | |
| 40 TargetServices* SandboxFactory::GetTargetServices() { | |
| 41 // Can't be the target if the section handle is not valid. | |
| 42 if (NULL == g_shared_section) { | |
| 43 return NULL; | |
| 44 } | |
| 45 // We are the target | |
| 46 s_is_broker = false; | |
| 47 // Creates and returns the target services implementation. | |
| 48 return TargetServicesBase::GetInstance(); | |
| 49 } | |
| 50 | |
| 51 } // namespace sandbox | |
| OLD | NEW |