| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/ui/app_list/arc/arc_app_icon.h" | 5 #include "chrome/browser/ui/app_list/arc/arc_app_icon.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 gfx::ImageSkiaRep GetImageForScale(float scale) override; | 100 gfx::ImageSkiaRep GetImageForScale(float scale) override; |
| 101 | 101 |
| 102 // Used to load images asynchronously. NULLed out when the ArcAppIcon is | 102 // Used to load images asynchronously. NULLed out when the ArcAppIcon is |
| 103 // destroyed. | 103 // destroyed. |
| 104 base::WeakPtr<ArcAppIcon> host_; | 104 base::WeakPtr<ArcAppIcon> host_; |
| 105 | 105 |
| 106 const int resource_size_in_dip_; | 106 const int resource_size_in_dip_; |
| 107 | 107 |
| 108 // A map from a pair of a resource ID and size in DIP to an image. This | 108 // A map from a pair of a resource ID and size in DIP to an image. This |
| 109 // is a cache to avoid resizing IDR icons in GetImageForScale every time. | 109 // is a cache to avoid resizing IDR icons in GetImageForScale every time. |
| 110 static base::LazyInstance<std::map<std::pair<int, int>, gfx::ImageSkia>> | 110 static base::LazyInstance<std::map<std::pair<int, int>, gfx::ImageSkia>>:: |
| 111 default_icons_cache_; | 111 DestructorAtExit default_icons_cache_; |
| 112 | 112 |
| 113 DISALLOW_COPY_AND_ASSIGN(Source); | 113 DISALLOW_COPY_AND_ASSIGN(Source); |
| 114 }; | 114 }; |
| 115 | 115 |
| 116 base::LazyInstance<std::map<std::pair<int, int>, gfx::ImageSkia>> | 116 base::LazyInstance<std::map<std::pair<int, int>, gfx::ImageSkia>>:: |
| 117 ArcAppIcon::Source::default_icons_cache_ = LAZY_INSTANCE_INITIALIZER; | 117 DestructorAtExit ArcAppIcon::Source::default_icons_cache_ = |
| 118 LAZY_INSTANCE_INITIALIZER; |
| 118 | 119 |
| 119 ArcAppIcon::Source::Source(const base::WeakPtr<ArcAppIcon>& host, | 120 ArcAppIcon::Source::Source(const base::WeakPtr<ArcAppIcon>& host, |
| 120 int resource_size_in_dip) | 121 int resource_size_in_dip) |
| 121 : host_(host), | 122 : host_(host), |
| 122 resource_size_in_dip_(resource_size_in_dip) { | 123 resource_size_in_dip_(resource_size_in_dip) { |
| 123 } | 124 } |
| 124 | 125 |
| 125 ArcAppIcon::Source::~Source() { | 126 ArcAppIcon::Source::~Source() { |
| 126 } | 127 } |
| 127 | 128 |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 void ArcAppIcon::DiscardDecodeRequest(DecodeRequest* request) { | 363 void ArcAppIcon::DiscardDecodeRequest(DecodeRequest* request) { |
| 363 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 364 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 364 | 365 |
| 365 auto it = std::find_if(decode_requests_.begin(), decode_requests_.end(), | 366 auto it = std::find_if(decode_requests_.begin(), decode_requests_.end(), |
| 366 [request](const std::unique_ptr<DecodeRequest>& ptr) { | 367 [request](const std::unique_ptr<DecodeRequest>& ptr) { |
| 367 return ptr.get() == request; | 368 return ptr.get() == request; |
| 368 }); | 369 }); |
| 369 CHECK(it != decode_requests_.end()); | 370 CHECK(it != decode_requests_.end()); |
| 370 decode_requests_.erase(it); | 371 decode_requests_.erase(it); |
| 371 } | 372 } |
| OLD | NEW |