OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/suggestions/image_manager.h" | 5 #include "components/suggestions/image_manager.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 std::unique_ptr<SkBitmap> DecodeImage( | 27 std::unique_ptr<SkBitmap> DecodeImage( |
28 scoped_refptr<base::RefCountedMemory> encoded_data) { | 28 scoped_refptr<base::RefCountedMemory> encoded_data) { |
29 return suggestions::DecodeJPEGToSkBitmap(encoded_data->front(), | 29 return suggestions::DecodeJPEGToSkBitmap(encoded_data->front(), |
30 encoded_data->size()); | 30 encoded_data->size()); |
31 } | 31 } |
32 | 32 |
33 // Wraps an ImageManager callback so that it can be used with the ImageFetcher. | 33 // Wraps an ImageManager callback so that it can be used with the ImageFetcher. |
34 void WrapCallback( | 34 void WrapCallback( |
35 const suggestions::ImageManager::ImageCallback& wrapped_callback, | 35 const suggestions::ImageManager::ImageCallback& wrapped_callback, |
36 const std::string& url, | 36 const std::string& url, |
37 const gfx::Image& image) { | 37 const gfx::Image& image, |
| 38 const image_fetcher::RequestMetadata& metadata) { |
38 wrapped_callback.Run(GURL(url), image); | 39 wrapped_callback.Run(GURL(url), image); |
39 } | 40 } |
40 | 41 |
41 } // namespace | 42 } // namespace |
42 | 43 |
43 namespace suggestions { | 44 namespace suggestions { |
44 | 45 |
45 ImageManager::ImageManager() : weak_ptr_factory_(this) {} | 46 ImageManager::ImageManager() : weak_ptr_factory_(this) {} |
46 | 47 |
47 ImageManager::ImageManager( | 48 ImageManager::ImageManager( |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 it != pending_cache_requests_.end(); ++it) { | 254 it != pending_cache_requests_.end(); ++it) { |
254 const ImageCacheRequest& request = it->second; | 255 const ImageCacheRequest& request = it->second; |
255 for (CallbackVector::const_iterator callback_it = request.callbacks.begin(); | 256 for (CallbackVector::const_iterator callback_it = request.callbacks.begin(); |
256 callback_it != request.callbacks.end(); ++callback_it) { | 257 callback_it != request.callbacks.end(); ++callback_it) { |
257 ServeFromCacheOrNetwork(request.url, request.image_url, *callback_it); | 258 ServeFromCacheOrNetwork(request.url, request.image_url, *callback_it); |
258 } | 259 } |
259 } | 260 } |
260 } | 261 } |
261 | 262 |
262 } // namespace suggestions | 263 } // namespace suggestions |
OLD | NEW |