From 8a6e174c293dfcce6b1c409f5f508537eaaa7f9c Mon Sep 17 00:00:00 2001 From: "brettw@google.com" Date: Sat, 13 Dec 2008 17:18:50 +0000 Subject: Implement visited link coloring. Review URL: http://codereview.chromium.org/12928 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6970 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/common/visitedlink_common.cc | 2 +- chrome/common/visitedlink_common.h | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) (limited to 'chrome/common') diff --git a/chrome/common/visitedlink_common.cc b/chrome/common/visitedlink_common.cc index 39273e0..6bda05d 100644 --- a/chrome/common/visitedlink_common.cc +++ b/chrome/common/visitedlink_common.cc @@ -29,7 +29,7 @@ bool VisitedLinkCommon::IsVisited(const char* canonical_url, NOTREACHED(); return false; } - return IsVisited(ComputeURLFingerprint(canonical_url, url_len, salt_)); + return IsVisited(ComputeURLFingerprint(canonical_url, url_len)); } bool VisitedLinkCommon::IsVisited(Fingerprint fingerprint) const { diff --git a/chrome/common/visitedlink_common.h b/chrome/common/visitedlink_common.h index 65f540b..06a4f5c 100644 --- a/chrome/common/visitedlink_common.h +++ b/chrome/common/visitedlink_common.h @@ -55,13 +55,20 @@ class VisitedLinkCommon { VisitedLinkCommon(); virtual ~VisitedLinkCommon(); - // Computes the fingerprint of the key and looks it up in the table. We - // return true if found. Does not modify the hastable. The input should be - // the canonical 16-bit URL. + // Returns the fingerprint for the given URL. + Fingerprint ComputeURLFingerprint(const char* canonical_url, + size_t url_len) const { + return ComputeURLFingerprint(canonical_url, url_len, salt_); + } + + // Looks up the given key in the table. The fingerprint for the URL is + // computed if you call one with the string argument. Returns true if found. + // Does not modify the hastable. bool IsVisited(const char* canonical_url, size_t url_len) const; bool IsVisited(const GURL& url) const { return IsVisited(url.spec().data(), url.spec().size()); } + bool IsVisited(Fingerprint fingerprint) const; #ifdef UNIT_TEST // Returns statistics about DB usage @@ -93,12 +100,10 @@ class VisitedLinkCommon { return hash_table_[table_offset]; } - // Returns true if the given fingerprint is in the table. - bool IsVisited(Fingerprint fingerprint) const; - // Computes the fingerprint of the given canonical URL. It is static so the // same algorithm can be re-used by the table rebuilder, so you will have to - // pass the salt as a parameter. + // pass the salt as a parameter. See the non-static version above if you + // want to use the current class' salt. static Fingerprint ComputeURLFingerprint(const char* canonical_url, size_t url_len, const uint8 salt[LINK_SALT_LENGTH]); -- cgit v1.1