| 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 NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PROXY_VAR_CACHE_H_ |   5 #ifndef NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PROXY_VAR_CACHE_H_ | 
|   6 #define NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PROXY_VAR_CACHE_H_ |   6 #define NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PROXY_VAR_CACHE_H_ | 
|   7  |   7  | 
|   8 #include <map> |   8 #include <map> | 
|   9 #include <vector> |   9 #include <vector> | 
|  10  |  10  | 
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  47   void ReleaseProxyVar(const PP_Var& var); |  47   void ReleaseProxyVar(const PP_Var& var); | 
|  48  |  48  | 
|  49   // Find the object in the cache associated with |pp_var|. |  49   // Find the object in the cache associated with |pp_var|. | 
|  50   SharedProxyVar SharedProxyVarForVar(PP_Var pp_var) const; |  50   SharedProxyVar SharedProxyVarForVar(PP_Var pp_var) const; | 
|  51  |  51  | 
|  52   // Return all live Vars in the tracker. Reference counts are incremented. |  52   // Return all live Vars in the tracker. Reference counts are incremented. | 
|  53   std::vector<PP_Var> GetLiveVars(); |  53   std::vector<PP_Var> GetLiveVars(); | 
|  54  |  54  | 
|  55  private: |  55  private: | 
|  56   // Return whether or not a var type is cached. |  56   // Return whether or not a var type is cached. | 
|  57   // Note to implementers: be sure to add to this function when adding new |  | 
|  58   // cached types. |  | 
|  59   // TODO(dspringer): When all the complex var types are handled, this |  | 
|  60   // test can turn into something like var.type >= PP_VARTYPE_STRING. |  | 
|  61   bool IsCachedType(const PP_Var& var) { |  57   bool IsCachedType(const PP_Var& var) { | 
|  62     return var.type == PP_VARTYPE_STRING || var.type == PP_VARTYPE_OBJECT; |  58     return var.type >= PP_VARTYPE_STRING; | 
|  63   } |  59   } | 
|  64  |  60  | 
|  65   // The cache of these objects.  The value is a shared pointer so that |  61   // The cache of these objects.  The value is a shared pointer so that | 
|  66   // instances of subclasses can be inserted. |  62   // instances of subclasses can be inserted. | 
|  67   typedef std::map<int64_t, SharedProxyVar> ProxyVarDictionary; |  63   typedef std::map<int64_t, SharedProxyVar> ProxyVarDictionary; | 
|  68   ProxyVarDictionary proxy_var_cache_; |  64   ProxyVarDictionary proxy_var_cache_; | 
|  69  |  65  | 
|  70   static ProxyVarCache* cache_singleton; |  66   static ProxyVarCache* cache_singleton; | 
|  71  |  67  | 
|  72   ProxyVarCache() {} |  68   ProxyVarCache() {} | 
|  73 }; |  69 }; | 
|  74  |  70  | 
|  75 }  // namespace ppapi_proxy |  71 }  // namespace ppapi_proxy | 
|  76  |  72  | 
|  77 #endif  // NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PROXY_VAR_CACHE_H_ |  73 #endif  // NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_PROXY_VAR_CACHE_H_ | 
| OLD | NEW |