summaryrefslogtreecommitdiffstats
path: root/chrome/browser/history
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-13 19:00:29 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-13 19:00:29 +0000
commit34cdd0557b61c9c98aa0510cadfcd814a8156b44 (patch)
treefc5ee6c4e81b184e5259a23ed1957528bf034615 /chrome/browser/history
parent5c65e10ad600bf4786f9eb8f6f30872bc61231e3 (diff)
downloadchromium_src-34cdd0557b61c9c98aa0510cadfcd814a8156b44.zip
chromium_src-34cdd0557b61c9c98aa0510cadfcd814a8156b44.tar.gz
chromium_src-34cdd0557b61c9c98aa0510cadfcd814a8156b44.tar.bz2
This CL adds some UI to remove most-visited thumbnails from the New Tab Page.
The URL of removed thumbnails is added to a blacklist, which is a user pref. I had to modify the VisitSegmentDatabase::QuerySegmentUsage not to return a fixed number of items, as now we may filter the ones we get back. Note: this adds between 20 and 30ms to the first NTP load on my machine (a 3 to 5% increase). BUG=685 TEST=Open the NTP. Click the 'Edit thumbnails' link. Remove some thumbnails. Press Done. Edit again, use the "Restore removed" link. Review URL: http://codereview.chromium.org/67037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13611 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/history')
-rw-r--r--chrome/browser/history/history.cc3
-rw-r--r--chrome/browser/history/history.h1
-rw-r--r--chrome/browser/history/history_backend.cc5
-rw-r--r--chrome/browser/history/history_backend.h3
-rw-r--r--chrome/browser/history/history_unittest.cc6
-rw-r--r--chrome/browser/history/visitsegment_database.cc8
-rw-r--r--chrome/browser/history/visitsegment_database.h4
7 files changed, 17 insertions, 13 deletions
diff --git a/chrome/browser/history/history.cc b/chrome/browser/history/history.cc
index 33eb4d9..7e1130c 100644
--- a/chrome/browser/history/history.cc
+++ b/chrome/browser/history/history.cc
@@ -242,10 +242,11 @@ HistoryService::Handle HistoryService::ScheduleDBTask(
HistoryService::Handle HistoryService::QuerySegmentUsageSince(
CancelableRequestConsumerBase* consumer,
const Time from_time,
+ int max_result_count,
SegmentQueryCallback* callback) {
return Schedule(PRIORITY_UI, &HistoryBackend::QuerySegmentUsage,
consumer, new history::QuerySegmentUsageRequest(callback),
- from_time);
+ from_time, max_result_count);
}
void HistoryService::SetOnBackendDestroyTask(Task* task) {
diff --git a/chrome/browser/history/history.h b/chrome/browser/history/history.h
index d47f12f..eb62217 100644
--- a/chrome/browser/history/history.h
+++ b/chrome/browser/history/history.h
@@ -468,6 +468,7 @@ class HistoryService : public CancelableRequestProvider,
// representing the segment.
Handle QuerySegmentUsageSince(CancelableRequestConsumerBase* consumer,
const base::Time from_time,
+ int max_result_count,
SegmentQueryCallback* callback);
// Set the presentation index for the segment identified by |segment_id|.
diff --git a/chrome/browser/history/history_backend.cc b/chrome/browser/history/history_backend.cc
index 48a8373..d045dc9 100644
--- a/chrome/browser/history/history_backend.cc
+++ b/chrome/browser/history/history_backend.cc
@@ -846,12 +846,13 @@ void HistoryBackend::SetSegmentPresentationIndex(SegmentID segment_id,
void HistoryBackend::QuerySegmentUsage(
scoped_refptr<QuerySegmentUsageRequest> request,
- const Time from_time) {
+ const Time from_time,
+ int max_result_count) {
if (request->canceled())
return;
if (db_.get()) {
- db_->QuerySegmentUsage(from_time, &request->value.get());
+ db_->QuerySegmentUsage(from_time, max_result_count, &request->value.get());
// If this is the first time we query segments, invoke
// DeleteOldSegmentData asynchronously. We do this to cleanup old
diff --git a/chrome/browser/history/history_backend.h b/chrome/browser/history/history_backend.h
index 7a66008..6201ec6 100644
--- a/chrome/browser/history/history_backend.h
+++ b/chrome/browser/history/history_backend.h
@@ -208,7 +208,8 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>,
// Segment usage -------------------------------------------------------------
void QuerySegmentUsage(scoped_refptr<QuerySegmentUsageRequest> request,
- const base::Time from_time);
+ const base::Time from_time,
+ int max_result_count);
void DeleteOldSegmentData();
void SetSegmentPresentationIndex(SegmentID segment_id, int index);
diff --git a/chrome/browser/history/history_unittest.cc b/chrome/browser/history/history_unittest.cc
index 107d845..e64a09d 100644
--- a/chrome/browser/history/history_unittest.cc
+++ b/chrome/browser/history/history_unittest.cc
@@ -598,7 +598,7 @@ TEST_F(HistoryTest, Segments) {
// Make sure a segment was created.
history->QuerySegmentUsageSince(
- &consumer_, Time::Now() - TimeDelta::FromDays(1),
+ &consumer_, Time::Now() - TimeDelta::FromDays(1), 10,
NewCallback(static_cast<HistoryTest*>(this),
&HistoryTest::OnSegmentUsageAvailable));
@@ -616,7 +616,7 @@ TEST_F(HistoryTest, Segments) {
// Query again
history->QuerySegmentUsageSince(
- &consumer_, Time::Now() - TimeDelta::FromDays(1),
+ &consumer_, Time::Now() - TimeDelta::FromDays(1), 10,
NewCallback(static_cast<HistoryTest*>(this),
&HistoryTest::OnSegmentUsageAvailable));
@@ -633,7 +633,7 @@ TEST_F(HistoryTest, Segments) {
// Query again
history->QuerySegmentUsageSince(
- &consumer_, Time::Now() - TimeDelta::FromDays(1),
+ &consumer_, Time::Now() - TimeDelta::FromDays(1), 10,
NewCallback(static_cast<HistoryTest*>(this),
&HistoryTest::OnSegmentUsageAvailable));
diff --git a/chrome/browser/history/visitsegment_database.cc b/chrome/browser/history/visitsegment_database.cc
index 6bab4972..8d9c362 100644
--- a/chrome/browser/history/visitsegment_database.cc
+++ b/chrome/browser/history/visitsegment_database.cc
@@ -232,6 +232,7 @@ bool VisitSegmentDatabase::IncreaseSegmentVisitCount(SegmentID segment_id,
void VisitSegmentDatabase::QuerySegmentUsage(
const Time& from_time,
+ int max_result_count,
std::vector<PageUsageData*>* results) {
// This function gathers the highest-ranked segments in two queries.
// The first gathers scores for all segments.
@@ -241,9 +242,6 @@ void VisitSegmentDatabase::QuerySegmentUsage(
// used to lock results into position. But the rest of our code currently
// does as well.
- // How many results we return, as promised in the header file.
- const size_t kResultCount = 9;
-
// Gather all the segment scores:
SQLITE_UNIQUE_STATEMENT(statement, GetStatementCache(),
"SELECT segment_id, time_slot, visit_count "
@@ -296,8 +294,8 @@ void VisitSegmentDatabase::QuerySegmentUsage(
// Limit to the top kResultCount results.
sort(results->begin(), results->end(), PageUsageData::Predicate);
- if (results->size() > kResultCount)
- results->resize(kResultCount);
+ if (static_cast<int>(results->size()) > max_result_count)
+ results->resize(max_result_count);
// Now fetch the details about the entries we care about.
SQLITE_UNIQUE_STATEMENT(statement2, GetStatementCache(),
diff --git a/chrome/browser/history/visitsegment_database.h b/chrome/browser/history/visitsegment_database.h
index 2f2bbb2..0eb0a36f 100644
--- a/chrome/browser/history/visitsegment_database.h
+++ b/chrome/browser/history/visitsegment_database.h
@@ -49,8 +49,10 @@ class VisitSegmentDatabase {
int amount);
// Compute the segment usage since |from_time| using the provided aggregator.
- // A PageUsageData is added in |result| for the nine highest-scored segments.
+ // A PageUsageData is added in |result| for the highest-scored segments up to
+ // |max_result_count|.
void QuerySegmentUsage(const base::Time& from_time,
+ int max_result_count,
std::vector<PageUsageData*>* result);
// Delete all the segment usage data which is older than the provided time