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

Unified Diff: chrome/browser/visitedlink_master.cc

Issue 149185: Ensure that VisitedLink listener Add event only fires when new fingerprint is... (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/trunk/src/
Patch Set: Fixed the comment. Created 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/visitedlink_master.h ('k') | chrome/browser/visitedlink_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/visitedlink_master.cc
===================================================================
--- chrome/browser/visitedlink_master.cc (revision 19910)
+++ chrome/browser/visitedlink_master.cc (working copy)
@@ -311,7 +311,7 @@
if (used_items_ / 8 > table_length_ / 10)
return null_hash_; // Table is more than 80% full.
- return AddFingerprint(fingerprint);
+ return AddFingerprint(fingerprint, true);
}
void VisitedLinkMaster::AddURL(const GURL& url) {
@@ -400,7 +400,8 @@
// See VisitedLinkCommon::IsVisited which should be in sync with this algorithm
VisitedLinkMaster::Hash VisitedLinkMaster::AddFingerprint(
- Fingerprint fingerprint) {
+ Fingerprint fingerprint,
+ bool send_notifications) {
if (!hash_table_ || table_length_ == 0) {
NOTREACHED(); // Not initialized.
return null_hash_;
@@ -417,8 +418,9 @@
// End of probe sequence found, insert here.
hash_table_[cur_hash] = fingerprint;
used_items_++;
- // Notify listener that a new visited link was added.
- listener_->Add(fingerprint);
+ // If allowed, notify listener that a new visited link was added.
+ if (send_notifications)
+ listener_->Add(fingerprint);
return cur_hash;
}
@@ -503,7 +505,7 @@
if (!shuffled_fingerprints->empty()) {
// Need to add the new items back.
for (size_t i = 0; i < shuffled_fingerprints->size(); i++)
- AddFingerprint(shuffled_fingerprints[i]);
+ AddFingerprint(shuffled_fingerprints[i], false);
}
// Write the affected range to disk [deleted_hash, end_range].
@@ -804,7 +806,7 @@
for (int32 i = 0; i < old_table_length; i++) {
Fingerprint cur = old_hash_table[i];
if (cur)
- AddFingerprint(cur);
+ AddFingerprint(cur, false);
}
// On error unmapping, just forget about it since we can't do anything
@@ -902,13 +904,13 @@
// Add the stored fingerprints to the hash table.
for (size_t i = 0; i < fingerprints.size(); i++)
- AddFingerprint(fingerprints[i]);
+ AddFingerprint(fingerprints[i], false);
// Also add anything that was added while we were asynchronously
// generating the new table.
for (std::set<Fingerprint>::iterator i = added_since_rebuild_.begin();
i != added_since_rebuild_.end(); ++i)
- AddFingerprint(*i);
+ AddFingerprint(*i, false);
added_since_rebuild_.clear();
// Now handle deletions.
« no previous file with comments | « chrome/browser/visitedlink_master.h ('k') | chrome/browser/visitedlink_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698