| 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/enhanced_bookmarks/test_image_store.h" | 5 #include "components/enhanced_bookmarks/test_image_store.h" |
| 6 | 6 |
| 7 #include "third_party/skia/include/core/SkBitmap.h" |
| 7 #include "ui/gfx/geometry/size.h" | 8 #include "ui/gfx/geometry/size.h" |
| 8 #include "url/gurl.h" | 9 #include "url/gurl.h" |
| 9 | 10 |
| 10 TestImageStore::TestImageStore() { | 11 TestImageStore::TestImageStore() { |
| 11 } | 12 } |
| 12 | 13 |
| 13 bool TestImageStore::HasKey(const GURL& page_url) { | 14 bool TestImageStore::HasKey(const GURL& page_url) { |
| 14 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 15 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); |
| 15 | 16 |
| 16 return store_.find(page_url) != store_.end(); | 17 return store_.find(page_url) != store_.end(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 for (ImageMap::const_iterator it = store_.begin(); it != store_.end(); ++it) | 62 for (ImageMap::const_iterator it = store_.begin(); it != store_.end(); ++it) |
| 62 urls->insert(it->first); | 63 urls->insert(it->first); |
| 63 } | 64 } |
| 64 | 65 |
| 65 void TestImageStore::ClearAll() { | 66 void TestImageStore::ClearAll() { |
| 66 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 67 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); |
| 67 | 68 |
| 68 store_.clear(); | 69 store_.clear(); |
| 69 } | 70 } |
| 70 | 71 |
| 72 int64 TestImageStore::GetStoreSize() { |
| 73 // Not 100% accurate, but it's for testing so the actual value is not |
| 74 // important. |
| 75 int64 size = sizeof(store_); |
| 76 for (ImageMap::const_iterator it = store_.begin(); it != store_.end(); ++it) { |
| 77 size += sizeof(it->first); |
| 78 size += it->first.spec().length(); |
| 79 size += sizeof(it->second); |
| 80 SkBitmap bitmap = it->second.first.AsBitmap(); |
| 81 size += bitmap.width() * bitmap.height() * bitmap.bytesPerPixel(); |
| 82 size += it->second.second.spec().length(); |
| 83 } |
| 84 return size; |
| 85 } |
| 86 |
| 71 TestImageStore::~TestImageStore() { | 87 TestImageStore::~TestImageStore() { |
| 72 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 88 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); |
| 73 } | 89 } |
| OLD | NEW |