diff options
author | kkimlabs@chromium.org <kkimlabs@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-02 19:16:33 +0000 |
---|---|---|
committer | kkimlabs@chromium.org <kkimlabs@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-02 19:16:33 +0000 |
commit | 6e2d03a37faa8cde06ca668d841fb34bb4fafdcc (patch) | |
tree | f219c138a84077370f758ef6dfcc53091f16fc40 /components/enhanced_bookmarks/test_image_store.cc | |
parent | a2a75f57fcab08f4d34b84e35e6cf5505afbd7f8 (diff) | |
download | chromium_src-6e2d03a37faa8cde06ca668d841fb34bb4fafdcc.zip chromium_src-6e2d03a37faa8cde06ca668d841fb34bb4fafdcc.tar.gz chromium_src-6e2d03a37faa8cde06ca668d841fb34bb4fafdcc.tar.bz2 |
Add GetStoreSizeInBytes() to ImageStore to know the actual db size.
We will limit the enhanced bookmark image store database size
to ensure that the db file size is reasonable. So add a function
to query the actual file size.
BUG=378853
Review URL: https://codereview.chromium.org/305963004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274297 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/enhanced_bookmarks/test_image_store.cc')
-rw-r--r-- | components/enhanced_bookmarks/test_image_store.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/components/enhanced_bookmarks/test_image_store.cc b/components/enhanced_bookmarks/test_image_store.cc index c96f3cf..19d505f 100644 --- a/components/enhanced_bookmarks/test_image_store.cc +++ b/components/enhanced_bookmarks/test_image_store.cc @@ -4,6 +4,7 @@ #include "components/enhanced_bookmarks/test_image_store.h" +#include "third_party/skia/include/core/SkBitmap.h" #include "ui/gfx/geometry/size.h" #include "url/gurl.h" @@ -68,6 +69,21 @@ void TestImageStore::ClearAll() { store_.clear(); } +int64 TestImageStore::GetStoreSizeInBytes() { + // Not 100% accurate, but it's for testing so the actual value is not + // important. + int64 size = sizeof(store_); + for (ImageMap::const_iterator it = store_.begin(); it != store_.end(); ++it) { + size += sizeof(it->first); + size += it->first.spec().length(); + size += sizeof(it->second); + SkBitmap bitmap = it->second.first.AsBitmap(); + size += bitmap.getSize(); + size += it->second.second.spec().length(); + } + return size; +} + TestImageStore::~TestImageStore() { DCHECK(sequence_checker_.CalledOnValidSequencedThread()); } |