| 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 #include "ppapi/proxy/ppb_image_data_proxy.h" | 5 #include "ppapi/proxy/ppb_image_data_proxy.h" |
| 6 | 6 |
| 7 #include <string.h> // For memcpy | 7 #include <string.h> // For memcpy |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 void ImageDataUsable(ImageData* image_data); | 242 void ImageDataUsable(ImageData* image_data); |
| 243 | 243 |
| 244 void DidDeleteInstance(PP_Instance instance); | 244 void DidDeleteInstance(PP_Instance instance); |
| 245 | 245 |
| 246 private: | 246 private: |
| 247 friend struct LeakySingletonTraits<ImageDataCache>; | 247 friend struct LeakySingletonTraits<ImageDataCache>; |
| 248 | 248 |
| 249 // Timer callback to expire entries for the given instance. | 249 // Timer callback to expire entries for the given instance. |
| 250 void OnTimer(PP_Instance instance); | 250 void OnTimer(PP_Instance instance); |
| 251 | 251 |
| 252 typedef std::map<PP_Instance, ImageDataInstanceCache> CacheMap; | |
| 253 CacheMap cache_; | |
| 254 | |
| 255 // This class does timer calls and we don't want to run these outside of the | 252 // This class does timer calls and we don't want to run these outside of the |
| 256 // scope of the object. Technically, since this class is a leaked static, | 253 // scope of the object. Technically, since this class is a leaked static, |
| 257 // this will never happen and this factory is unnecessary. However, it's | 254 // this will never happen and this factory is unnecessary. However, it's |
| 258 // probably better not to make assumptions about the lifetime of this class. | 255 // probably better not to make assumptions about the lifetime of this class. |
| 259 base::WeakPtrFactory<ImageDataCache> weak_factory_; | 256 base::WeakPtrFactory<ImageDataCache> weak_factory_; |
| 260 | 257 |
| 258 typedef std::map<PP_Instance, ImageDataInstanceCache> CacheMap; |
| 259 CacheMap cache_; |
| 260 |
| 261 DISALLOW_COPY_AND_ASSIGN(ImageDataCache); | 261 DISALLOW_COPY_AND_ASSIGN(ImageDataCache); |
| 262 }; | 262 }; |
| 263 | 263 |
| 264 // static | 264 // static |
| 265 ImageDataCache* ImageDataCache::GetInstance() { | 265 ImageDataCache* ImageDataCache::GetInstance() { |
| 266 return Singleton<ImageDataCache, | 266 return Singleton<ImageDataCache, |
| 267 LeakySingletonTraits<ImageDataCache> >::get(); | 267 LeakySingletonTraits<ImageDataCache> >::get(); |
| 268 } | 268 } |
| 269 | 269 |
| 270 scoped_refptr<ImageData> ImageDataCache::Get( | 270 scoped_refptr<ImageData> ImageDataCache::Get( |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 // still cached in our process, the proxy still holds a reference so we can | 698 // still cached in our process, the proxy still holds a reference so we can |
| 699 // remove the one the renderer just sent is. If the proxy no longer holds a | 699 // remove the one the renderer just sent is. If the proxy no longer holds a |
| 700 // reference, we released everything and we should also release the one the | 700 // reference, we released everything and we should also release the one the |
| 701 // renderer just sent us. | 701 // renderer just sent us. |
| 702 dispatcher()->Send(new PpapiHostMsg_PPBCore_ReleaseResource( | 702 dispatcher()->Send(new PpapiHostMsg_PPBCore_ReleaseResource( |
| 703 API_ID_PPB_CORE, old_image_data)); | 703 API_ID_PPB_CORE, old_image_data)); |
| 704 } | 704 } |
| 705 | 705 |
| 706 } // namespace proxy | 706 } // namespace proxy |
| 707 } // namespace ppapi | 707 } // namespace ppapi |
| OLD | NEW |