Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(255)

Side by Side Diff: chrome/renderer/chrome_ppapi_interfaces.cc

Issue 8591035: Clean up disable_nacl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/chrome_browser.gypi ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/renderer/chrome_ppapi_interfaces.h" 5 #include "chrome/renderer/chrome_ppapi_interfaces.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/rand_util_c.h" 9 #include "base/rand_util_c.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "chrome/common/render_messages.h" 11 #include "chrome/common/render_messages.h"
12 #include "chrome/renderer/chrome_ppb_pdf_impl.h" 12 #include "chrome/renderer/chrome_ppb_pdf_impl.h"
13 #include "content/public/common/content_switches.h" 13 #include "content/public/common/content_switches.h"
14 #include "content/public/renderer/render_thread.h" 14 #include "content/public/renderer/render_thread.h"
15 #include "ppapi/c/private/ppb_nacl_private.h" 15 #include "ppapi/c/private/ppb_nacl_private.h"
16 #include "ppapi/c/private/ppb_pdf.h" 16 #include "ppapi/c/private/ppb_pdf.h"
17 #include "webkit/plugins/ppapi/ppapi_interface_factory.h" 17 #include "webkit/plugins/ppapi/ppapi_interface_factory.h"
18 18
19 #if !defined(DISABLE_NACL) 19 #if !defined(DISABLE_NACL)
20 #include "native_client/src/shared/imc/nacl_imc.h" 20 #include "native_client/src/shared/imc/nacl_imc.h"
21 #include "ppapi/native_client/src/trusted/plugin/nacl_entry_points.h" 21 #include "ppapi/native_client/src/trusted/plugin/nacl_entry_points.h"
22 #endif 22 #endif
23 23
24 using content::RenderThread; 24 using content::RenderThread;
25 25
26 namespace chrome { 26 namespace chrome {
27 27
28 #if !defined(DISABLE_NACL)
28 // Launch NaCl's sel_ldr process. 29 // Launch NaCl's sel_ldr process.
29 bool LaunchSelLdr(const char* alleged_url, int socket_count, 30 bool LaunchSelLdr(const char* alleged_url, int socket_count,
30 void* imc_handles, void* nacl_process_handle, 31 void* imc_handles, void* nacl_process_handle,
31 int* nacl_process_id) { 32 int* nacl_process_id) {
32 #if !defined(DISABLE_NACL)
33 std::vector<nacl::FileDescriptor> sockets; 33 std::vector<nacl::FileDescriptor> sockets;
34 base::ProcessHandle nacl_process; 34 base::ProcessHandle nacl_process;
35 if (!RenderThread::Get()->Send( 35 if (!RenderThread::Get()->Send(
36 new ChromeViewHostMsg_LaunchNaCl( 36 new ChromeViewHostMsg_LaunchNaCl(
37 ASCIIToWide(alleged_url), 37 ASCIIToWide(alleged_url),
38 socket_count, 38 socket_count,
39 &sockets, 39 &sockets,
40 &nacl_process, 40 &nacl_process,
41 reinterpret_cast<base::ProcessId*>(nacl_process_id)))) { 41 reinterpret_cast<base::ProcessId*>(nacl_process_id)))) {
42 return false; 42 return false;
43 } 43 }
44 CHECK(static_cast<int>(sockets.size()) == socket_count); 44 CHECK(static_cast<int>(sockets.size()) == socket_count);
45 for (int i = 0; i < socket_count; i++) { 45 for (int i = 0; i < socket_count; i++) {
46 static_cast<nacl::Handle*>(imc_handles)[i] = 46 static_cast<nacl::Handle*>(imc_handles)[i] =
47 nacl::ToNativeHandle(sockets[i]); 47 nacl::ToNativeHandle(sockets[i]);
48 } 48 }
49 *static_cast<nacl::Handle*>(nacl_process_handle) = nacl_process; 49 *static_cast<nacl::Handle*>(nacl_process_handle) = nacl_process;
50 return true; 50 return true;
51 #else
52 return false;
53 #endif
54 } 51 }
55 52
56 int UrandomFD(void) { 53 int UrandomFD(void) {
57 #if defined(OS_POSIX) 54 #if defined(OS_POSIX)
58 return GetUrandomFD(); 55 return GetUrandomFD();
59 #else 56 #else
60 return 0; 57 return 0;
61 #endif 58 #endif
62 } 59 }
63 60
64 bool Are3DInterfacesDisabled() { 61 bool Are3DInterfacesDisabled() {
65 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisable3DAPIs); 62 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisable3DAPIs);
66 } 63 }
67 64
68 const PPB_NaCl_Private ppb_nacl = { 65 const PPB_NaCl_Private ppb_nacl = {
69 &LaunchSelLdr, 66 &LaunchSelLdr,
70 &UrandomFD, 67 &UrandomFD,
71 &Are3DInterfacesDisabled, 68 &Are3DInterfacesDisabled,
72 }; 69 };
73 70
74 class PPB_NaCl_Impl { 71 class PPB_NaCl_Impl {
75 public: 72 public:
76 // Returns a pointer to the interface implementing PPB_NaCl_Private that is 73 // Returns a pointer to the interface implementing PPB_NaCl_Private that is
77 // exposed to the plugin. 74 // exposed to the plugin.
78 static const PPB_NaCl_Private* GetInterface() { 75 static const PPB_NaCl_Private* GetInterface() {
79 return &ppb_nacl; 76 return &ppb_nacl;
80 } 77 }
81 }; 78 };
79 #endif // DISABLE_NACL
82 80
83 const void* ChromePPAPIInterfaceFactory(const std::string& interface_name) { 81 const void* ChromePPAPIInterfaceFactory(const std::string& interface_name) {
82 #if !defined(DISABLE_NACL)
84 if (interface_name == PPB_NACL_PRIVATE_INTERFACE) 83 if (interface_name == PPB_NACL_PRIVATE_INTERFACE)
85 return chrome::PPB_NaCl_Impl::GetInterface(); 84 return chrome::PPB_NaCl_Impl::GetInterface();
85 #endif // DISABLE_NACL
86 if (interface_name == PPB_PDF_INTERFACE) 86 if (interface_name == PPB_PDF_INTERFACE)
87 return chrome::PPB_PDF_Impl::GetInterface(); 87 return chrome::PPB_PDF_Impl::GetInterface();
88 return NULL; 88 return NULL;
89 } 89 }
90 90
91 } // namespace chrome 91 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/chrome_browser.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698