| 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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 CacheMap::iterator found = cache_.find(instance); | 275 CacheMap::iterator found = cache_.find(instance); |
| 276 if (found == cache_.end()) | 276 if (found == cache_.end()) |
| 277 return scoped_refptr<ImageData>(); | 277 return scoped_refptr<ImageData>(); |
| 278 return found->second.Get(type, width, height, format); | 278 return found->second.Get(type, width, height, format); |
| 279 } | 279 } |
| 280 | 280 |
| 281 void ImageDataCache::Add(ImageData* image_data) { | 281 void ImageDataCache::Add(ImageData* image_data) { |
| 282 cache_[image_data->pp_instance()].Add(image_data); | 282 cache_[image_data->pp_instance()].Add(image_data); |
| 283 | 283 |
| 284 // Schedule a timer to invalidate this entry. | 284 // Schedule a timer to invalidate this entry. |
| 285 base::MessageLoop::current()->PostDelayedTask( | 285 PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostDelayedTask( |
| 286 FROM_HERE, | 286 FROM_HERE, |
| 287 RunWhileLocked(base::Bind(&ImageDataCache::OnTimer, | 287 RunWhileLocked(base::Bind(&ImageDataCache::OnTimer, |
| 288 weak_factory_.GetWeakPtr(), | 288 weak_factory_.GetWeakPtr(), |
| 289 image_data->pp_instance())), | 289 image_data->pp_instance())), |
| 290 base::TimeDelta::FromSeconds(kMaxAgeSeconds)); | 290 base::TimeDelta::FromSeconds(kMaxAgeSeconds)); |
| 291 } | 291 } |
| 292 | 292 |
| 293 void ImageDataCache::ImageDataUsable(ImageData* image_data) { | 293 void ImageDataCache::ImageDataUsable(ImageData* image_data) { |
| 294 CacheMap::iterator found = cache_.find(image_data->pp_instance()); | 294 CacheMap::iterator found = cache_.find(image_data->pp_instance()); |
| 295 if (found != cache_.end()) | 295 if (found != cache_.end()) |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 // still cached in our process, the proxy still holds a reference so we can | 687 // still cached in our process, the proxy still holds a reference so we can |
| 688 // remove the one the renderer just sent is. If the proxy no longer holds a | 688 // remove the one the renderer just sent is. If the proxy no longer holds a |
| 689 // reference, we released everything and we should also release the one the | 689 // reference, we released everything and we should also release the one the |
| 690 // renderer just sent us. | 690 // renderer just sent us. |
| 691 dispatcher()->Send(new PpapiHostMsg_PPBCore_ReleaseResource( | 691 dispatcher()->Send(new PpapiHostMsg_PPBCore_ReleaseResource( |
| 692 API_ID_PPB_CORE, old_image_data)); | 692 API_ID_PPB_CORE, old_image_data)); |
| 693 } | 693 } |
| 694 | 694 |
| 695 } // namespace proxy | 695 } // namespace proxy |
| 696 } // namespace ppapi | 696 } // namespace ppapi |
| OLD | NEW |