Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1258)

Unified Diff: ash/app_list/icon_cache.cc

Issue 10388032: Move app list from ash to ui. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: fix win_aura bot and comments in #5 Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/app_list/icon_cache.h ('k') | ash/app_list/page_switcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/app_list/icon_cache.cc
===================================================================
--- ash/app_list/icon_cache.cc (revision 135932)
+++ ash/app_list/icon_cache.cc (working copy)
@@ -1,90 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ash/app_list/icon_cache.h"
-
-#include "base/logging.h"
-#include "base/md5.h"
-#include "ui/gfx/size.h"
-
-namespace {
-
-// Gets cache key based on |image| contents and desired |size|.
-std::string GetKey(const SkBitmap& image, const gfx::Size& size) {
- SkAutoLockPixels image_lock(image);
- base::MD5Digest digest;
- MD5Sum(image.getPixels(), image.getSize(), &digest);
-
- return MD5DigestToBase16(digest) + "." + size.ToString();
-}
-
-} // namespace
-
-namespace ash {
-
-// static
-IconCache* IconCache::instance_ = NULL;
-
-// static
-void IconCache::CreateInstance() {
- DCHECK(!instance_);
- instance_ = new IconCache;
-}
-
-// static
-void IconCache::DeleteInstance() {
- DCHECK(instance_);
- delete instance_;
- instance_ = NULL;
-}
-
-// static
-IconCache* IconCache::GetInstance() {
- DCHECK(instance_);
- return instance_;
-}
-
-void IconCache::MarkAllEntryUnused() {
- for (Cache::iterator i = cache_.begin(); i != cache_.end(); ++i)
- i->second.used = false;
-}
-
-void IconCache::PurgeAllUnused() {
- for (Cache::iterator i = cache_.begin(); i != cache_.end();) {
- Cache::iterator current(i);
- ++i;
- if (!current->second.used)
- cache_.erase(current);
- }
-}
-
-bool IconCache::Get(const SkBitmap& src,
- const gfx::Size& size,
- SkBitmap* processed) {
- Cache::iterator it = cache_.find(GetKey(src, size));
- if (it == cache_.end())
- return false;
-
- it->second.used = true;
-
- if (processed)
- *processed = it->second.image;
- return true;
-}
-
-void IconCache::Put(const SkBitmap& src,
- const gfx::Size& size,
- const SkBitmap& processed) {
- const std::string key = GetKey(src, size);
- cache_[key].image = processed;
- cache_[key].used = true;
-}
-
-IconCache::IconCache() {
-}
-
-IconCache::~IconCache() {
-}
-
-} // namespace ash
« no previous file with comments | « ash/app_list/icon_cache.h ('k') | ash/app_list/page_switcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698