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

Unified Diff: ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_image_data_rpc_server.cc

Issue 9677061: Pass dup'd handles to nacl::DescWrapper instead of bumping the ref count. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_graphics_3d_rpc_server.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_image_data_rpc_server.cc
===================================================================
--- ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_image_data_rpc_server.cc (revision 126418)
+++ ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_image_data_rpc_server.cc (working copy)
@@ -7,6 +7,7 @@
#include "native_client/src/include/nacl_macros.h"
#include "native_client/src/include/nacl_scoped_ptr.h"
#include "native_client/src/include/portability.h"
+#include "native_client/src/shared/imc/nacl_imc.h"
#include "native_client/src/shared/ppapi_proxy/browser_globals.h"
#include "native_client/src/shared/ppapi_proxy/utility.h"
#include "native_client/src/trusted/desc/nacl_desc_wrapper.h"
@@ -118,47 +119,37 @@
return;
}
*shm = desc_wrapper->desc();
- *shm_size = -1;
+ *shm_size = 0;
*success = PP_FALSE;
PP_Bool pp_success =
ppapi_proxy::PPBImageDataInterface()->Describe(
resource, reinterpret_cast<struct PP_ImageDataDesc*>(desc));
if (pp_success == PP_TRUE) {
- int native_handle = 0;
+ const int kInvalidIntHandle = int(nacl::kInvalidHandle);
+ int native_handle = kInvalidIntHandle;
uint32_t native_size = 0;
if (ppapi_proxy::PPBImageDataTrustedInterface()->GetSharedMemory(
static_cast<PP_Resource>(resource),
&native_handle,
&native_size) == PP_OK) {
-
+ if (kInvalidIntHandle != native_handle) {
#if NACL_LINUX
- desc_wrapper.reset(factory.ImportSysvShm(native_handle, native_size));
- *shm = desc_wrapper->desc();
- *shm_size = native_size;
- *success = PP_TRUE;
-#elif NACL_WINDOWS
- HANDLE dup_handle;
- if (DuplicateHandle(GetCurrentProcess(),
- reinterpret_cast<NaClHandle>(native_handle),
- GetCurrentProcess(),
- &dup_handle,
- 0,
- FALSE,
- DUPLICATE_SAME_ACCESS)) {
- desc_wrapper.reset(factory.ImportShmHandle(dup_handle, native_size));
+ desc_wrapper.reset(factory.ImportSysvShm(native_handle, native_size));
*shm = desc_wrapper->desc();
*shm_size = native_size;
*success = PP_TRUE;
- }
#else
- int dup_handle = dup(static_cast<int>(native_handle));
- if (dup_handle >= 0) {
- desc_wrapper.reset(factory.ImportShmHandle(dup_handle, native_size));
- *shm = desc_wrapper->desc();
- *shm_size = native_size;
- *success = PP_TRUE;
- }
+ NaClHandle nacl_handle = NaClHandle(native_handle);
+ NaClHandle nacl_dup_handle = NaClDuplicateNaClHandle(nacl_handle);
+ if (nacl::kInvalidHandle != nacl_dup_handle) {
+ desc_wrapper.reset(
+ factory.ImportShmHandle(nacl_dup_handle, native_size));
+ *shm = desc_wrapper->desc();
+ *shm_size = native_size;
+ *success = PP_TRUE;
+ }
#endif
+ }
}
}
DebugPrintf("PPB_ImageData::Describe: resource=%"NACL_PRId32", "
« no previous file with comments | « ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_graphics_3d_rpc_server.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698