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

Side by Side Diff: components/enhanced_bookmarks/test_image_store.cc

Issue 305963004: Add GetStoreSize() to ImageStore to know the actual db size. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: size += bitmap.getSize(); Created 6 years, 6 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 unified diff | Download patch
« no previous file with comments | « components/enhanced_bookmarks/test_image_store.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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::GetStoreSizeInBytes() {
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.getSize();
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 }
OLDNEW
« no previous file with comments | « components/enhanced_bookmarks/test_image_store.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698