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

Unified Diff: o3d/gpu_plugin/system_services/shared_memory.cc

Issue 194049: Implemented shared memory as an NPObject. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 3 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
Index: o3d/gpu_plugin/system_services/shared_memory.cc
===================================================================
--- o3d/gpu_plugin/system_services/shared_memory.cc (revision 0)
+++ o3d/gpu_plugin/system_services/shared_memory.cc (revision 0)
@@ -0,0 +1,65 @@
+// Copyright (c) 2006-2008 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 "o3d/gpu_plugin/system_services/shared_memory.h"
+
+namespace o3d {
+namespace gpu_plugin {
+
+SharedMemory::SharedMemory(NPP npp)
+ : npp_(npp),
+ shared_memory_(NULL) {
Ken Russell (Google) 2009/09/09 01:32:54 Where are the NPObject fields (_class and referenc
apatrick 2009/09/09 02:10:18 Shared memory objects are created through NPN_Crea
+ handle = NULL;
+ ptr = NULL;
+ size = 0;
+}
+
+SharedMemory::~SharedMemory() {
+ if (shared_memory_) {
+ delete shared_memory_;
+ }
+}
+
+void SharedMemory::Initialize(base::SharedMemory* shared_memory, int32 size) {
+ DCHECK(shared_memory);
+ shared_memory_ = shared_memory;
+ this->handle = shared_memory->handle();
+ this->size = size;
+}
+
+bool SharedMemory::Initialize(int32 size) {
+ if (size < 0)
+ return false;
+
+ if (shared_memory_)
+ return false;
+
+ shared_memory_ = new base::SharedMemory();
+ if (!shared_memory_->Create(std::wstring(), false, false, size)) {
+ delete shared_memory_;
+ shared_memory_ = NULL;
+ return false;
+ }
+
+ handle = shared_memory_->handle();
+ this->size = size;
+ return true;
+}
+
+bool SharedMemory::Map() {
+ if (!shared_memory_)
+ return false;
+
+ if (!shared_memory_->memory()) {
+ if (!shared_memory_->Map(shared_memory_->max_size()))
+ return false;
+
+ ptr = shared_memory_->memory();
+ }
+
+ return true;
+}
+
+} // namespace gpu_plugin
+} // namespace o3d

Powered by Google App Engine
This is Rietveld 408576698