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

Unified Diff: chrome/renderer/nacl_desc_wrapper_chrome.cc

Issue 969006: Add the descriptor support needed for Pepper in a way that does... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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 | « chrome/chrome_renderer.gypi ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/nacl_desc_wrapper_chrome.cc
===================================================================
--- chrome/renderer/nacl_desc_wrapper_chrome.cc (revision 0)
+++ chrome/renderer/nacl_desc_wrapper_chrome.cc (revision 0)
@@ -0,0 +1,71 @@
+// Copyright (c) 2010 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 "base/shared_memory.h"
+#include "base/sync_socket.h"
+#include "chrome/common/transport_dib.h"
+#include "native_client/src/trusted/desc/nacl_desc_base.h"
+#include "native_client/src/trusted/desc/nacl_desc_sync_socket.h"
+#include "native_client/src/trusted/desc/nacl_desc_wrapper.h"
+
+namespace nacl {
+
+DescWrapper* DescWrapperFactory::ImportPepperSharedMemory(intptr_t shm_int,
+ size_t size) {
+ base::SharedMemory* shm = reinterpret_cast<base::SharedMemory*>(shm_int);
+#if defined(OS_LINUX) || defined(OS_MACOSX)
+ return ImportShmHandle(shm->handle().fd, size);
+#elif defined(OS_WIN)
+ return ImportShmHandle(shm->handle(), size);
+#else
+# error "What platform?"
+#endif
+}
+
+DescWrapper* DescWrapperFactory::ImportPepper2DSharedMemory(intptr_t shm_int) {
+ TransportDIB* dib = reinterpret_cast<TransportDIB*>(shm_int);
+#if defined(OS_LINUX)
+ // TransportDIBs use SysV (X) shared memory on Linux.
+ return ImportSysvShm(dib->handle(), dib->size());
+#elif defined(OS_MACOSX)
+ // TransportDIBs use mmap shared memory on OSX.
+ return ImportShmHandle(dib->handle().fd, dib->size());
+#elif defined(OS_WIN)
+ // TransportDIBs use MapViewOfFile shared memory on Windows.
+ return ImportShmHandle(dib->handle(), dib->size());
+#else
+# error "What platform?"
+#endif
+}
+
+DescWrapper* DescWrapperFactory::ImportPepperSync(intptr_t sync_int) {
+ base::SyncSocket* sock = reinterpret_cast<base::SyncSocket*>(sync_int);
+ struct NaClDescSyncSocket* ss_desc = NULL;
+ DescWrapper* wrapper = NULL;
+
+ ss_desc = static_cast<NaClDescSyncSocket*>(
+ calloc(1, sizeof(*ss_desc)));
+ if (NULL == ss_desc) {
+ // TODO(sehr): Gotos are awful. Add a scoped_ptr variant that
+ // invokes NaClDescSafeUnref.
+ goto cleanup;
+ }
+ if (!NaClDescSyncSocketCtor(ss_desc, sock->handle())) {
+ free(ss_desc);
+ ss_desc = NULL;
+ goto cleanup;
+ }
+ wrapper = new DescWrapper(common_data_, &ss_desc->base);
+ if (NULL == wrapper) {
+ goto cleanup;
+ }
+ ss_desc = NULL; // DescWrapper takes ownership of ss_desc.
+ return wrapper;
+
+ cleanup:
+ NaClDescSafeUnref(&ss_desc->base);
+ return NULL;
+}
+
+} // namespace nacl
Property changes on: chrome\renderer\nacl_desc_wrapper_chrome.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « chrome/chrome_renderer.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698