diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-05 05:04:55 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-05 05:04:55 +0000 |
commit | 219b9b974fe4adf8069db2cb2d611c07f14798cc (patch) | |
tree | 2e7d3e8e92ecb7dea2ac0485a43c9feb2e13335c /chrome/renderer/chrome_ppapi_interfaces.cc | |
parent | 758eb9cda8f50d5d561aaf4a319d4f4f217b465a (diff) | |
download | chromium_src-219b9b974fe4adf8069db2cb2d611c07f14798cc.zip chromium_src-219b9b974fe4adf8069db2cb2d611c07f14798cc.tar.gz chromium_src-219b9b974fe4adf8069db2cb2d611c07f14798cc.tar.bz2 |
Reduce one of the implicit dependencies of src\content on chrome\renderer by moving the custom nacl
ppapi interface PPB_NACL_PRIVATE_INTERFACE to chrome\renderer. This interface is returned via a factory
which is registered in the renderer process, when the render thread is created.
This CL is intended to eventually help build src\content as an independent dll.
I also changed the ChromeContentRendererClient and ChromeContentPluginClient instances to be lazy instances
to fix some asserts i was seeing while running browser_tests.
BUG=82454
Review URL: http://codereview.chromium.org/7066069
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87943 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/chrome_ppapi_interfaces.cc')
-rw-r--r-- | chrome/renderer/chrome_ppapi_interfaces.cc | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/chrome/renderer/chrome_ppapi_interfaces.cc b/chrome/renderer/chrome_ppapi_interfaces.cc new file mode 100644 index 0000000..e57794c --- /dev/null +++ b/chrome/renderer/chrome_ppapi_interfaces.cc @@ -0,0 +1,82 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/renderer/chrome_ppapi_interfaces.h" + +#include "base/logging.h" +#include "base/rand_util_c.h" +#include "base/utf_string_conversions.h" +#include "chrome/common/render_messages.h" +#include "content/renderer/render_thread.h" +#include "ppapi/c/private/ppb_nacl_private.h" +#include "webkit/plugins/ppapi/ppapi_interface_factory.h" + +#if !defined(DISABLE_NACL) +#include "native_client/src/shared/imc/nacl_imc.h" +#include "native_client/src/trusted/plugin/nacl_entry_points.h" +#endif + +namespace chrome { + +// Launch NaCl's sel_ldr process. +bool LaunchSelLdr(const char* alleged_url, int socket_count, + void* imc_handles, void* nacl_process_handle, + int* nacl_process_id) { +#if !defined(DISABLE_NACL) + std::vector<nacl::FileDescriptor> sockets; + base::ProcessHandle nacl_process; + if (!RenderThread::current()->Send( + new ViewHostMsg_LaunchNaCl( + ASCIIToWide(alleged_url), + socket_count, + &sockets, + &nacl_process, + reinterpret_cast<base::ProcessId*>(nacl_process_id)))) { + return false; + } + CHECK(static_cast<int>(sockets.size()) == socket_count); + for (int i = 0; i < socket_count; i++) { + static_cast<nacl::Handle*>(imc_handles)[i] = + nacl::ToNativeHandle(sockets[i]); + } + *static_cast<nacl::Handle*>(nacl_process_handle) = nacl_process; + return true; +#else + return false; +#endif +} + +int UrandomFD(void) { +#if defined(OS_POSIX) + return GetUrandomFD(); +#else + return 0; +#endif +} + +const PPB_NaCl_Private ppb_nacl = { + &LaunchSelLdr, + &UrandomFD, +}; + +const void* ChromePPAPIInterfaceFactory(const std::string& interface_name) { + if (interface_name == PPB_NACL_PRIVATE_INTERFACE) + return &ppb_nacl; + return NULL; +} + +void InitializePPAPI() { + webkit::ppapi::PpapiInterfaceFactoryManager* factory_manager = + webkit::ppapi::PpapiInterfaceFactoryManager::GetInstance(); + factory_manager->RegisterFactory(ChromePPAPIInterfaceFactory); +} + +void UninitializePPAPI() { + webkit::ppapi::PpapiInterfaceFactoryManager* factory_manager = + webkit::ppapi::PpapiInterfaceFactoryManager::GetInstance(); + factory_manager->UnregisterFactory(ChromePPAPIInterfaceFactory); +} + +} // namespace chrome + |