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 // This class holds the URL to an image and the bitmap for the fetched image, | 5 // This class holds the URL to an image and the bitmap for the fetched image, |
6 // and has code to fetch the bitmap from the URL. | 6 // and has code to fetch the bitmap from the URL. |
7 | 7 |
8 #include "chrome/browser/image_holder.h" | 8 #include "chrome/browser/image_holder.h" |
9 | 9 |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 void ImageHolder::CreateBitmapFetcher(const GURL& url) { | 53 void ImageHolder::CreateBitmapFetcher(const GURL& url) { |
54 // Check for dups, ignore any request for a dup. | 54 // Check for dups, ignore any request for a dup. |
55 ScopedVector<chrome::BitmapFetcher>::iterator iter; | 55 ScopedVector<chrome::BitmapFetcher>::iterator iter; |
56 for (iter = fetchers_.begin(); iter != fetchers_.end(); ++iter) { | 56 for (iter = fetchers_.begin(); iter != fetchers_.end(); ++iter) { |
57 if ((*iter)->url() == url) | 57 if ((*iter)->url() == url) |
58 return; | 58 return; |
59 } | 59 } |
60 | 60 |
61 if (url.is_valid()) { | 61 if (url.is_valid()) { |
62 fetchers_.push_back(new chrome::BitmapFetcher(url, this)); | 62 fetchers_.push_back(new chrome::BitmapFetcher(url, this)); |
63 DVLOG(2) << __FUNCTION__ << "Pushing bitmap " << url; | 63 DVLOG(2) << __func__ << "Pushing bitmap " << url; |
64 } | 64 } |
65 } | 65 } |
66 | 66 |
67 void ImageHolder::StartFetch() { | 67 void ImageHolder::StartFetch() { |
68 // Now that we have queued them all, start the fetching. | 68 // Now that we have queued them all, start the fetching. |
69 ScopedVector<chrome::BitmapFetcher>::iterator iter; | 69 ScopedVector<chrome::BitmapFetcher>::iterator iter; |
70 for (iter = fetchers_.begin(); iter != fetchers_.end(); ++iter) { | 70 for (iter = fetchers_.begin(); iter != fetchers_.end(); ++iter) { |
71 (*iter)->Init( | 71 (*iter)->Init( |
72 profile_->GetRequestContext(), | 72 profile_->GetRequestContext(), |
73 std::string(), | 73 std::string(), |
(...skipping 10 matching lines...) Expand all Loading... |
84 // factor. | 84 // factor. |
85 if (url == low_dpi_url_) { | 85 if (url == low_dpi_url_) { |
86 low_dpi_fetched_ = true; | 86 low_dpi_fetched_ = true; |
87 if (bitmap != NULL) | 87 if (bitmap != NULL) |
88 image_.AddRepresentation(gfx::ImageSkiaRep(*bitmap, 1.0)); | 88 image_.AddRepresentation(gfx::ImageSkiaRep(*bitmap, 1.0)); |
89 } else if (url == high_dpi_url_) { | 89 } else if (url == high_dpi_url_) { |
90 high_dpi_fetched_ = true; | 90 high_dpi_fetched_ = true; |
91 if (bitmap != NULL) | 91 if (bitmap != NULL) |
92 image_.AddRepresentation(gfx::ImageSkiaRep(*bitmap, 2.0)); | 92 image_.AddRepresentation(gfx::ImageSkiaRep(*bitmap, 2.0)); |
93 } else { | 93 } else { |
94 DVLOG(2) << __FUNCTION__ << "Unmatched bitmap arrived " << url; | 94 DVLOG(2) << __func__ << "Unmatched bitmap arrived " << url; |
95 } | 95 } |
96 | 96 |
97 // Notify callback of bitmap arrival. | 97 // Notify callback of bitmap arrival. |
98 delegate_->OnFetchComplete(); | 98 delegate_->OnFetchComplete(); |
99 } | 99 } |
100 | 100 |
101 } // namespace chrome. | 101 } // namespace chrome. |
OLD | NEW |