summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autocomplete
diff options
context:
space:
mode:
authormrossetti@chromium.org <mrossetti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-07 04:12:46 +0000
committermrossetti@chromium.org <mrossetti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-07 04:12:46 +0000
commit91f4b017e820a0cb0dc20a7ee076384e32559c02 (patch)
tree927a7931c739b17851dfdc59f1386bd5f4deb5af /chrome/browser/autocomplete
parent50b82260d18b63c6678ea8bb8f90410cffb4b0b4 (diff)
downloadchromium_src-91f4b017e820a0cb0dc20a7ee076384e32559c02.zip
chromium_src-91f4b017e820a0cb0dc20a7ee076384e32559c02.tar.gz
chromium_src-91f4b017e820a0cb0dc20a7ee076384e32559c02.tar.bz2
Move Ownership of IMUI to HistoryService.
This change moves the InMemoryURLIndex (IMUI) from being owned by the InMemoryHistoryBackend to being owned by the HistoryService. The only dependency the IMUI has on the HistoryBackend is the need to access the history database for the one-time need to build the IMUI from scratch. Divorcing the IMUI from the HistoryBackend also pointed out that updates to the IMUI index related to URL visits and history deletes should be handled by notification, and this was implemented in this CL. NOTE: Portions previously reviewed as: http://codereview.chromium.org/9030031/. That change involved both 1) moving the ownership of the IMUI from the InMemoryHistoryBackend, and 2) performing the caching file operations on the FILE thread. I've split this up into two CLs with this CL dealing with the move of ownership. BUG=83659 TEST=Updated unit tests. Review URL: https://chromiumcodereview.appspot.com/9316109 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120707 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete')
-rw-r--r--chrome/browser/autocomplete/history_quick_provider_unittest.cc32
1 files changed, 19 insertions, 13 deletions
diff --git a/chrome/browser/autocomplete/history_quick_provider_unittest.cc b/chrome/browser/autocomplete/history_quick_provider_unittest.cc
index bec93c5..f6892e9 100644
--- a/chrome/browser/autocomplete/history_quick_provider_unittest.cc
+++ b/chrome/browser/autocomplete/history_quick_provider_unittest.cc
@@ -18,6 +18,7 @@
#include "chrome/browser/history/history.h"
#include "chrome/browser/history/in_memory_url_index.h"
#include "chrome/browser/history/url_database.h"
+#include "chrome/browser/history/url_index_private_data.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_browser_process.h"
@@ -99,10 +100,7 @@ class HistoryQuickProviderTest : public testing::Test,
};
void SetUp();
-
- void TearDown() {
- provider_ = NULL;
- }
+ void TearDown();
virtual void GetTestData(size_t* data_count, TestURLInfo** test_data);
@@ -117,6 +115,9 @@ class HistoryQuickProviderTest : public testing::Test,
bool can_inline_top_result,
string16 expected_fill_into_edit);
+ // Pass-through functions to simplify our friendship with URLIndexPrivateData.
+ bool UpdateURL(const history::URLRow& row);
+
MessageLoopForUI message_loop_;
content::TestBrowserThread ui_thread_;
content::TestBrowserThread file_thread_;
@@ -141,6 +142,18 @@ void HistoryQuickProviderTest::SetUp() {
FillData();
}
+void HistoryQuickProviderTest::TearDown() {
+ provider_ = NULL;
+}
+
+bool HistoryQuickProviderTest::UpdateURL(const history::URLRow& row) {
+ history::InMemoryURLIndex* index = provider_->GetIndex();
+ DCHECK(index);
+ history::URLIndexPrivateData* private_data = index->private_data();
+ DCHECK(private_data);
+ return private_data->UpdateURL(row);
+}
+
void HistoryQuickProviderTest::OnProviderUpdate(bool updated_matches) {
MessageLoop::current()->Quit();
}
@@ -156,12 +169,6 @@ void HistoryQuickProviderTest::GetTestData(size_t* data_count,
void HistoryQuickProviderTest::FillData() {
history::URLDatabase* db = history_service_->InMemoryDatabase();
ASSERT_TRUE(db != NULL);
-
- history::InMemoryURLIndex* index =
- new history::InMemoryURLIndex(FilePath());
- PrefService* prefs = profile_->GetPrefs();
- std::string languages(prefs->GetString(prefs::kAcceptLanguages));
- index->Init(db, languages);
size_t data_count = 0;
TestURLInfo* test_data = NULL;
GetTestData(&data_count, &test_data);
@@ -171,15 +178,14 @@ void HistoryQuickProviderTest::FillData() {
Time visit_time = Time::Now() - TimeDelta::FromDays(cur.days_from_now);
history::URLRow url_info(current_url);
+ url_info.set_id(i + 5000);
url_info.set_title(UTF8ToUTF16(cur.title));
url_info.set_visit_count(cur.visit_count);
url_info.set_typed_count(cur.typed_count);
url_info.set_last_visit(visit_time);
url_info.set_hidden(false);
- index->UpdateURL(i, url_info);
+ UpdateURL(url_info);
}
-
- provider_->set_index(index);
}
HistoryQuickProviderTest::SetShouldContain::SetShouldContain(