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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
194 uint32_t options) { | 194 uint32_t options) { |
195 #if defined(OS_WIN) | 195 #if defined(OS_WIN) |
196 return content::BrokerDuplicateHandle(source_handle, process_id, | 196 return content::BrokerDuplicateHandle(source_handle, process_id, |
197 target_handle, desired_access, | 197 target_handle, desired_access, |
198 options); | 198 options); |
199 #else | 199 #else |
200 return 0; | 200 return 0; |
201 #endif | 201 #endif |
202 } | 202 } |
203 | 203 |
204 int32_t EnsurePnaclInstalled(PP_Instance instance, | |
205 PP_CompletionCallback callback) { | |
dmichael (off chromium)
2013/08/01 17:33:49
It might be good to DCHECK that you're on the main
jvoung (off chromium)
2013/08/01 23:14:07
Done. (within InitializePnaclResourceHost and shar
| |
206 ppapi::thunk::EnterInstance enter(instance, callback); | |
207 if (enter.failed()) | |
208 return enter.retval(); | |
209 if (!InitializePnaclResourceHost()) | |
210 return enter.SetResult(PP_ERROR_FAILED); | |
211 g_pnacl_resource_host.Get()->EnsurePnaclInstalled( | |
212 instance, | |
213 enter.callback()); | |
214 return enter.SetResult(PP_OK_COMPLETIONPENDING); | |
215 } | |
216 | |
204 PP_FileHandle GetReadonlyPnaclFD(const char* filename) { | 217 PP_FileHandle GetReadonlyPnaclFD(const char* filename) { |
205 IPC::PlatformFileForTransit out_fd = IPC::InvalidPlatformFileForTransit(); | 218 IPC::PlatformFileForTransit out_fd = IPC::InvalidPlatformFileForTransit(); |
206 IPC::Sender* sender = content::RenderThread::Get(); | 219 IPC::Sender* sender = content::RenderThread::Get(); |
207 DCHECK(sender); | 220 DCHECK(sender); |
208 if (!sender->Send(new NaClHostMsg_GetReadonlyPnaclFD( | 221 if (!sender->Send(new NaClHostMsg_GetReadonlyPnaclFD( |
209 std::string(filename), | 222 std::string(filename), |
210 &out_fd))) { | 223 &out_fd))) { |
211 return base::kInvalidPlatformFileValue; | 224 return base::kInvalidPlatformFileValue; |
212 } | 225 } |
213 | |
214 if (out_fd == IPC::InvalidPlatformFileForTransit()) { | 226 if (out_fd == IPC::InvalidPlatformFileForTransit()) { |
215 return base::kInvalidPlatformFileValue; | 227 return base::kInvalidPlatformFileValue; |
216 } | 228 } |
217 | |
218 base::PlatformFile handle = | 229 base::PlatformFile handle = |
219 IPC::PlatformFileForTransitToPlatformFile(out_fd); | 230 IPC::PlatformFileForTransitToPlatformFile(out_fd); |
220 return handle; | 231 return handle; |
221 } | 232 } |
222 | 233 |
223 PP_FileHandle CreateTemporaryFile(PP_Instance instance) { | 234 PP_FileHandle CreateTemporaryFile(PP_Instance instance) { |
224 IPC::PlatformFileForTransit transit_fd = IPC::InvalidPlatformFileForTransit(); | 235 IPC::PlatformFileForTransit transit_fd = IPC::InvalidPlatformFileForTransit(); |
225 IPC::Sender* sender = content::RenderThread::Get(); | 236 IPC::Sender* sender = content::RenderThread::Get(); |
226 DCHECK(sender); | 237 DCHECK(sender); |
227 if (!sender->Send(new NaClHostMsg_NaClCreateTemporaryFile( | 238 if (!sender->Send(new NaClHostMsg_NaClCreateTemporaryFile( |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
339 IPC::PlatformFileForTransitToPlatformFile(out_fd); | 350 IPC::PlatformFileForTransitToPlatformFile(out_fd); |
340 return handle; | 351 return handle; |
341 } | 352 } |
342 | 353 |
343 const PPB_NaCl_Private nacl_interface = { | 354 const PPB_NaCl_Private nacl_interface = { |
344 &LaunchSelLdr, | 355 &LaunchSelLdr, |
345 &StartPpapiProxy, | 356 &StartPpapiProxy, |
346 &UrandomFD, | 357 &UrandomFD, |
347 &Are3DInterfacesDisabled, | 358 &Are3DInterfacesDisabled, |
348 &BrokerDuplicateHandle, | 359 &BrokerDuplicateHandle, |
360 &EnsurePnaclInstalled, | |
349 &GetReadonlyPnaclFD, | 361 &GetReadonlyPnaclFD, |
350 &CreateTemporaryFile, | 362 &CreateTemporaryFile, |
351 &GetNexeFd, | 363 &GetNexeFd, |
352 &ReportTranslationFinished, | 364 &ReportTranslationFinished, |
353 &IsOffTheRecord, | 365 &IsOffTheRecord, |
354 &IsPnaclEnabled, | 366 &IsPnaclEnabled, |
355 &ReportNaClError, | 367 &ReportNaClError, |
356 &OpenNaClExecutable | 368 &OpenNaClExecutable |
357 }; | 369 }; |
358 | 370 |
359 } // namespace | 371 } // namespace |
360 | 372 |
361 const PPB_NaCl_Private* PPB_NaCl_Private_Impl::GetInterface() { | 373 const PPB_NaCl_Private* PPB_NaCl_Private_Impl::GetInterface() { |
362 return &nacl_interface; | 374 return &nacl_interface; |
363 } | 375 } |
364 | 376 |
365 #endif // DISABLE_NACL | 377 #endif // DISABLE_NACL |
OLD | NEW |