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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 image_fetcher_->SetImageFetcherDelegate(this); | 47 image_fetcher_->SetImageFetcherDelegate(this); |
48 database_->Init(kDatabaseUMAClientName, database_dir, | 48 database_->Init(kDatabaseUMAClientName, database_dir, |
49 base::Bind(&ImageManager::OnDatabaseInit, | 49 base::Bind(&ImageManager::OnDatabaseInit, |
50 weak_ptr_factory_.GetWeakPtr())); | 50 weak_ptr_factory_.GetWeakPtr())); |
51 } | 51 } |
52 | 52 |
53 ImageManager::~ImageManager() {} | 53 ImageManager::~ImageManager() {} |
54 | 54 |
55 ImageManager::ImageCacheRequest::ImageCacheRequest() {} | 55 ImageManager::ImageCacheRequest::ImageCacheRequest() {} |
56 | 56 |
| 57 ImageManager::ImageCacheRequest::ImageCacheRequest( |
| 58 const ImageCacheRequest& other) = default; |
| 59 |
57 ImageManager::ImageCacheRequest::~ImageCacheRequest() {} | 60 ImageManager::ImageCacheRequest::~ImageCacheRequest() {} |
58 | 61 |
59 void ImageManager::Initialize(const SuggestionsProfile& suggestions) { | 62 void ImageManager::Initialize(const SuggestionsProfile& suggestions) { |
60 image_url_map_.clear(); | 63 image_url_map_.clear(); |
61 for (int i = 0; i < suggestions.suggestions_size(); ++i) { | 64 for (int i = 0; i < suggestions.suggestions_size(); ++i) { |
62 const ChromeSuggestion& suggestion = suggestions.suggestions(i); | 65 const ChromeSuggestion& suggestion = suggestions.suggestions(i); |
63 if (suggestion.has_thumbnail()) { | 66 if (suggestion.has_thumbnail()) { |
64 image_url_map_[GURL(suggestion.url())] = GURL(suggestion.thumbnail()); | 67 image_url_map_[GURL(suggestion.url())] = GURL(suggestion.thumbnail()); |
65 } | 68 } |
66 } | 69 } |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 it != pending_cache_requests_.end(); ++it) { | 241 it != pending_cache_requests_.end(); ++it) { |
239 const ImageCacheRequest& request = it->second; | 242 const ImageCacheRequest& request = it->second; |
240 for (CallbackVector::const_iterator callback_it = request.callbacks.begin(); | 243 for (CallbackVector::const_iterator callback_it = request.callbacks.begin(); |
241 callback_it != request.callbacks.end(); ++callback_it) { | 244 callback_it != request.callbacks.end(); ++callback_it) { |
242 ServeFromCacheOrNetwork(request.url, request.image_url, *callback_it); | 245 ServeFromCacheOrNetwork(request.url, request.image_url, *callback_it); |
243 } | 246 } |
244 } | 247 } |
245 } | 248 } |
246 | 249 |
247 } // namespace suggestions | 250 } // namespace suggestions |
OLD | NEW |