OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/hash_tables.h" | 11 #include "base/hash_tables.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 // Create a new array buffer of size |size_in_bytes|. Return a PP_Var that | 61 // Create a new array buffer of size |size_in_bytes|. Return a PP_Var that |
62 // that references it and has an initial reference-count of 1. | 62 // that references it and has an initial reference-count of 1. |
63 PP_Var MakeArrayBufferPPVar(uint32 size_in_bytes); | 63 PP_Var MakeArrayBufferPPVar(uint32 size_in_bytes); |
64 | 64 |
65 // Return a vector containing all PP_Vars that are in the tracker. This is | 65 // Return a vector containing all PP_Vars that are in the tracker. This is |
66 // to help implement PPB_Testing_Dev.GetLiveVars and should generally not be | 66 // to help implement PPB_Testing_Dev.GetLiveVars and should generally not be |
67 // used in production code. The PP_Vars are returned in no particular order, | 67 // used in production code. The PP_Vars are returned in no particular order, |
68 // and their reference counts are unaffected. | 68 // and their reference counts are unaffected. |
69 std::vector<PP_Var> GetLiveVars(); | 69 std::vector<PP_Var> GetLiveVars(); |
70 | 70 |
71 // Retrieves the internal reference counts for testing. Returns 0 if we | |
72 // know about the object but the corresponding value is 0, or -1 if the | |
73 // given object ID isn't in our map. | |
74 int GetRefCountForObject(const PP_Var& object); | |
75 int GetTrackedWithNoReferenceCountForObject(const PP_Var& object); | |
76 | |
77 protected: | 71 protected: |
78 struct VarInfo { | 72 struct VarInfo { |
79 VarInfo(); | 73 VarInfo(); |
80 VarInfo(Var* v, int input_ref_count); | 74 VarInfo(Var* v, int input_ref_count); |
81 | 75 |
82 scoped_refptr<Var> var; | 76 scoped_refptr<Var> var; |
83 | 77 |
84 // Explicit reference count. This value is affected by the renderer calling | 78 // Explicit reference count. This value is affected by the renderer calling |
85 // AddRef and Release. A nonzero value here is represented by a single | 79 // AddRef and Release. A nonzero value here is represented by a single |
86 // reference in the host on our behalf (this reduces IPC traffic). | 80 // reference in the host on our behalf (this reduces IPC traffic). |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 // implemented by the Host and Plugin tracker separately, so that it can be | 145 // implemented by the Host and Plugin tracker separately, so that it can be |
152 // a real WebKit ArrayBuffer on the host side. | 146 // a real WebKit ArrayBuffer on the host side. |
153 virtual ArrayBufferVar* CreateArrayBuffer(uint32 size_in_bytes) = 0; | 147 virtual ArrayBufferVar* CreateArrayBuffer(uint32 size_in_bytes) = 0; |
154 | 148 |
155 DISALLOW_COPY_AND_ASSIGN(VarTracker); | 149 DISALLOW_COPY_AND_ASSIGN(VarTracker); |
156 }; | 150 }; |
157 | 151 |
158 } // namespace ppapi | 152 } // namespace ppapi |
159 | 153 |
160 #endif // PPAPI_SHARED_IMPL_VAR_TRACKER_H_ | 154 #endif // PPAPI_SHARED_IMPL_VAR_TRACKER_H_ |
OLD | NEW |