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" |
11 #include "base/containers/hash_tables.h" | 11 #include "base/containers/hash_tables.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/shared_memory.h" | 14 #include "base/memory/shared_memory.h" |
15 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
16 #include "ppapi/c/pp_instance.h" | 16 #include "ppapi/c/pp_instance.h" |
17 #include "ppapi/c/pp_module.h" | 17 #include "ppapi/c/pp_module.h" |
18 #include "ppapi/c/pp_resource.h" | 18 #include "ppapi/c/pp_resource.h" |
19 #include "ppapi/c/pp_var.h" | 19 #include "ppapi/c/pp_var.h" |
20 #include "ppapi/shared_impl/host_resource.h" | 20 #include "ppapi/shared_impl/host_resource.h" |
21 #include "ppapi/shared_impl/ppapi_shared_export.h" | 21 #include "ppapi/shared_impl/ppapi_shared_export.h" |
22 #include "ppapi/shared_impl/var.h" | 22 #include "ppapi/shared_impl/var.h" |
23 | 23 |
| 24 namespace IPC { |
| 25 class Message; |
| 26 } // namespace IPC |
| 27 |
24 namespace ppapi { | 28 namespace ppapi { |
25 | 29 |
26 class ArrayBufferVar; | 30 class ArrayBufferVar; |
27 | 31 |
28 // Tracks non-POD (refcounted) var objects held by a plugin. | 32 // Tracks non-POD (refcounted) var objects held by a plugin. |
29 // | 33 // |
30 // The tricky part is the concept of a "tracked object". These are only | 34 // The tricky part is the concept of a "tracked object". These are only |
31 // necessary in the plugin side of the proxy when running out of process. A | 35 // necessary in the plugin side of the proxy when running out of process. A |
32 // tracked object is one that the plugin is aware of, but doesn't hold a | 36 // tracked object is one that the plugin is aware of, but doesn't hold a |
33 // reference to. This will happen when the plugin is passed an object as an | 37 // reference to. This will happen when the plugin is passed an object as an |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 // into the new array buffer. | 82 // into the new array buffer. |
79 PP_Var MakeArrayBufferPPVar(uint32 size_in_bytes, | 83 PP_Var MakeArrayBufferPPVar(uint32 size_in_bytes, |
80 base::SharedMemoryHandle h); | 84 base::SharedMemoryHandle h); |
81 | 85 |
82 // Create an ArrayBuffer and copy the contents of |data| in to it. The | 86 // Create an ArrayBuffer and copy the contents of |data| in to it. The |
83 // returned object has 0 reference count in the tracker, and like all | 87 // returned object has 0 reference count in the tracker, and like all |
84 // RefCounted objects, has a 0 initial internal reference count. (You should | 88 // RefCounted objects, has a 0 initial internal reference count. (You should |
85 // usually immediately put this in a scoped_refptr). | 89 // usually immediately put this in a scoped_refptr). |
86 ArrayBufferVar* MakeArrayBufferVar(uint32 size_in_bytes, const void* data); | 90 ArrayBufferVar* MakeArrayBufferVar(uint32 size_in_bytes, const void* data); |
87 | 91 |
| 92 // 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 |
| 94 // count of 1. If |creation_message| is empty, returns a valid, empty resource |
| 95 // var. On the host side, |creation_message| is ignored, and an empty resource |
| 96 // var is always returned. |
| 97 virtual PP_Var MakeResourcePPVar(const IPC::Message& creation_message, |
| 98 int pending_renderer_id, |
| 99 int pending_browser_id, |
| 100 PP_Instance instance) = 0; |
| 101 |
88 // Creates a new resource var that points to a given resource ID. Returns a | 102 // Creates a new resource var that points to a given resource ID. Returns a |
89 // PP_Var that references it and has an initial reference count of 1. | 103 // PP_Var that references it and has an initial reference count of 1. |
90 // If |pp_resource| is 0, returns a valid, empty resource var. On the plugin | 104 // If |pp_resource| is 0, returns a valid, empty resource var. On the plugin |
91 // side (where it is possible to tell which resources exist), if |pp_resource| | 105 // side (where it is possible to tell which resources exist), if |pp_resource| |
92 // does not exist, returns a null var. | 106 // does not exist, returns a null var. |
93 PP_Var MakeResourcePPVar(PP_Resource pp_resource); | 107 PP_Var MakeResourcePPVar(PP_Resource pp_resource); |
94 | 108 |
95 // Creates a new resource var that points to a given resource ID. This is | 109 // Creates a new resource var that points to a given resource ID. This is |
96 // implemented by the host and plugin tracker separately, because the plugin | 110 // implemented by the host and plugin tracker separately, because the plugin |
97 // keeps a reference to the resource, and the host does not. | 111 // keeps a reference to the resource, and the host does not. |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 // other threads (especially the IO thread). On the plugin side, the tracker | 235 // other threads (especially the IO thread). On the plugin side, the tracker |
222 // is protected by the proxy lock and is thread-safe, so this will be NULL. | 236 // is protected by the proxy lock and is thread-safe, so this will be NULL. |
223 scoped_ptr<base::ThreadChecker> thread_checker_; | 237 scoped_ptr<base::ThreadChecker> thread_checker_; |
224 | 238 |
225 DISALLOW_COPY_AND_ASSIGN(VarTracker); | 239 DISALLOW_COPY_AND_ASSIGN(VarTracker); |
226 }; | 240 }; |
227 | 241 |
228 } // namespace ppapi | 242 } // namespace ppapi |
229 | 243 |
230 #endif // PPAPI_SHARED_IMPL_VAR_TRACKER_H_ | 244 #endif // PPAPI_SHARED_IMPL_VAR_TRACKER_H_ |
OLD | NEW |