| 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 #ifndef PPAPI_SHARED_IMPL_VAR_TRACKER_H_ | 5 #ifndef PPAPI_SHARED_IMPL_VAR_TRACKER_H_ |
| 6 #define PPAPI_SHARED_IMPL_VAR_TRACKER_H_ | 6 #define PPAPI_SHARED_IMPL_VAR_TRACKER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 bool ReleaseVar(int32 var_id); | 73 bool ReleaseVar(int32 var_id); |
| 74 bool ReleaseVar(const PP_Var& var); | 74 bool ReleaseVar(const PP_Var& var); |
| 75 | 75 |
| 76 // Create a new array buffer of size |size_in_bytes|. Return a PP_Var that | 76 // Create a new array buffer of size |size_in_bytes|. Return a PP_Var that |
| 77 // that references it and has an initial reference-count of 1. | 77 // that references it and has an initial reference-count of 1. |
| 78 PP_Var MakeArrayBufferPPVar(uint32 size_in_bytes); | 78 PP_Var MakeArrayBufferPPVar(uint32 size_in_bytes); |
| 79 // Same as above, but copy the contents of |data| in to the new array buffer. | 79 // Same as above, but copy the contents of |data| in to the new array buffer. |
| 80 PP_Var MakeArrayBufferPPVar(uint32 size_in_bytes, const void* data); | 80 PP_Var MakeArrayBufferPPVar(uint32 size_in_bytes, const void* data); |
| 81 // Same as above, but copy the contents of the shared memory in |h| | 81 // Same as above, but copy the contents of the shared memory in |h| |
| 82 // into the new array buffer. | 82 // into the new array buffer. |
| 83 PP_Var MakeArrayBufferPPVar(uint32 size_in_bytes, | 83 PP_Var MakeArrayBufferPPVar(uint32 size_in_bytes, base::SharedMemoryHandle h); |
| 84 base::SharedMemoryHandle h); | |
| 85 | 84 |
| 86 // Create an ArrayBuffer and copy the contents of |data| in to it. The | 85 // Create an ArrayBuffer and copy the contents of |data| in to it. The |
| 87 // returned object has 0 reference count in the tracker, and like all | 86 // returned object has 0 reference count in the tracker, and like all |
| 88 // RefCounted objects, has a 0 initial internal reference count. (You should | 87 // RefCounted objects, has a 0 initial internal reference count. (You should |
| 89 // usually immediately put this in a scoped_refptr). | 88 // usually immediately put this in a scoped_refptr). |
| 90 ArrayBufferVar* MakeArrayBufferVar(uint32 size_in_bytes, const void* data); | 89 ArrayBufferVar* MakeArrayBufferVar(uint32 size_in_bytes, const void* data); |
| 91 | 90 |
| 92 // Creates a new resource var from a resource creation message. Returns a | 91 // Creates a new resource var from a resource creation message. Returns a |
| 93 // PP_Var that references a new PP_Resource, both with an initial reference | 92 // PP_Var that references a new PP_Resource, both with an initial reference |
| 94 // count of 1. On the host side, |creation_message| is ignored, and an empty | 93 // count of 1. On the host side, |creation_message| is ignored, and an empty |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 // Returns an "id" for a shared memory handle that can be safely sent between | 135 // Returns an "id" for a shared memory handle that can be safely sent between |
| 137 // the host and plugin, and resolved back into the original handle on the | 136 // the host and plugin, and resolved back into the original handle on the |
| 138 // host. Not implemented on the plugin side. | 137 // host. Not implemented on the plugin side. |
| 139 virtual int TrackSharedMemoryHandle(PP_Instance instance, | 138 virtual int TrackSharedMemoryHandle(PP_Instance instance, |
| 140 base::SharedMemoryHandle handle, | 139 base::SharedMemoryHandle handle, |
| 141 uint32 size_in_bytes) = 0; | 140 uint32 size_in_bytes) = 0; |
| 142 | 141 |
| 143 // Resolves an "id" generated by TrackSharedMemoryHandle back into | 142 // Resolves an "id" generated by TrackSharedMemoryHandle back into |
| 144 // a SharedMemory handle and its size on the host. | 143 // a SharedMemory handle and its size on the host. |
| 145 // Not implemented on the plugin side. | 144 // Not implemented on the plugin side. |
| 146 virtual bool StopTrackingSharedMemoryHandle( | 145 virtual bool StopTrackingSharedMemoryHandle(int id, |
| 147 int id, | 146 PP_Instance instance, |
| 148 PP_Instance instance, | 147 base::SharedMemoryHandle* handle, |
| 149 base::SharedMemoryHandle *handle, | 148 uint32* size_in_bytes) = 0; |
| 150 uint32* size_in_bytes) = 0; | |
| 151 | 149 |
| 152 protected: | 150 protected: |
| 153 struct PPAPI_SHARED_EXPORT VarInfo { | 151 struct PPAPI_SHARED_EXPORT VarInfo { |
| 154 VarInfo(); | 152 VarInfo(); |
| 155 VarInfo(Var* v, int input_ref_count); | 153 VarInfo(Var* v, int input_ref_count); |
| 156 | 154 |
| 157 scoped_refptr<Var> var; | 155 scoped_refptr<Var> var; |
| 158 | 156 |
| 159 // Explicit reference count. This value is affected by the renderer calling | 157 // Explicit reference count. This value is affected by the renderer calling |
| 160 // AddRef and Release. A nonzero value here is represented by a single | 158 // AddRef and Release. A nonzero value here is represented by a single |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 // other threads (especially the IO thread). On the plugin side, the tracker | 233 // other threads (especially the IO thread). On the plugin side, the tracker |
| 236 // is protected by the proxy lock and is thread-safe, so this will be NULL. | 234 // is protected by the proxy lock and is thread-safe, so this will be NULL. |
| 237 scoped_ptr<base::ThreadChecker> thread_checker_; | 235 scoped_ptr<base::ThreadChecker> thread_checker_; |
| 238 | 236 |
| 239 DISALLOW_COPY_AND_ASSIGN(VarTracker); | 237 DISALLOW_COPY_AND_ASSIGN(VarTracker); |
| 240 }; | 238 }; |
| 241 | 239 |
| 242 } // namespace ppapi | 240 } // namespace ppapi |
| 243 | 241 |
| 244 #endif // PPAPI_SHARED_IMPL_VAR_TRACKER_H_ | 242 #endif // PPAPI_SHARED_IMPL_VAR_TRACKER_H_ |
| OLD | NEW |