| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/pepper/ppb_nacl_private_impl.h" | 5 #include "chrome/renderer/pepper/ppb_nacl_private_impl.h" |
| 6 | 6 |
| 7 #ifndef DISABLE_NACL | 7 #ifndef DISABLE_NACL |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 uint32_t options) { | 213 uint32_t options) { |
| 214 #if defined(OS_WIN) | 214 #if defined(OS_WIN) |
| 215 return content::BrokerDuplicateHandle(source_handle, process_id, | 215 return content::BrokerDuplicateHandle(source_handle, process_id, |
| 216 target_handle, desired_access, | 216 target_handle, desired_access, |
| 217 options); | 217 options); |
| 218 #else | 218 #else |
| 219 return 0; | 219 return 0; |
| 220 #endif | 220 #endif |
| 221 } | 221 } |
| 222 | 222 |
| 223 int32_t EnsurePnaclInstalled(PP_Instance instance, |
| 224 PP_CompletionCallback callback) { |
| 225 ppapi::thunk::EnterInstance enter(instance, callback); |
| 226 if (enter.failed()) |
| 227 return enter.retval(); |
| 228 if (!InitializePnaclResourceHost()) |
| 229 return enter.SetResult(PP_ERROR_FAILED); |
| 230 g_pnacl_resource_host.Get()->EnsurePnaclInstalled( |
| 231 instance, |
| 232 enter.callback()); |
| 233 return enter.SetResult(PP_OK_COMPLETIONPENDING); |
| 234 } |
| 235 |
| 223 PP_FileHandle GetReadonlyPnaclFD(const char* filename) { | 236 PP_FileHandle GetReadonlyPnaclFD(const char* filename) { |
| 224 IPC::PlatformFileForTransit out_fd = IPC::InvalidPlatformFileForTransit(); | 237 IPC::PlatformFileForTransit out_fd = IPC::InvalidPlatformFileForTransit(); |
| 225 IPC::Sender* sender = content::RenderThread::Get(); | 238 IPC::Sender* sender = content::RenderThread::Get(); |
| 226 DCHECK(sender); | 239 DCHECK(sender); |
| 227 if (!sender->Send(new NaClHostMsg_GetReadonlyPnaclFD( | 240 if (!sender->Send(new NaClHostMsg_GetReadonlyPnaclFD( |
| 228 std::string(filename), | 241 std::string(filename), |
| 229 &out_fd))) { | 242 &out_fd))) { |
| 230 return base::kInvalidPlatformFileValue; | 243 return base::kInvalidPlatformFileValue; |
| 231 } | 244 } |
| 232 | |
| 233 if (out_fd == IPC::InvalidPlatformFileForTransit()) { | 245 if (out_fd == IPC::InvalidPlatformFileForTransit()) { |
| 234 return base::kInvalidPlatformFileValue; | 246 return base::kInvalidPlatformFileValue; |
| 235 } | 247 } |
| 236 | |
| 237 base::PlatformFile handle = | 248 base::PlatformFile handle = |
| 238 IPC::PlatformFileForTransitToPlatformFile(out_fd); | 249 IPC::PlatformFileForTransitToPlatformFile(out_fd); |
| 239 return handle; | 250 return handle; |
| 240 } | 251 } |
| 241 | 252 |
| 242 PP_FileHandle CreateTemporaryFile(PP_Instance instance) { | 253 PP_FileHandle CreateTemporaryFile(PP_Instance instance) { |
| 243 IPC::PlatformFileForTransit transit_fd = IPC::InvalidPlatformFileForTransit(); | 254 IPC::PlatformFileForTransit transit_fd = IPC::InvalidPlatformFileForTransit(); |
| 244 IPC::Sender* sender = content::RenderThread::Get(); | 255 IPC::Sender* sender = content::RenderThread::Get(); |
| 245 DCHECK(sender); | 256 DCHECK(sender); |
| 246 if (!sender->Send(new NaClHostMsg_NaClCreateTemporaryFile( | 257 if (!sender->Send(new NaClHostMsg_NaClCreateTemporaryFile( |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 IPC::PlatformFileForTransitToPlatformFile(out_fd); | 369 IPC::PlatformFileForTransitToPlatformFile(out_fd); |
| 359 return handle; | 370 return handle; |
| 360 } | 371 } |
| 361 | 372 |
| 362 const PPB_NaCl_Private nacl_interface = { | 373 const PPB_NaCl_Private nacl_interface = { |
| 363 &LaunchSelLdr, | 374 &LaunchSelLdr, |
| 364 &StartPpapiProxy, | 375 &StartPpapiProxy, |
| 365 &UrandomFD, | 376 &UrandomFD, |
| 366 &Are3DInterfacesDisabled, | 377 &Are3DInterfacesDisabled, |
| 367 &BrokerDuplicateHandle, | 378 &BrokerDuplicateHandle, |
| 379 &EnsurePnaclInstalled, |
| 368 &GetReadonlyPnaclFD, | 380 &GetReadonlyPnaclFD, |
| 369 &CreateTemporaryFile, | 381 &CreateTemporaryFile, |
| 370 &GetNexeFd, | 382 &GetNexeFd, |
| 371 &ReportTranslationFinished, | 383 &ReportTranslationFinished, |
| 372 &IsOffTheRecord, | 384 &IsOffTheRecord, |
| 373 &IsPnaclEnabled, | 385 &IsPnaclEnabled, |
| 374 &ReportNaClError, | 386 &ReportNaClError, |
| 375 &OpenNaClExecutable | 387 &OpenNaClExecutable |
| 376 }; | 388 }; |
| 377 | 389 |
| 378 } // namespace | 390 } // namespace |
| 379 | 391 |
| 380 const PPB_NaCl_Private* PPB_NaCl_Private_Impl::GetInterface() { | 392 const PPB_NaCl_Private* PPB_NaCl_Private_Impl::GetInterface() { |
| 381 return &nacl_interface; | 393 return &nacl_interface; |
| 382 } | 394 } |
| 383 | 395 |
| 384 #endif // DISABLE_NACL | 396 #endif // DISABLE_NACL |
| OLD | NEW |