OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef O3D_GPU_PLUGIN_SYSTEM_SERVICES_SHARED_MEMORY_H_ |
| 6 #define O3D_GPU_PLUGIN_SYSTEM_SERVICES_SHARED_MEMORY_H_ |
| 7 |
| 8 #include "base/shared_memory.h" |
| 9 #include "o3d/gpu_plugin/np_utils/default_np_object.h" |
| 10 #include "o3d/gpu_plugin/np_utils/np_dispatcher.h" |
| 11 #include "o3d/gpu_plugin/np_utils/np_object_pointer.h" |
| 12 #include "o3d/gpu_plugin/system_services/shared_memory_public.h" |
| 13 #include "third_party/npapi/bindings/npruntime.h" |
| 14 |
| 15 namespace o3d { |
| 16 namespace gpu_plugin { |
| 17 |
| 18 // An NPObject holding a shared memory handle. |
| 19 class SharedMemory : public DefaultNPObject<CHRSharedMemory> { |
| 20 public: |
| 21 explicit SharedMemory(NPP npp); |
| 22 ~SharedMemory(); |
| 23 |
| 24 // Initialize from an existing base::SharedMemory. Takes ownership of the |
| 25 // base::SharedMemory. |
| 26 void Initialize(base::SharedMemory* shared_memory, int32 size); |
| 27 |
| 28 virtual bool Initialize(int32 size); |
| 29 |
| 30 virtual int32 GetSize() { |
| 31 return size; |
| 32 } |
| 33 |
| 34 virtual bool Map(); |
| 35 |
| 36 base::SharedMemory* shared_memory() const { |
| 37 return shared_memory_; |
| 38 } |
| 39 |
| 40 NP_UTILS_BEGIN_DISPATCHER_CHAIN(SharedMemory, DefaultNPObject<NPObject>) |
| 41 NP_UTILS_DISPATCHER(Initialize, bool(int32)); |
| 42 NP_UTILS_DISPATCHER(GetSize, int32()) |
| 43 NP_UTILS_DISPATCHER(Map, bool()) |
| 44 NP_UTILS_END_DISPATCHER_CHAIN |
| 45 |
| 46 private: |
| 47 NPP npp_; |
| 48 base::SharedMemory* shared_memory_; |
| 49 DISALLOW_COPY_AND_ASSIGN(SharedMemory); |
| 50 }; |
| 51 |
| 52 } // namespace gpu_plugin |
| 53 } // namespace o3d |
| 54 |
| 55 #endif // O3D_GPU_PLUGIN_SYSTEM_SERVICES_SHARED_MEMORY_H_ |
OLD | NEW |