summaryrefslogtreecommitdiffstats
path: root/chrome/browser/history/top_sites.h
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-02 22:33:44 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-02 22:33:44 +0000
commite6baed56407e548b4d4019aeb27d40d900824042 (patch)
tree96e41d4988731736323a124a87d5cf2c298ef023 /chrome/browser/history/top_sites.h
parent07910cb764fe0772f93ca55ad95588c3f682e268 (diff)
downloadchromium_src-e6baed56407e548b4d4019aeb27d40d900824042.zip
chromium_src-e6baed56407e548b4d4019aeb27d40d900824042.tar.gz
chromium_src-e6baed56407e548b4d4019aeb27d40d900824042.tar.bz2
Tweaks to improve memory consumption by TopSites. The biggest culprit
seems to repeatedly querying history during this perf test. So, the biggest gain is made by scaling this back. Here are other tweaks I've made: . decrease the page size/cache size of the two DBs. Now that favicons doesn't store thumbnails the db doesn't need to be so big. . Set a cap to the max number of tmp thumnbails maintains. . Force jpg data vector to be only as big as it needs to be. . Tweak TopSitesCache so it doesn't end up duplicating so many GURLs. This is particularly helpful for long redirect lists. BUG=61487 TEST=none Review URL: http://codereview.chromium.org/4106014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64837 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/history/top_sites.h')
-rw-r--r--chrome/browser/history/top_sites.h16
1 files changed, 13 insertions, 3 deletions
diff --git a/chrome/browser/history/top_sites.h b/chrome/browser/history/top_sites.h
index cc70cc7..bd406f1 100644
--- a/chrome/browser/history/top_sites.h
+++ b/chrome/browser/history/top_sites.h
@@ -6,14 +6,14 @@
#define CHROME_BROWSER_HISTORY_TOP_SITES_H_
#pragma once
-#include <map>
+#include <list>
#include <set>
#include <string>
-#include <vector>
#include "base/basictypes.h"
#include "base/gtest_prod_util.h"
#include "base/lock.h"
+#include "base/time.h"
#include "base/timer.h"
#include "base/ref_counted.h"
#include "base/ref_counted_memory.h"
@@ -145,6 +145,9 @@ class TopSites
friend class base::RefCountedThreadSafe<TopSites>;
friend class TopSitesTest;
+ typedef std::pair<GURL, Images> TempImage;
+ typedef std::list<TempImage> TempImages;
+
// Enumeration of the possible states history can be in.
enum HistoryLoadState {
// We're waiting for history to finish loading.
@@ -191,6 +194,10 @@ class TopSites
static bool EncodeBitmap(const SkBitmap& bitmap,
scoped_refptr<RefCountedBytes>* bytes);
+ // Removes the cached thumbnail for url. Does nothing if |url| if not cached
+ // in |temp_images_|.
+ void RemoveTemporaryThumbnailByURL(const GURL& url);
+
// Add a thumbnail for an unknown url. See temp_thumbnails_map_.
void AddTemporaryThumbnail(const GURL& url,
const RefCountedBytes* thumbnail,
@@ -295,6 +302,9 @@ class TopSites
// data stays in sync with history.
base::OneShotTimer<TopSites> timer_;
+ // The time we started |timer_| at. Only valid if |timer_| is running.
+ base::TimeTicks timer_start_time_;
+
NotificationRegistrar registrar_;
// The number of URLs changed on the last update.
@@ -309,7 +319,7 @@ class TopSites
// called, if we don't know about that URL yet and we don't have
// enough Top Sites (new profile), we store it until the next
// SetTopSites call.
- URLToImagesMap temp_thumbnails_map_;
+ TempImages temp_images_;
// Blacklisted and pinned URLs are stored in Preferences.