| OLD | NEW |
| 1 // Copyright (c) 2011 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> |
| 9 |
| 8 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 9 #include "base/hash_tables.h" | 11 #include "base/hash_tables.h" |
| 10 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 11 #include "ppapi/c/pp_module.h" | 13 #include "ppapi/c/pp_module.h" |
| 12 #include "ppapi/c/pp_var.h" | 14 #include "ppapi/c/pp_var.h" |
| 13 #include "ppapi/shared_impl/ppapi_shared_export.h" | 15 #include "ppapi/shared_impl/ppapi_shared_export.h" |
| 14 | 16 |
| 15 namespace ppapi { | 17 namespace ppapi { |
| 16 | 18 |
| 17 class ArrayBufferVar; | 19 class ArrayBufferVar; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 // the ID is invalid or if the refcount was already 0. The PP_Var version | 55 // the ID is invalid or if the refcount was already 0. The PP_Var version |
| 54 // returns true and does nothing for non-refcounted type vars. The var will | 56 // returns true and does nothing for non-refcounted type vars. The var will |
| 55 // be deleted if there are no more refs to it. | 57 // be deleted if there are no more refs to it. |
| 56 bool ReleaseVar(int32 var_id); | 58 bool ReleaseVar(int32 var_id); |
| 57 bool ReleaseVar(const PP_Var& var); | 59 bool ReleaseVar(const PP_Var& var); |
| 58 | 60 |
| 59 // 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 |
| 60 // that references it and has an initial reference-count of 1. | 62 // that references it and has an initial reference-count of 1. |
| 61 PP_Var MakeArrayBufferPPVar(uint32 size_in_bytes); | 63 PP_Var MakeArrayBufferPPVar(uint32 size_in_bytes); |
| 62 | 64 |
| 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 |
| 67 // used in production code. The PP_Vars are returned in no particular order, |
| 68 // and their reference counts are unaffected. |
| 69 std::vector<PP_Var> GetLiveVars(); |
| 70 |
| 63 protected: | 71 protected: |
| 64 struct VarInfo { | 72 struct VarInfo { |
| 65 VarInfo(); | 73 VarInfo(); |
| 66 VarInfo(Var* v, int input_ref_count); | 74 VarInfo(Var* v, int input_ref_count); |
| 67 | 75 |
| 68 scoped_refptr<Var> var; | 76 scoped_refptr<Var> var; |
| 69 | 77 |
| 70 // Explicit reference count. This value is affected by the renderer calling | 78 // Explicit reference count. This value is affected by the renderer calling |
| 71 // 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 |
| 72 // 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... |
| 137 // 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 |
| 138 // a real WebKit ArrayBuffer on the host side. | 146 // a real WebKit ArrayBuffer on the host side. |
| 139 virtual ArrayBufferVar* CreateArrayBuffer(uint32 size_in_bytes) = 0; | 147 virtual ArrayBufferVar* CreateArrayBuffer(uint32 size_in_bytes) = 0; |
| 140 | 148 |
| 141 DISALLOW_COPY_AND_ASSIGN(VarTracker); | 149 DISALLOW_COPY_AND_ASSIGN(VarTracker); |
| 142 }; | 150 }; |
| 143 | 151 |
| 144 } // namespace ppapi | 152 } // namespace ppapi |
| 145 | 153 |
| 146 #endif // PPAPI_SHARED_IMPL_VAR_TRACKER_H_ | 154 #endif // PPAPI_SHARED_IMPL_VAR_TRACKER_H_ |
| OLD | NEW |