| 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 CONTENT_RENDERER_PEPPER_HOST_VAR_TRACKER_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_HOST_VAR_TRACKER_H_ |
| 6 #define CONTENT_RENDERER_PEPPER_HOST_VAR_TRACKER_H_ | 6 #define CONTENT_RENDERER_PEPPER_HOST_VAR_TRACKER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> |
| 9 |
| 8 #include <map> | 10 #include <map> |
| 9 | 11 |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 12 #include "base/containers/hash_tables.h" | 13 #include "base/containers/hash_tables.h" |
| 14 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 14 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
| 15 #include "ppapi/c/pp_instance.h" | 17 #include "ppapi/c/pp_instance.h" |
| 16 #include "ppapi/shared_impl/host_resource.h" | 18 #include "ppapi/shared_impl/host_resource.h" |
| 17 #include "ppapi/shared_impl/resource_tracker.h" | 19 #include "ppapi/shared_impl/resource_tracker.h" |
| 18 #include "ppapi/shared_impl/var_tracker.h" | 20 #include "ppapi/shared_impl/var_tracker.h" |
| 19 #include "v8/include/v8.h" | 21 #include "v8/include/v8.h" |
| 20 | 22 |
| 21 namespace ppapi { | 23 namespace ppapi { |
| 22 class ArrayBufferVar; | 24 class ArrayBufferVar; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 46 // VarTracker public implementation. | 48 // VarTracker public implementation. |
| 47 PP_Var MakeResourcePPVarFromMessage(PP_Instance instance, | 49 PP_Var MakeResourcePPVarFromMessage(PP_Instance instance, |
| 48 const IPC::Message& creation_message, | 50 const IPC::Message& creation_message, |
| 49 int pending_renderer_id, | 51 int pending_renderer_id, |
| 50 int pending_browser_id) override; | 52 int pending_browser_id) override; |
| 51 ppapi::ResourceVar* MakeResourceVar(PP_Resource pp_resource) override; | 53 ppapi::ResourceVar* MakeResourceVar(PP_Resource pp_resource) override; |
| 52 void DidDeleteInstance(PP_Instance pp_instance) override; | 54 void DidDeleteInstance(PP_Instance pp_instance) override; |
| 53 | 55 |
| 54 int TrackSharedMemoryHandle(PP_Instance instance, | 56 int TrackSharedMemoryHandle(PP_Instance instance, |
| 55 base::SharedMemoryHandle file, | 57 base::SharedMemoryHandle file, |
| 56 uint32 size_in_bytes) override; | 58 uint32_t size_in_bytes) override; |
| 57 bool StopTrackingSharedMemoryHandle(int id, | 59 bool StopTrackingSharedMemoryHandle(int id, |
| 58 PP_Instance instance, | 60 PP_Instance instance, |
| 59 base::SharedMemoryHandle* handle, | 61 base::SharedMemoryHandle* handle, |
| 60 uint32* size_in_bytes) override; | 62 uint32_t* size_in_bytes) override; |
| 61 | 63 |
| 62 private: | 64 private: |
| 63 // VarTracker private implementation. | 65 // VarTracker private implementation. |
| 64 ppapi::ArrayBufferVar* CreateArrayBuffer(uint32 size_in_bytes) override; | 66 ppapi::ArrayBufferVar* CreateArrayBuffer(uint32_t size_in_bytes) override; |
| 65 ppapi::ArrayBufferVar* CreateShmArrayBuffer( | 67 ppapi::ArrayBufferVar* CreateShmArrayBuffer( |
| 66 uint32 size_in_bytes, | 68 uint32_t size_in_bytes, |
| 67 base::SharedMemoryHandle handle) override; | 69 base::SharedMemoryHandle handle) override; |
| 68 | 70 |
| 69 // Clear the reference count of the given object and remove it from | 71 // Clear the reference count of the given object and remove it from |
| 70 // live_vars_. | 72 // live_vars_. |
| 71 void ForceReleaseV8Object(ppapi::V8ObjectVar* object_var); | 73 void ForceReleaseV8Object(ppapi::V8ObjectVar* object_var); |
| 72 | 74 |
| 73 // A non-unique, ordered key for a V8ObjectVar. Contains the hash of the v8 | 75 // A non-unique, ordered key for a V8ObjectVar. Contains the hash of the v8 |
| 74 // and the instance it is associated with. | 76 // and the instance it is associated with. |
| 75 struct V8ObjectVarKey { | 77 struct V8ObjectVarKey { |
| 76 explicit V8ObjectVarKey(ppapi::V8ObjectVar* object_var); | 78 explicit V8ObjectVarKey(ppapi::V8ObjectVar* object_var); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 90 v8::Local<v8::Object> object); | 92 v8::Local<v8::Object> object); |
| 91 | 93 |
| 92 | 94 |
| 93 // A multimap of V8ObjectVarKey -> ObjectMap. | 95 // A multimap of V8ObjectVarKey -> ObjectMap. |
| 94 ObjectMap object_map_; | 96 ObjectMap object_map_; |
| 95 | 97 |
| 96 // Tracks all shared memory handles used for transmitting array buffers. | 98 // Tracks all shared memory handles used for transmitting array buffers. |
| 97 struct SharedMemoryMapEntry { | 99 struct SharedMemoryMapEntry { |
| 98 PP_Instance instance; | 100 PP_Instance instance; |
| 99 base::SharedMemoryHandle handle; | 101 base::SharedMemoryHandle handle; |
| 100 uint32 size_in_bytes; | 102 uint32_t size_in_bytes; |
| 101 }; | 103 }; |
| 102 typedef std::map<int, SharedMemoryMapEntry> SharedMemoryMap; | 104 typedef std::map<int, SharedMemoryMapEntry> SharedMemoryMap; |
| 103 SharedMemoryMap shared_memory_map_; | 105 SharedMemoryMap shared_memory_map_; |
| 104 uint32_t last_shared_memory_map_id_; | 106 uint32_t last_shared_memory_map_id_; |
| 105 | 107 |
| 106 DISALLOW_COPY_AND_ASSIGN(HostVarTracker); | 108 DISALLOW_COPY_AND_ASSIGN(HostVarTracker); |
| 107 }; | 109 }; |
| 108 | 110 |
| 109 } // namespace content | 111 } // namespace content |
| 110 | 112 |
| 111 #endif // CONTENT_RENDERER_PEPPER_HOST_VAR_TRACKER_H_ | 113 #endif // CONTENT_RENDERER_PEPPER_HOST_VAR_TRACKER_H_ |
| OLD | NEW |