diff options
Diffstat (limited to 'chrome')
50 files changed, 145 insertions, 670 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc b/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc index e1dc676..6452f2f 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc +++ b/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc @@ -233,8 +233,7 @@ class AutocompleteEditViewTest : public InProcessBrowserTest, Time t = Time::Now() - TimeDelta::FromHours(i + 1); history_service->AddPageWithDetails(url, UTF8ToUTF16(cur.title), cur.visit_count, - cur.typed_count, t, false, - history::SOURCE_BROWSED); + cur.typed_count, t, false); history_service->SetPageContents(url, UTF8ToUTF16(cur.body)); if (cur.starred) { bookmark_model->SetURLStarred(url, string16(), true); diff --git a/chrome/browser/autocomplete/history_contents_provider_unittest.cc b/chrome/browser/autocomplete/history_contents_provider_unittest.cc index 21e91fa..9212bce 100644 --- a/chrome/browser/autocomplete/history_contents_provider_unittest.cc +++ b/chrome/browser/autocomplete/history_contents_provider_unittest.cc @@ -73,8 +73,7 @@ class HistoryContentsProviderTest : public testing::Test, Time t = Time::Now() - TimeDelta::FromDays(arraysize(test_entries) + i); history_service->AddPage(url, t, id_scope, i, GURL(), - PageTransition::LINK, history::RedirectList(), - history::SOURCE_BROWSED, false); + PageTransition::LINK, history::RedirectList(), false); history_service->SetPageTitle(url, UTF8ToUTF16(test_entries[i].title)); history_service->SetPageContents(url, UTF8ToUTF16(test_entries[i].body)); } diff --git a/chrome/browser/autocomplete/history_url_provider_unittest.cc b/chrome/browser/autocomplete/history_url_provider_unittest.cc index 393cd62..d3ab9c3 100644 --- a/chrome/browser/autocomplete/history_url_provider_unittest.cc +++ b/chrome/browser/autocomplete/history_url_provider_unittest.cc @@ -175,8 +175,7 @@ void HistoryURLProviderTest::FillData() { const GURL current_url(cur.url); history_service_->AddPageWithDetails(current_url, UTF8ToUTF16(cur.title), cur.visit_count, cur.typed_count, - visit_time, false, - history::SOURCE_BROWSED); + visit_time, false); } } @@ -316,8 +315,7 @@ TEST_F(HistoryURLProviderTest, CullRedirects) { history_service_->AddPageWithDetails(GURL(redirect[i].url), UTF8ToUTF16("Title"), redirect[i].count, redirect[i].count, - Time::Now(), false, - history::SOURCE_BROWSED); + Time::Now(), false); } // Create a B->C->A redirect chain, but set the visit counts such that they @@ -329,8 +327,7 @@ TEST_F(HistoryURLProviderTest, CullRedirects) { redirects_to_a.push_back(GURL(redirect[2].url)); redirects_to_a.push_back(GURL(redirect[0].url)); history_service_->AddPage(GURL(redirect[0].url), NULL, 0, GURL(), - PageTransition::TYPED, redirects_to_a, - history::SOURCE_BROWSED, true); + PageTransition::TYPED, redirects_to_a, true); // Because all the results are part of a redirect chain with other results, // all but the first one (A) should be culled. We should get the default diff --git a/chrome/browser/autocomplete/search_provider_unittest.cc b/chrome/browser/autocomplete/search_provider_unittest.cc index da2c67e..0062657b 100644 --- a/chrome/browser/autocomplete/search_provider_unittest.cc +++ b/chrome/browser/autocomplete/search_provider_unittest.cc @@ -109,8 +109,7 @@ void SearchProviderTest::SetUp() { term1_url_ = GURL(default_t_url_->url()->ReplaceSearchTerms( *default_t_url_, UTF16ToWide(term1_), 0, std::wstring())); history->AddPageWithDetails(term1_url_, string16(), 1, 1, - base::Time::Now(), false, - history::SOURCE_BROWSED); + base::Time::Now(), false); history->SetKeywordSearchTermsForURL(term1_url_, default_t_url_->id(), term1_); @@ -127,8 +126,7 @@ void SearchProviderTest::SetUp() { keyword_url_ = GURL(keyword_t_url_->url()->ReplaceSearchTerms( *keyword_t_url_, UTF16ToWide(keyword_term_), 0, std::wstring())); history->AddPageWithDetails(keyword_url_, string16(), 1, 1, - base::Time::Now(), false, - history::SOURCE_BROWSED); + base::Time::Now(), false); history->SetKeywordSearchTermsForURL(keyword_url_, keyword_t_url_->id(), keyword_term_); diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index 46558ab..6ba2605 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -1836,7 +1836,6 @@ void AutomationProvider::AddHistoryItem(Browser* browser, GURL(), PageTransition::LINK, history::RedirectList(), - history::SOURCE_BROWSED, false); if (title.length()) hs->SetPageTitle(gurl, title); diff --git a/chrome/browser/bookmarks/bookmark_html_writer_unittest.cc b/chrome/browser/bookmarks/bookmark_html_writer_unittest.cc index 90ad16b..40f5110 100644 --- a/chrome/browser/bookmarks/bookmark_html_writer_unittest.cc +++ b/chrome/browser/bookmarks/bookmark_html_writer_unittest.cc @@ -193,8 +193,7 @@ TEST_F(BookmarkHTMLWriterTest, Test) { const BookmarkNode* f1 = model->AddGroup( model->GetBookmarkBarNode(), 0, f1_title); model->AddURLWithCreationTime(f1, 0, url1_title, url1, t1); - profile.GetHistoryService(Profile::EXPLICIT_ACCESS)->AddPage(url1, - history::SOURCE_BROWSED); + profile.GetHistoryService(Profile::EXPLICIT_ACCESS)->AddPage(url1); profile.GetFaviconService(Profile::EXPLICIT_ACCESS)->SetFavicon(url1, url1_favicon, icon_data); diff --git a/chrome/browser/bookmarks/bookmark_model_unittest.cc b/chrome/browser/bookmarks/bookmark_model_unittest.cc index c21104c..f588068 100644 --- a/chrome/browser/bookmarks/bookmark_model_unittest.cc +++ b/chrome/browser/bookmarks/bookmark_model_unittest.cc @@ -948,7 +948,7 @@ TEST_F(BookmarkModelTestWithProfile2, RemoveNotification) { profile_->GetHistoryService(Profile::EXPLICIT_ACCESS)->AddPage( url, NULL, 1, GURL(), PageTransition::TYPED, - history::RedirectList(), history::SOURCE_BROWSED, false); + history::RedirectList(), false); // This won't actually delete the URL, rather it'll empty out the visits. // This triggers blocking on the BookmarkModel. diff --git a/chrome/browser/extensions/extension_history_api.cc b/chrome/browser/extensions/extension_history_api.cc index 3df0509..95d3acb 100644 --- a/chrome/browser/extensions/extension_history_api.cc +++ b/chrome/browser/extensions/extension_history_api.cc @@ -304,7 +304,7 @@ bool AddUrlHistoryFunction::RunImpl() { return false; HistoryService* hs = profile()->GetHistoryService(Profile::EXPLICIT_ACCESS); - hs->AddPage(url, history::SOURCE_EXTENSION); + hs->AddPage(url); SendResponse(true); return true; diff --git a/chrome/browser/history/archived_database.cc b/chrome/browser/history/archived_database.cc index 72fa998..777ee4d 100644 --- a/chrome/browser/history/archived_database.cc +++ b/chrome/browser/history/archived_database.cc @@ -13,7 +13,7 @@ namespace history { namespace { -static const int kCurrentVersionNumber = 3; +static const int kCurrentVersionNumber = 2; static const int kCompatibleVersionNumber = 2; } // namespace @@ -110,12 +110,6 @@ sql::InitStatus ArchivedDatabase::EnsureCurrentVersion() { std::min(cur_version, kCompatibleVersionNumber)); } - if (cur_version == 2) { - // This is the version prior to adding visit_source table. - ++cur_version; - meta_table_.SetVersionNumber(cur_version); - } - // Put future migration cases here. // When the version is too old, we just try to continue anyway, there should diff --git a/chrome/browser/history/expire_history_backend.cc b/chrome/browser/history/expire_history_backend.cc index 294c0e6..bd471ad 100644 --- a/chrome/browser/history/expire_history_backend.cc +++ b/chrome/browser/history/expire_history_backend.cc @@ -512,7 +512,7 @@ void ExpireHistoryBackend::ExpireURLsForVisits( void ExpireHistoryBackend::ArchiveURLsAndVisits( const VisitVector& visits, DeleteDependencies* dependencies) { - if (!archived_db_ || !main_db_) + if (!archived_db_) return; // Make sure all unique URL rows are added to the dependency list and the @@ -539,12 +539,6 @@ void ExpireHistoryBackend::ArchiveURLsAndVisits( } } - // Retrieve the sources for all the archived visits before archiving. - // The returned visit_sources vector should contain the source for each visit - // from visits at the same index. - VisitSourceMap visit_sources; - main_db_->GetVisitsSource(visits, &visit_sources); - // Now archive the visits since we know the URL ID to make them reference. // The source visit list should still reference the visits in the main DB, but // we will update it to reflect only the visits that were successfully @@ -556,9 +550,7 @@ void ExpireHistoryBackend::ArchiveURLsAndVisits( VisitRow cur_visit(visits[i]); cur_visit.url_id = main_id_to_archived_id[cur_visit.url_id]; cur_visit.referring_visit = 0; - VisitSourceMap::iterator iter = visit_sources.find(visits[i].visit_id); - archived_db_->AddVisit(&cur_visit, - iter == visit_sources.end() ? SOURCE_BROWSED : iter->second); + archived_db_->AddVisit(&cur_visit); // Ignore failures, we will delete it from the main DB no matter what. } } diff --git a/chrome/browser/history/expire_history_backend.h b/chrome/browser/history/expire_history_backend.h index 96e2e9a..4bd18b0 100644 --- a/chrome/browser/history/expire_history_backend.h +++ b/chrome/browser/history/expire_history_backend.h @@ -106,7 +106,6 @@ class ExpireHistoryBackend { FRIEND_TEST_ALL_PREFIXES(ExpireHistoryTest, DeleteFaviconsIfPossible); FRIEND_TEST_ALL_PREFIXES(ExpireHistoryTest, ArchiveSomeOldHistory); FRIEND_TEST_ALL_PREFIXES(ExpireHistoryTest, ExpiringVisitsReader); - FRIEND_TEST_ALL_PREFIXES(ExpireHistoryTest, ArchiveSomeOldHistoryWithSource); friend class ::TestingProfile; struct DeleteDependencies; diff --git a/chrome/browser/history/expire_history_backend_unittest.cc b/chrome/browser/history/expire_history_backend_unittest.cc index 694c2e0..ac3e834 100644 --- a/chrome/browser/history/expire_history_backend_unittest.cc +++ b/chrome/browser/history/expire_history_backend_unittest.cc @@ -56,8 +56,6 @@ class ExpireHistoryTest : public testing::Test, protected: // Called by individual tests when they want data populated. void AddExampleData(URLID url_ids[3], Time visit_times[4]); - // Add visits with source information. - void AddExampleSourceData(const GURL& url, URLID* id); // Returns true if the given favicon/thumanil has an entry in the DB. bool HasFavIcon(FavIconID favicon_id); @@ -229,26 +227,26 @@ void ExpireHistoryTest::AddExampleData(URLID url_ids[3], Time visit_times[4]) { visit_row1.url_id = url_ids[0]; visit_row1.visit_time = visit_times[0]; visit_row1.is_indexed = true; - main_db_->AddVisit(&visit_row1, SOURCE_BROWSED); + main_db_->AddVisit(&visit_row1); VisitRow visit_row2; visit_row2.url_id = url_ids[1]; visit_row2.visit_time = visit_times[1]; visit_row2.is_indexed = true; - main_db_->AddVisit(&visit_row2, SOURCE_BROWSED); + main_db_->AddVisit(&visit_row2); VisitRow visit_row3; visit_row3.url_id = url_ids[1]; visit_row3.visit_time = visit_times[2]; visit_row3.is_indexed = true; visit_row3.transition = PageTransition::TYPED; - main_db_->AddVisit(&visit_row3, SOURCE_BROWSED); + main_db_->AddVisit(&visit_row3); VisitRow visit_row4; visit_row4.url_id = url_ids[2]; visit_row4.visit_time = visit_times[3]; visit_row4.is_indexed = true; - main_db_->AddVisit(&visit_row4, SOURCE_BROWSED); + main_db_->AddVisit(&visit_row4); // Full text index for each visit. text_db_->AddPageData(url_row1.url(), visit_row1.url_id, visit_row1.visit_id, @@ -269,35 +267,6 @@ void ExpireHistoryTest::AddExampleData(URLID url_ids[3], Time visit_times[4]) { UTF8ToUTF16("goats body")); } -void ExpireHistoryTest::AddExampleSourceData(const GURL& url, URLID* id) { - if (!main_db_.get()) - return; - - Time last_visit_time = Time::Now(); - // Add one URL. - URLRow url_row1(url); - url_row1.set_last_visit(last_visit_time); - url_row1.set_visit_count(4); - URLID url_id = main_db_->AddURL(url_row1); - *id = url_id; - - // Four times for each visit. - VisitRow visit_row1(url_id, last_visit_time - TimeDelta::FromDays(4), 0, - PageTransition::TYPED, 0); - main_db_->AddVisit(&visit_row1, SOURCE_SYNCED); - - VisitRow visit_row2(url_id, last_visit_time - TimeDelta::FromDays(3), 0, - PageTransition::TYPED, 0); - main_db_->AddVisit(&visit_row2, SOURCE_BROWSED); - - VisitRow visit_row3(url_id, last_visit_time - TimeDelta::FromDays(2), 0, - PageTransition::TYPED, 0); - main_db_->AddVisit(&visit_row3, SOURCE_EXTENSION); - - VisitRow visit_row4(url_id, last_visit_time, 0, PageTransition::TYPED, 0); - main_db_->AddVisit(&visit_row4, SOURCE_FIREFOX_IMPORTED); -} - bool ExpireHistoryTest::HasFavIcon(FavIconID favicon_id) { if (!thumb_db_.get()) return false; @@ -846,50 +815,6 @@ TEST_F(ExpireHistoryTest, ExpiringVisitsReader) { EXPECT_EQ(1U, visits.size()); } -// Tests how ArchiveSomeOldHistory treats source information. -TEST_F(ExpireHistoryTest, ArchiveSomeOldHistoryWithSource) { - const GURL url("www.testsource.com"); - URLID url_id; - AddExampleSourceData(url, &url_id); - const ExpiringVisitsReader* reader = expirer_.GetAllVisitsReader(); - - // Archiving all the visits we added. - ASSERT_FALSE(expirer_.ArchiveSomeOldHistory(Time::Now(), reader, 10)); - - URLRow archived_row; - ASSERT_TRUE(archived_db_->GetRowForURL(url, &archived_row)); - VisitVector archived_visits; - archived_db_->GetVisitsForURL(archived_row.id(), &archived_visits); - ASSERT_EQ(4U, archived_visits.size()); - VisitSourceMap sources; - archived_db_->GetVisitsSource(archived_visits, &sources); - ASSERT_EQ(3U, sources.size()); - int result = 0; - VisitSourceMap::iterator iter; - for (int i = 0; i < 4; i++) { - iter = sources.find(archived_visits[i].visit_id); - if (iter == sources.end()) - continue; - switch (iter->second) { - case history::SOURCE_EXTENSION: - result |= 0x1; - break; - case history::SOURCE_FIREFOX_IMPORTED: - result |= 0x2; - break; - case history::SOURCE_SYNCED: - result |= 0x4; - default: - break; - } - } - EXPECT_EQ(0x7, result); - main_db_->GetVisitsSource(archived_visits, &sources); - EXPECT_EQ(0U, sources.size()); - main_db_->GetVisitsForURL(url_id, &archived_visits); - EXPECT_EQ(0U, archived_visits.size()); -} - // TODO(brettw) add some visits with no URL to make sure everything is updated // properly. Have the visits also refer to nonexistant FTS rows. // diff --git a/chrome/browser/history/history.cc b/chrome/browser/history/history.cc index eb27b97..156f9da 100644 --- a/chrome/browser/history/history.cc +++ b/chrome/browser/history/history.cc @@ -301,10 +301,9 @@ void HistoryService::AddPage(const GURL& url, const GURL& referrer, PageTransition::Type transition, const history::RedirectList& redirects, - history::VisitSource visit_source, bool did_replace_entry) { AddPage(url, Time::Now(), id_scope, page_id, referrer, transition, redirects, - visit_source, did_replace_entry); + did_replace_entry); } void HistoryService::AddPage(const GURL& url, @@ -314,7 +313,6 @@ void HistoryService::AddPage(const GURL& url, const GURL& referrer, PageTransition::Type transition, const history::RedirectList& redirects, - history::VisitSource visit_source, bool did_replace_entry) { DCHECK(thread_) << "History service being called after cleanup"; @@ -342,8 +340,8 @@ void HistoryService::AddPage(const GURL& url, } scoped_refptr<history::HistoryAddPageArgs> request( - new history::HistoryAddPageArgs(url, time, id_scope, page_id, referrer, - redirects, transition, visit_source, + new history::HistoryAddPageArgs(url, time, id_scope, page_id, + referrer, redirects, transition, did_replace_entry)); ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::AddPage, request); } @@ -358,8 +356,7 @@ void HistoryService::AddPageWithDetails(const GURL& url, int visit_count, int typed_count, Time last_visit, - bool hidden, - history::VisitSource visit_source) { + bool hidden) { // Filter out unwanted URLs. if (!CanAddURL(url)) return; @@ -380,12 +377,11 @@ void HistoryService::AddPageWithDetails(const GURL& url, rows.push_back(row); ScheduleAndForget(PRIORITY_NORMAL, - &HistoryBackend::AddPagesWithDetails, rows, visit_source); + &HistoryBackend::AddPagesWithDetails, rows); } void HistoryService::AddPagesWithDetails( - const std::vector<history::URLRow>& info, - history::VisitSource visit_source) { + const std::vector<history::URLRow>& info) { // Add to the visited links system. VisitedLinkMaster* visited_links; @@ -401,7 +397,7 @@ void HistoryService::AddPagesWithDetails( } ScheduleAndForget(PRIORITY_NORMAL, - &HistoryBackend::AddPagesWithDetails, info, visit_source); + &HistoryBackend::AddPagesWithDetails, info); } void HistoryService::SetPageContents(const GURL& url, diff --git a/chrome/browser/history/history.h b/chrome/browser/history/history.h index 5bc3b7f..c142c97 100644 --- a/chrome/browser/history/history.h +++ b/chrome/browser/history/history.h @@ -185,7 +185,6 @@ class HistoryService : public CancelableRequestProvider, const GURL& referrer, PageTransition::Type transition, const history::RedirectList& redirects, - history::VisitSource visit_source, bool did_replace_entry); // For adding pages to history with a specific time. This is for testing @@ -197,13 +196,12 @@ class HistoryService : public CancelableRequestProvider, const GURL& referrer, PageTransition::Type transition, const history::RedirectList& redirects, - history::VisitSource visit_source, bool did_replace_entry); // For adding pages to history where no tracking information can be done. - void AddPage(const GURL& url, history::VisitSource visit_source) { - AddPage(url, NULL, 0, GURL(), PageTransition::LINK, - history::RedirectList(), visit_source, false); + void AddPage(const GURL& url) { + AddPage(url, NULL, 0, GURL(), PageTransition::LINK, history::RedirectList(), + false); } // Sets the title for the given page. The page should be in history. If it @@ -537,12 +535,10 @@ class HistoryService : public CancelableRequestProvider, int visit_count, int typed_count, base::Time last_visit, - bool hidden, - history::VisitSource visit_source); + bool hidden); // The same as AddPageWithDetails() but takes a vector. - void AddPagesWithDetails(const std::vector<history::URLRow>& info, - history::VisitSource visit_source); + void AddPagesWithDetails(const std::vector<history::URLRow>& info); // Starts the TopSites migration in the HistoryThread. Called by the // BackendDelegate. diff --git a/chrome/browser/history/history_backend.cc b/chrome/browser/history/history_backend.cc index 847dc6e..91aba75 100644 --- a/chrome/browser/history/history_backend.cc +++ b/chrome/browser/history/history_backend.cc @@ -405,7 +405,7 @@ void HistoryBackend::AddPage(scoped_refptr<HistoryAddPageArgs> request) { // No redirect case (one element means just the page itself). last_ids = AddPageVisit(request->url, last_recorded_time_, - last_ids.second, t, request->visit_source); + last_ids.second, t); // Update the segment for this visit. KEYWORD_GENERATED visits should not // result in changing most visited, so we don't update segments (most @@ -471,8 +471,7 @@ void HistoryBackend::AddPage(scoped_refptr<HistoryAddPageArgs> request) { // them anyway, and if we ever decide to, we can reconstruct their order // from the redirect chain. last_ids = AddPageVisit(request->redirects[redirect_index], - last_recorded_time_, last_ids.second, - t, request->visit_source); + last_recorded_time_, last_ids.second, t); if (t & PageTransition::CHAIN_START) { // Update the segment for this visit. UpdateSegments(request->redirects[redirect_index], @@ -652,8 +651,7 @@ std::pair<URLID, VisitID> HistoryBackend::AddPageVisit( const GURL& url, Time time, VisitID referring_visit, - PageTransition::Type transition, - VisitSource visit_source) { + PageTransition::Type transition) { // Top-level frame navigations are visible, everything else is hidden bool new_hidden = !PageTransition::IsMainFrame(transition); @@ -710,7 +708,7 @@ std::pair<URLID, VisitID> HistoryBackend::AddPageVisit( // Add the visit with the time to the database. VisitRow visit_info(url_id, time, referring_visit, transition, 0); - VisitID visit_id = db_->AddVisit(&visit_info, visit_source); + VisitID visit_id = db_->AddVisit(&visit_info); if (visit_info.visit_time < first_recorded_time_) first_recorded_time_ = visit_info.visit_time; @@ -729,8 +727,7 @@ std::pair<URLID, VisitID> HistoryBackend::AddPageVisit( return std::make_pair(url_id, visit_id); } -void HistoryBackend::AddPagesWithDetails(const std::vector<URLRow>& urls, - VisitSource visit_source) { +void HistoryBackend::AddPagesWithDetails(const std::vector<URLRow>& urls) { if (!db_.get()) return; @@ -792,7 +789,7 @@ void HistoryBackend::AddPagesWithDetails(const std::vector<URLRow>& urls, PageTransition::LINK | PageTransition::CHAIN_START | PageTransition::CHAIN_END, 0); visit_info.is_indexed = has_indexed; - if (!visit_database->AddVisit(&visit_info, visit_source)) { + if (!visit_database->AddVisit(&visit_info)) { NOTREACHED() << "Adding visit failed."; return; } @@ -909,12 +906,11 @@ bool HistoryBackend::UpdateURL(URLID id, const history::URLRow& url) { } bool HistoryBackend::AddVisits(const GURL& url, - const std::vector<base::Time>& visits, - VisitSource visit_source) { + const std::vector<base::Time>& visits) { if (db_.get()) { for (std::vector<base::Time>::const_iterator visit = visits.begin(); visit != visits.end(); ++visit) { - if (!AddPageVisit(url, *visit, 0, 0, visit_source).first) { + if (!AddPageVisit(url, *visit, 0, 0).first) { return false; } } diff --git a/chrome/browser/history/history_backend.h b/chrome/browser/history/history_backend.h index 1965bc5..4d333f3 100644 --- a/chrome/browser/history/history_backend.h +++ b/chrome/browser/history/history_backend.h @@ -258,10 +258,8 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, virtual bool UpdateURL(URLID id, const history::URLRow& url); - // While adding visits in batch, the source needs to be provided. virtual bool AddVisits(const GURL& url, - const std::vector<base::Time>& visits, - VisitSource visit_source); + const std::vector<base::Time>& visits); virtual bool RemoveVisits(const VisitVector& visits); @@ -294,9 +292,7 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, // Adds the given rows to the database if it doesn't exist. A visit will be // added for each given URL at the last visit time in the URLRow. - // Each visit will have the visit_source type set. - void AddPagesWithDetails(const std::vector<URLRow>& info, - VisitSource visit_source); + void AddPagesWithDetails(const std::vector<URLRow>& info); #if defined(UNIT_TEST) HistoryDatabase* db() const { return db_.get(); } @@ -316,11 +312,6 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, URLsNoLongerBookmarked); FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, StripUsernamePasswordTest); FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, DeleteThumbnailsDatabaseTest); - FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, AddPageVisitSource); - FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, AddPageArgsSource); - FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, AddVisitsSource); - FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, RemoveVisitsSource); - FRIEND_TEST_ALL_PREFIXES(HistoryBackendTest, MigrationVisitSource); friend class ::TestingProfile; // Computes the name of the specified database on disk. @@ -348,8 +339,7 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>, std::pair<URLID, VisitID> AddPageVisit(const GURL& url, base::Time time, VisitID referring_visit, - PageTransition::Type transition, - VisitSource visit_source); + PageTransition::Type transition); // Returns a redirect chain in |redirects| for the VisitID // |cur_visit|. |cur_visit| is assumed to be valid. Assumes that diff --git a/chrome/browser/history/history_backend_unittest.cc b/chrome/browser/history/history_backend_unittest.cc index 568fd4f..fe36c9d 100644 --- a/chrome/browser/history/history_backend_unittest.cc +++ b/chrome/browser/history/history_backend_unittest.cc @@ -15,8 +15,6 @@ #include "chrome/browser/history/history_notifications.h" #include "chrome/browser/history/in_memory_history_backend.h" #include "chrome/browser/history/in_memory_database.h" -#include "chrome/common/chrome_constants.h" -#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/notification_service.h" #include "chrome/common/thumbnail_score.h" @@ -77,7 +75,7 @@ class HistoryBackendTest : public testing::Test { scoped_refptr<history::HistoryAddPageArgs> request( new history::HistoryAddPageArgs( redirects.back(), Time::Now(), scope, page_id, GURL(), - redirects, PageTransition::LINK, history::SOURCE_BROWSED, true)); + redirects, PageTransition::LINK, true)); backend_->AddPage(request); } @@ -97,8 +95,7 @@ class HistoryBackendTest : public testing::Test { redirects.push_back(url2); scoped_refptr<HistoryAddPageArgs> request( new HistoryAddPageArgs(url2, base::Time(), dummy_scope, 0, url1, - redirects, PageTransition::CLIENT_REDIRECT, - history::SOURCE_BROWSED, did_replace)); + redirects, PageTransition::CLIENT_REDIRECT, did_replace)); backend_->AddPage(request); *transition1 = getTransition(url1); @@ -115,10 +112,6 @@ class HistoryBackendTest : public testing::Test { return visits[0].transition; } - FilePath getTestDir() { - return test_dir_; - } - BookmarkModel bookmark_model_; protected: @@ -222,7 +215,7 @@ TEST_F(HistoryBackendTest, DeleteAll) { std::vector<URLRow> rows; rows.push_back(row2); // Reversed order for the same reason as favicons. rows.push_back(row1); - backend_->AddPagesWithDetails(rows, history::SOURCE_BROWSED); + backend_->AddPagesWithDetails(rows); URLID row1_id = backend_->db_->GetRowForURL(row1.url(), NULL); URLID row2_id = backend_->db_->GetRowForURL(row2.url(), NULL); @@ -352,7 +345,7 @@ TEST_F(HistoryBackendTest, URLsNoLongerBookmarked) { std::vector<URLRow> rows; rows.push_back(row2); // Reversed order for the same reason as favicons. rows.push_back(row1); - backend_->AddPagesWithDetails(rows, history::SOURCE_BROWSED); + backend_->AddPagesWithDetails(rows); URLID row1_id = backend_->db_->GetRowForURL(row1.url(), NULL); URLID row2_id = backend_->db_->GetRowForURL(row2.url(), NULL); @@ -461,8 +454,7 @@ TEST_F(HistoryBackendTest, KeywordGenerated) { scoped_refptr<HistoryAddPageArgs> request( new HistoryAddPageArgs(url, visit_time, NULL, 0, GURL(), history::RedirectList(), - PageTransition::KEYWORD_GENERATED, - history::SOURCE_BROWSED, false)); + PageTransition::KEYWORD_GENERATED, false)); backend_->AddPage(request); // A row should have been added for the url. @@ -545,7 +537,7 @@ TEST_F(HistoryBackendTest, ImportedFaviconsTest) { std::vector<URLRow> rows; rows.push_back(row1); rows.push_back(row2); - backend_->AddPagesWithDetails(rows, history::SOURCE_BROWSED); + backend_->AddPagesWithDetails(rows); URLRow url_row1, url_row2; EXPECT_FALSE(backend_->db_->GetRowForURL(row1.url(), &url_row1) == 0); EXPECT_FALSE(backend_->db_->GetRowForURL(row2.url(), &url_row2) == 0); @@ -600,8 +592,7 @@ TEST_F(HistoryBackendTest, StripUsernamePasswordTest) { // Visit the url with username, password. backend_->AddPageVisit(url, base::Time::Now(), 0, - PageTransition::GetQualifier(PageTransition::TYPED), - history::SOURCE_BROWSED); + PageTransition::GetQualifier(PageTransition::TYPED)); // Fetch the row information about stripped url from history db. VisitVector visits; @@ -621,214 +612,4 @@ TEST_F(HistoryBackendTest, DeleteThumbnailsDatabaseTest) { EXPECT_FALSE(backend_->thumbnail_db_->NeedsMigrationToTopSites()); } -TEST_F(HistoryBackendTest, AddPageVisitSource) { - ASSERT_TRUE(backend_.get()); - - GURL url("http://www.google.com"); - - // Clear all history. - backend_->DeleteAllHistory(); - - // Assume visiting the url from an externsion. - backend_->AddPageVisit(url, base::Time::Now(), 0, PageTransition::TYPED, - history::SOURCE_EXTENSION); - // Assume the url is imported from Firefox. - backend_->AddPageVisit(url, base::Time::Now(), 0, PageTransition::TYPED, - history::SOURCE_FIREFOX_IMPORTED); - // Assume this url is also synced. - backend_->AddPageVisit(url, base::Time::Now(), 0, PageTransition::TYPED, - history::SOURCE_SYNCED); - - // Fetch the row information about the url from history db. - VisitVector visits; - URLID row_id = backend_->db_->GetRowForURL(url, NULL); - backend_->db_->GetVisitsForURL(row_id, &visits); - - // Check if all the visits to the url are stored in database. - ASSERT_EQ(3U, visits.size()); - VisitSourceMap visit_sources; - backend_->db_->GetVisitsSource(visits, &visit_sources); - ASSERT_EQ(3U, visit_sources.size()); - int sources = 0; - for (int i = 0; i < 3; i++) { - switch (visit_sources[visits[i].visit_id]) { - case history::SOURCE_EXTENSION: - sources |= 0x1; - break; - case history::SOURCE_FIREFOX_IMPORTED: - sources |= 0x2; - break; - case history::SOURCE_SYNCED: - sources |= 0x4; - default: - break; - } - } - EXPECT_EQ(0x7, sources); -} - -TEST_F(HistoryBackendTest, AddPageArgsSource) { - ASSERT_TRUE(backend_.get()); - - GURL url("http://testpageargs.com"); - - // Assume this page is browsed by user. - scoped_refptr<HistoryAddPageArgs> request1( - new HistoryAddPageArgs(url, base::Time::Now(), NULL, 0, GURL(), - history::RedirectList(), - PageTransition::KEYWORD_GENERATED, - history::SOURCE_BROWSED, false)); - backend_->AddPage(request1); - // Assume this page is synced. - scoped_refptr<HistoryAddPageArgs> request2( - new HistoryAddPageArgs(url, base::Time::Now(), NULL, 0, GURL(), - history::RedirectList(), - PageTransition::LINK, - history::SOURCE_SYNCED, false)); - backend_->AddPage(request2); - // Assume this page is browsed again. - scoped_refptr<HistoryAddPageArgs> request3( - new HistoryAddPageArgs(url, base::Time::Now(), NULL, 0, GURL(), - history::RedirectList(), - PageTransition::TYPED, - history::SOURCE_BROWSED, false)); - backend_->AddPage(request3); - - // Three visits should be added with proper sources. - VisitVector visits; - URLRow row; - URLID id = backend_->db()->GetRowForURL(url, &row); - ASSERT_TRUE(backend_->db()->GetVisitsForURL(id, &visits)); - ASSERT_EQ(3U, visits.size()); - VisitSourceMap visit_sources; - backend_->db_->GetVisitsSource(visits, &visit_sources); - ASSERT_EQ(1U, visit_sources.size()); - EXPECT_EQ(history::SOURCE_SYNCED, visit_sources.begin()->second); -} - -TEST_F(HistoryBackendTest, AddVisitsSource) { - ASSERT_TRUE(backend_.get()); - - GURL url1("http://www.cnn.com"); - std::vector<base::Time> visits1; - visits1.push_back(Time::Now() - base::TimeDelta::FromDays(5)); - visits1.push_back(Time::Now() - base::TimeDelta::FromDays(1)); - visits1.push_back(Time::Now()); - - GURL url2("http://www.example.com"); - std::vector<base::Time> visits2; - visits2.push_back(Time::Now() - base::TimeDelta::FromDays(10)); - visits2.push_back(Time::Now()); - - // Clear all history. - backend_->DeleteAllHistory(); - - // Add the visits. - backend_->AddVisits(url1, visits1, history::SOURCE_IE_IMPORTED); - backend_->AddVisits(url2, visits2, history::SOURCE_SYNCED); - - // Verify the visits were added with their sources. - VisitVector visits; - URLRow row; - URLID id = backend_->db()->GetRowForURL(url1, &row); - ASSERT_TRUE(backend_->db()->GetVisitsForURL(id, &visits)); - ASSERT_EQ(3U, visits.size()); - VisitSourceMap visit_sources; - backend_->db_->GetVisitsSource(visits, &visit_sources); - ASSERT_EQ(3U, visit_sources.size()); - for (int i = 0; i < 3; i++) - EXPECT_EQ(history::SOURCE_IE_IMPORTED, visit_sources[visits[i].visit_id]); - id = backend_->db()->GetRowForURL(url2, &row); - ASSERT_TRUE(backend_->db()->GetVisitsForURL(id, &visits)); - ASSERT_EQ(2U, visits.size()); - backend_->db_->GetVisitsSource(visits, &visit_sources); - ASSERT_EQ(2U, visit_sources.size()); - for (int i = 0; i < 2; i++) - EXPECT_EQ(history::SOURCE_SYNCED, visit_sources[visits[i].visit_id]); -} - -TEST_F(HistoryBackendTest, RemoveVisitsSource) { - ASSERT_TRUE(backend_.get()); - - GURL url1("http://www.cnn.com"); - std::vector<base::Time> visits1; - visits1.push_back(Time::Now() - base::TimeDelta::FromDays(5)); - visits1.push_back(Time::Now()); - - GURL url2("http://www.example.com"); - std::vector<base::Time> visits2; - visits2.push_back(Time::Now() - base::TimeDelta::FromDays(10)); - visits2.push_back(Time::Now()); - - // Clear all history. - backend_->DeleteAllHistory(); - - // Add the visits. - backend_->AddVisits(url1, visits1, history::SOURCE_IE_IMPORTED); - backend_->AddVisits(url2, visits2, history::SOURCE_SYNCED); - - // Verify the visits of url1 were added. - VisitVector visits; - URLRow row; - URLID id = backend_->db()->GetRowForURL(url1, &row); - ASSERT_TRUE(backend_->db()->GetVisitsForURL(id, &visits)); - ASSERT_EQ(2U, visits.size()); - // Remove these visits. - ASSERT_TRUE(backend_->RemoveVisits(visits)); - - // Now check only url2's source in visit_source table. - VisitSourceMap visit_sources; - backend_->db_->GetVisitsSource(visits, &visit_sources); - ASSERT_EQ(0U, visit_sources.size()); - id = backend_->db()->GetRowForURL(url2, &row); - ASSERT_TRUE(backend_->db()->GetVisitsForURL(id, &visits)); - ASSERT_EQ(2U, visits.size()); - backend_->db_->GetVisitsSource(visits, &visit_sources); - ASSERT_EQ(2U, visit_sources.size()); - for (int i = 0; i < 2; i++) - EXPECT_EQ(history::SOURCE_SYNCED, visit_sources[visits[i].visit_id]); -} - -// Test for migration of adding visit_source table. -TEST_F(HistoryBackendTest, MigrationVisitSource) { - ASSERT_TRUE(backend_.get()); - - FilePath old_history_path; - ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &old_history_path)); - old_history_path = old_history_path.AppendASCII("History"); - old_history_path = old_history_path.AppendASCII("HistoryNoSource"); - - // Copy history database file to current directory so that it will be deleted - // in Teardown. - FilePath new_history_path(getTestDir()); - file_util::Delete(new_history_path, true); - file_util::CreateDirectory(new_history_path); - FilePath new_history_file = new_history_path.Append(chrome::kHistoryFilename); - ASSERT_TRUE(file_util::CopyFile(old_history_path, new_history_file)); - - backend_->Closing(); - backend_ = new HistoryBackend(new_history_path, - new HistoryBackendTestDelegate(this), - &bookmark_model_); - backend_->Init(false); - - // Now the database should already be migrated. - // Check version first. - int cur_version = HistoryDatabase::GetCurrentVersion(); - sql::Connection db; - ASSERT_TRUE(db.Open(new_history_file)); - sql::Statement s(db.GetUniqueStatement( - "SELECT value FROM meta WHERE key = 'version'")); - ASSERT_TRUE(s.Step()); - int file_version = s.ColumnInt(0); - EXPECT_EQ(cur_version, file_version); - - // Check visit_source table is created and empty. - s.Assign(db.GetUniqueStatement( - "SELECT name FROM sqlite_master WHERE name=\"visit_source\"")); - ASSERT_TRUE(s.Step()); - s.Assign(db.GetUniqueStatement("SELECT * FROM visit_source LIMIT 10")); - EXPECT_FALSE(s.Step()); -} - } // namespace history diff --git a/chrome/browser/history/history_database.cc b/chrome/browser/history/history_database.cc index 4fab291..7869fcc 100644 --- a/chrome/browser/history/history_database.cc +++ b/chrome/browser/history/history_database.cc @@ -26,7 +26,7 @@ namespace { // Current version number. We write databases at the "current" version number, // but any previous version that can read the "compatible" one can make do with // or database without *too* many bad effects. -static const int kCurrentVersionNumber = 19; +static const int kCurrentVersionNumber = 18; static const int kCompatibleVersionNumber = 16; static const char kEarlyExpirationThresholdKey[] = "early_expiration_threshold"; @@ -134,7 +134,7 @@ void HistoryDatabase::BeginExclusiveMode() { // static int HistoryDatabase::GetCurrentVersion() { - // If we don't use TopSites, we stay at the last pre-TopSites version. + // If we don't use TopSites, we are one version number behind. if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoTopSites)) return 17; // Last pre-TopSites version. else @@ -284,19 +284,12 @@ sql::InitStatus HistoryDatabase::EnsureCurrentVersion( needs_version_18_migration_ = true; if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoTopSites) && - (cur_version == 18 || cur_version == 19)) { + cur_version == 18) { // Set DB version back to pre-top sites. cur_version = 17; meta_table_.SetVersionNumber(cur_version); } - if (needs_version_18_migration_ || cur_version == 18) { - // This is the version prior to adding url_source column. We need to - // migrate the database. - cur_version = 19; - meta_table_.SetVersionNumber(cur_version); - } - // When the version is too old, we just try to continue anyway, there should // not be a released product that makes a database too old for us to handle. LOG_IF(WARNING, (cur_version < GetCurrentVersion() && @@ -332,13 +325,9 @@ void HistoryDatabase::MigrateTimeEpoch() { #endif void HistoryDatabase::MigrationToTopSitesDone() { - // Migration should only happen for version 17 and 19. - int version = meta_table_.GetVersionNumber(); - DCHECK(17 == version || 19 == version); - if (17 == version) { - // We should be migrating from 17 to 18. - meta_table_.SetVersionNumber(18); - } + // We should be migrating from 17 to 18. + DCHECK_EQ(17, meta_table_.GetVersionNumber()); + meta_table_.SetVersionNumber(18); needs_version_18_migration_ = false; } diff --git a/chrome/browser/history/history_marshaling.h b/chrome/browser/history/history_marshaling.h index e746d20..64cde29 100644 --- a/chrome/browser/history/history_marshaling.h +++ b/chrome/browser/history/history_marshaling.h @@ -30,7 +30,6 @@ class HistoryAddPageArgs const GURL& arg_referrer, const history::RedirectList& arg_redirects, PageTransition::Type arg_transition, - VisitSource arg_source, bool arg_did_replace_entry) : url(arg_url), time(arg_time), @@ -39,7 +38,6 @@ class HistoryAddPageArgs referrer(arg_referrer), redirects(arg_redirects), transition(arg_transition), - visit_source(arg_source), did_replace_entry(arg_did_replace_entry) { } @@ -52,7 +50,6 @@ class HistoryAddPageArgs GURL referrer; history::RedirectList redirects; PageTransition::Type transition; - VisitSource visit_source; bool did_replace_entry; private: diff --git a/chrome/browser/history/history_querying_unittest.cc b/chrome/browser/history/history_querying_unittest.cc index 7dbf5d1..7512786 100644 --- a/chrome/browser/history/history_querying_unittest.cc +++ b/chrome/browser/history/history_querying_unittest.cc @@ -111,7 +111,7 @@ class HistoryQueryTest : public testing::Test { history_->AddPage(url, test_entries[i].time, id_scope, page_id, GURL(), PageTransition::LINK, history::RedirectList(), - history::SOURCE_BROWSED, false); + false); history_->SetPageTitle(url, UTF8ToUTF16(test_entries[i].title)); history_->SetPageContents(url, UTF8ToUTF16(test_entries[i].body)); } @@ -314,7 +314,7 @@ TEST_F(HistoryQueryTest, FTSArchived) { row2.set_last_visit(Time::Now()); urls_to_add.push_back(row2); - history_->AddPagesWithDetails(urls_to_add, history::SOURCE_BROWSED); + history_->AddPagesWithDetails(urls_to_add); QueryOptions options; QueryResults results; diff --git a/chrome/browser/history/history_types.h b/chrome/browser/history/history_types.h index de4b88c..21e8067 100644 --- a/chrome/browser/history/history_types.h +++ b/chrome/browser/history/history_types.h @@ -176,27 +176,9 @@ class URLRow { // We support the implicit copy constuctor and operator=. }; -// The enumeration of all possible sources of visits is listed below. -// The source will be propogated along with a URL or a visit item -// and eventually be stored in the history database, -// visit_source table specifically. -// Different from page transition types, they describe the origins of visits. -// (Warning): Please don't change any existing values while it is ok to add -// new values when needed. -typedef enum { - SOURCE_SYNCED = 0, // Synchronized from somewhere else. - SOURCE_BROWSED = 1, // User browsed. - SOURCE_EXTENSION = 2, // Added by an externsion. - SOURCE_FIREFOX_IMPORTED = 3, - SOURCE_IE_IMPORTED = 4, - SOURCE_SAFARI_IMPORTED = 5, -} VisitSource; +// VisitRow ------------------------------------------------------------------- typedef int64 VisitID; -// Structure to hold the mapping between each visit's id and its source. -typedef std::map<VisitID, VisitSource> VisitSourceMap; - -// VisitRow ------------------------------------------------------------------- // Holds all information associated with a specific visit. A visit holds time // and referrer information for one time a URL is visited. diff --git a/chrome/browser/history/history_unittest.cc b/chrome/browser/history/history_unittest.cc index 255e466..063414f 100644 --- a/chrome/browser/history/history_unittest.cc +++ b/chrome/browser/history/history_unittest.cc @@ -415,8 +415,7 @@ TEST_F(HistoryTest, AddPage) { const GURL test_url("http://www.google.com/"); history->AddPage(test_url, NULL, 0, GURL(), PageTransition::MANUAL_SUBFRAME, - history::RedirectList(), - history::SOURCE_BROWSED, false); + history::RedirectList(), false); EXPECT_TRUE(QueryURL(history, test_url)); EXPECT_EQ(1, query_url_row_.visit_count()); EXPECT_EQ(0, query_url_row_.typed_count()); @@ -424,8 +423,7 @@ TEST_F(HistoryTest, AddPage) { // Add the page once from the main frame (should unhide it). history->AddPage(test_url, NULL, 0, GURL(), PageTransition::LINK, - history::RedirectList(), - history::SOURCE_BROWSED, false); + history::RedirectList(), false); EXPECT_TRUE(QueryURL(history, test_url)); EXPECT_EQ(2, query_url_row_.visit_count()); // Added twice. EXPECT_EQ(0, query_url_row_.typed_count()); // Never typed. @@ -448,16 +446,14 @@ TEST_F(HistoryTest, AddPageSameTimes) { // additions have different timestamps. history->AddPage(test_urls[0], now, NULL, 0, GURL(), PageTransition::LINK, - history::RedirectList(), - history::SOURCE_BROWSED, false); + history::RedirectList(), false); EXPECT_TRUE(QueryURL(history, test_urls[0])); EXPECT_EQ(1, query_url_row_.visit_count()); EXPECT_TRUE(now == query_url_row_.last_visit()); // gtest doesn't like Time history->AddPage(test_urls[1], now, NULL, 0, GURL(), PageTransition::LINK, - history::RedirectList(), - history::SOURCE_BROWSED, false); + history::RedirectList(), false); EXPECT_TRUE(QueryURL(history, test_urls[1])); EXPECT_EQ(1, query_url_row_.visit_count()); EXPECT_TRUE(now + TimeDelta::FromMicroseconds(1) == @@ -467,8 +463,7 @@ TEST_F(HistoryTest, AddPageSameTimes) { history->AddPage(test_urls[2], now + TimeDelta::FromMinutes(1), NULL, 0, GURL(), PageTransition::LINK, - history::RedirectList(), - history::SOURCE_BROWSED, false); + history::RedirectList(), false); EXPECT_TRUE(QueryURL(history, test_urls[2])); EXPECT_EQ(1, query_url_row_.visit_count()); EXPECT_TRUE(now + TimeDelta::FromMinutes(1) == @@ -491,8 +486,7 @@ TEST_F(HistoryTest, AddRedirect) { // Add the sequence of pages as a server with no referrer. Note that we need // to have a non-NULL page ID scope. history->AddPage(first_redirects.back(), MakeFakeHost(1), 0, GURL(), - PageTransition::LINK, first_redirects, - history::SOURCE_BROWSED, true); + PageTransition::LINK, first_redirects, true); // The first page should be added once with a link visit type (because we set // LINK when we added the original URL, and a referrer of nowhere (0). @@ -530,7 +524,7 @@ TEST_F(HistoryTest, AddRedirect) { second_redirects[0], static_cast<PageTransition::Type>(PageTransition::LINK | PageTransition::CLIENT_REDIRECT), - second_redirects, history::SOURCE_BROWSED, true); + second_redirects, true); // The last page (source of the client redirect) should NOT have an // additional visit added, because it was a client redirect (normally it @@ -555,8 +549,7 @@ TEST_F(HistoryTest, Typed) { // Add the page once as typed. const GURL test_url("http://www.google.com/"); history->AddPage(test_url, NULL, 0, GURL(), PageTransition::TYPED, - history::RedirectList(), - history::SOURCE_BROWSED, false); + history::RedirectList(), false); EXPECT_TRUE(QueryURL(history, test_url)); // We should have the same typed & visit count. @@ -565,8 +558,7 @@ TEST_F(HistoryTest, Typed) { // Add the page again not typed. history->AddPage(test_url, NULL, 0, GURL(), PageTransition::LINK, - history::RedirectList(), - history::SOURCE_BROWSED, false); + history::RedirectList(), false); EXPECT_TRUE(QueryURL(history, test_url)); // The second time should not have updated the typed count. @@ -576,7 +568,7 @@ TEST_F(HistoryTest, Typed) { // Add the page again as a generated URL. history->AddPage(test_url, NULL, 0, GURL(), PageTransition::GENERATED, history::RedirectList(), - history::SOURCE_BROWSED, false); + false); EXPECT_TRUE(QueryURL(history, test_url)); // This should have worked like a link click. @@ -586,7 +578,7 @@ TEST_F(HistoryTest, Typed) { // Add the page again as a reload. history->AddPage(test_url, NULL, 0, GURL(), PageTransition::RELOAD, history::RedirectList(), - history::SOURCE_BROWSED, false); + false); EXPECT_TRUE(QueryURL(history, test_url)); // This should not have incremented any visit counts. @@ -601,7 +593,7 @@ TEST_F(HistoryTest, SetTitle) { // Add a URL. const GURL existing_url("http://www.google.com/"); - history->AddPage(existing_url, history::SOURCE_BROWSED); + history->AddPage(existing_url); // Set some title. const string16 existing_title = UTF8ToUTF16("Google"); @@ -636,7 +628,7 @@ TEST_F(HistoryTest, Segments) { const GURL existing_url("http://www.google.com/"); history->AddPage(existing_url, scope, 0, GURL(), PageTransition::TYPED, history::RedirectList(), - history::SOURCE_BROWSED, false); + false); // Make sure a segment was created. history->QuerySegmentUsageSince( @@ -655,7 +647,7 @@ TEST_F(HistoryTest, Segments) { const GURL link_url("http://yahoo.com/"); history->AddPage(link_url, scope, 0, GURL(), PageTransition::LINK, history::RedirectList(), - history::SOURCE_BROWSED, false); + false); // Query again history->QuerySegmentUsageSince( @@ -673,7 +665,7 @@ TEST_F(HistoryTest, Segments) { // Add a page linked from existing_url. history->AddPage(GURL("http://www.google.com/foo"), scope, 3, existing_url, PageTransition::LINK, history::RedirectList(), - history::SOURCE_BROWSED, false); + false); // Query again history->QuerySegmentUsageSince( @@ -707,8 +699,7 @@ TEST_F(HistoryTest, Thumbnails) { static const double boringness = 0.25; const GURL url("http://www.google.com/thumbnail_test/"); - // Must be visited before adding a thumbnail. - history->AddPage(url, history::SOURCE_BROWSED); + history->AddPage(url); // Must be visited before adding a thumbnail. history->SetPageThumbnail(url, *thumbnail, ThumbnailScore(boringness, true, true)); @@ -775,10 +766,10 @@ TEST_F(HistoryTest, MostVisitedURLs) { // Add two pages. history->AddPage(url0, scope, 0, GURL(), PageTransition::TYPED, history::RedirectList(), - history::SOURCE_BROWSED, false); + false); history->AddPage(url1, scope, 0, GURL(), PageTransition::TYPED, history::RedirectList(), - history::SOURCE_BROWSED, false); + false); history->QueryMostVisitedURLs(20, 90, &consumer_, NewCallback(static_cast<HistoryTest*>(this), &HistoryTest::OnMostVisitedURLsAvailable)); @@ -791,7 +782,7 @@ TEST_F(HistoryTest, MostVisitedURLs) { // Add another page. history->AddPage(url2, scope, 0, GURL(), PageTransition::TYPED, history::RedirectList(), - history::SOURCE_BROWSED, false); + false); history->QueryMostVisitedURLs(20, 90, &consumer_, NewCallback(static_cast<HistoryTest*>(this), &HistoryTest::OnMostVisitedURLsAvailable)); @@ -805,7 +796,7 @@ TEST_F(HistoryTest, MostVisitedURLs) { // Revisit url2, making it the top URL. history->AddPage(url2, scope, 0, GURL(), PageTransition::TYPED, history::RedirectList(), - history::SOURCE_BROWSED, false); + false); history->QueryMostVisitedURLs(20, 90, &consumer_, NewCallback(static_cast<HistoryTest*>(this), &HistoryTest::OnMostVisitedURLsAvailable)); @@ -819,7 +810,7 @@ TEST_F(HistoryTest, MostVisitedURLs) { // Revisit url1, making it the top URL. history->AddPage(url1, scope, 0, GURL(), PageTransition::TYPED, history::RedirectList(), - history::SOURCE_BROWSED, false); + false); history->QueryMostVisitedURLs(20, 90, &consumer_, NewCallback(static_cast<HistoryTest*>(this), &HistoryTest::OnMostVisitedURLsAvailable)); @@ -838,7 +829,7 @@ TEST_F(HistoryTest, MostVisitedURLs) { // Visit url4 using redirects. history->AddPage(url4, scope, 0, GURL(), PageTransition::TYPED, redirects, - history::SOURCE_BROWSED, false); + false); history->QueryMostVisitedURLs(20, 90, &consumer_, NewCallback(static_cast<HistoryTest*>(this), &HistoryTest::OnMostVisitedURLsAvailable)); @@ -896,8 +887,7 @@ HistoryAddPageArgs* MakeAddArgs(const GURL& url) { 0, GURL(), history::RedirectList(), - PageTransition::TYPED, - history::SOURCE_BROWSED, false); + PageTransition::TYPED, false); } // Convenience version of the above to convert a char string. diff --git a/chrome/browser/history/text_database_manager_unittest.cc b/chrome/browser/history/text_database_manager_unittest.cc index 1ec7744..8e7f27e 100644 --- a/chrome/browser/history/text_database_manager_unittest.cc +++ b/chrome/browser/history/text_database_manager_unittest.cc @@ -79,7 +79,7 @@ void AddAllPages(TextDatabaseManager& manager, VisitDatabase* visit_db, visit_row.transition = 0; visit_row.segment_id = 0; visit_row.is_indexed = false; - VisitID visit_id = visit_db->AddVisit(&visit_row, SOURCE_BROWSED); + VisitID visit_id = visit_db->AddVisit(&visit_row); times->push_back(visit_row.visit_time); manager.AddPageData(GURL(kURL1), visit_row.url_id, visit_row.visit_id, @@ -89,7 +89,7 @@ void AddAllPages(TextDatabaseManager& manager, VisitDatabase* visit_db, exploded.day_of_month++; visit_row.url_id = 2; visit_row.visit_time = Time::FromUTCExploded(exploded); - visit_id = visit_db->AddVisit(&visit_row, SOURCE_BROWSED); + visit_id = visit_db->AddVisit(&visit_row); times->push_back(visit_row.visit_time); manager.AddPageData(GURL(kURL2), visit_row.url_id, visit_row.visit_id, visit_row.visit_time, UTF8ToUTF16(kTitle2), @@ -98,7 +98,7 @@ void AddAllPages(TextDatabaseManager& manager, VisitDatabase* visit_db, exploded.day_of_month++; visit_row.url_id = 2; visit_row.visit_time = Time::FromUTCExploded(exploded); - visit_id = visit_db->AddVisit(&visit_row, SOURCE_BROWSED); + visit_id = visit_db->AddVisit(&visit_row); times->push_back(visit_row.visit_time); manager.AddPageData(GURL(kURL3), visit_row.url_id, visit_row.visit_id, visit_row.visit_time, UTF8ToUTF16(kTitle3), @@ -108,7 +108,7 @@ void AddAllPages(TextDatabaseManager& manager, VisitDatabase* visit_db, exploded.month++; visit_row.url_id = 2; visit_row.visit_time = Time::FromUTCExploded(exploded); - visit_id = visit_db->AddVisit(&visit_row, SOURCE_BROWSED); + visit_id = visit_db->AddVisit(&visit_row); times->push_back(visit_row.visit_time); manager.AddPageData(GURL(kURL4), visit_row.url_id, visit_row.visit_id, visit_row.visit_time, UTF8ToUTF16(kTitle4), @@ -117,7 +117,7 @@ void AddAllPages(TextDatabaseManager& manager, VisitDatabase* visit_db, exploded.day_of_month++; visit_row.url_id = 2; visit_row.visit_time = Time::FromUTCExploded(exploded); - visit_id = visit_db->AddVisit(&visit_row, SOURCE_BROWSED); + visit_id = visit_db->AddVisit(&visit_row); times->push_back(visit_row.visit_time); manager.AddPageData(GURL(kURL5), visit_row.url_id, visit_row.visit_id, visit_row.visit_time, UTF8ToUTF16(kTitle5), @@ -127,7 +127,7 @@ void AddAllPages(TextDatabaseManager& manager, VisitDatabase* visit_db, exploded.day_of_month++; visit_row.url_id = 2; visit_row.visit_time = Time::FromUTCExploded(exploded); - visit_id = visit_db->AddVisit(&visit_row, SOURCE_BROWSED); + visit_id = visit_db->AddVisit(&visit_row); times->push_back(visit_row.visit_time); manager.AddPageData(GURL(kURL1), visit_row.url_id, visit_row.visit_id, visit_row.visit_time, UTF8ToUTF16(kTitle1), @@ -242,7 +242,7 @@ TEST_F(TextDatabaseManagerTest, InsertCompleteVisit) { visit.transition = PageTransition::LINK; visit.segment_id = 0; visit.is_indexed = false; - visit_db.AddVisit(&visit, SOURCE_BROWSED); + visit_db.AddVisit(&visit); // Add a full text indexed entry for that visit. const GURL url(kURL2); @@ -335,7 +335,7 @@ TEST_F(TextDatabaseManagerTest, PartialComplete) { VisitRow visit_row; visit_row.url_id = url_id; visit_row.visit_time = added_time; - visit_db.AddVisit(&visit_row, SOURCE_BROWSED); + visit_db.AddVisit(&visit_row); // Add a URL with no title or body, and say that it expired. manager.AddPageURL(url, 0, 0, added_time); diff --git a/chrome/browser/history/thumbnail_database.cc b/chrome/browser/history/thumbnail_database.cc index ecc7a3c..979accf 100644 --- a/chrome/browser/history/thumbnail_database.cc +++ b/chrome/browser/history/thumbnail_database.cc @@ -499,8 +499,7 @@ bool ThumbnailDatabase::RenameAndDropThumbnails(const FilePath& old_db_file, favicons.Close(); // Can't attach within a transaction. - if (transaction_nesting()) - CommitTransaction(); + CommitTransaction(); // Attach new DB. { diff --git a/chrome/browser/history/visit_database.cc b/chrome/browser/history/visit_database.cc index d0156c2..75c91ee 100644 --- a/chrome/browser/history/visit_database.cc +++ b/chrome/browser/history/visit_database.cc @@ -11,7 +11,6 @@ #include "app/sql/statement.h" #include "base/logging.h" -#include "base/string_number_conversions.h" #include "chrome/browser/history/url_database.h" #include "chrome/common/page_transition_types.h" #include "chrome/common/url_constants.h" @@ -51,17 +50,6 @@ bool VisitDatabase::InitVisitTable() { return false; } - // Visit source table contains the source information for all the visits. To - // save space, we do not record those user browsed visits which would be the - // majority in this table. Only other sources are recorded. - // Due to the tight relationship between visit_source and visits table, they - // should be created and dropped at the same time. - if (!GetDB().DoesTableExist("visit_source")) { - if (!GetDB().Execute("CREATE TABLE visit_source(" - "id INTEGER PRIMARY KEY,source INTEGER NOT NULL)")) - return false; - } - // Index over url so we can quickly find visits for a page. This will just // fail if it already exists and we'll ignore it. GetDB().Execute("CREATE INDEX visits_url_index ON visits (url)"); @@ -79,7 +67,6 @@ bool VisitDatabase::InitVisitTable() { } bool VisitDatabase::DropVisitTable() { - GetDB().Execute("DROP TABLE visit_source"); // This will also drop the indices over the table. return GetDB().Execute("DROP TABLE visits"); } @@ -106,7 +93,7 @@ void VisitDatabase::FillVisitVector(sql::Statement& statement, } } -VisitID VisitDatabase::AddVisit(VisitRow* visit, VisitSource source) { +VisitID VisitDatabase::AddVisit(VisitRow* visit) { sql::Statement statement(GetDB().GetCachedStatement(SQL_FROM_HERE, "INSERT INTO visits " "(url, visit_time, from_visit, transition, segment_id, is_indexed) " @@ -124,20 +111,6 @@ VisitID VisitDatabase::AddVisit(VisitRow* visit, VisitSource source) { return 0; visit->visit_id = GetDB().GetLastInsertRowId(); - - if (source != SOURCE_BROWSED) { - // Record the source of this visit when it is not browsed. - sql::Statement statement1(GetDB().GetCachedStatement(SQL_FROM_HERE, - "INSERT INTO visit_source (id, source) VALUES (?,?)")); - if (!statement1.is_valid()) - return 0; - - statement1.BindInt64(0, visit->visit_id); - statement1.BindInt64(1, source); - if (!statement1.Run()) - return 0; - } - return visit->visit_id; } @@ -159,16 +132,6 @@ void VisitDatabase::DeleteVisit(const VisitRow& visit) { return; del.BindInt64(0, visit.visit_id); del.Run(); - - // Try to delete the entry in visit_source table as well. - // If the visit was browsed, there is no corresponding entry in visit_source - // table, and nothing will be deleted. - del.Assign(GetDB().GetCachedStatement(SQL_FROM_HERE, - "DELETE FROM visit_source WHERE id=?")); - if (!del.is_valid()) - return; - del.BindInt64(0, visit.visit_id); - del.Run(); } bool VisitDatabase::GetRowForVisit(VisitID visit_id, VisitRow* out_visit) { @@ -473,42 +436,4 @@ bool VisitDatabase::GetStartDate(base::Time* first_visit) { return true; } -void VisitDatabase::GetVisitsSource(const VisitVector& visits, - VisitSourceMap* sources) { - DCHECK(sources); - sources->clear(); - - // We query the source in batch. Here defines the batch size. - const size_t batch_size = 500; - size_t visits_size = visits.size(); - - size_t start_index = 0, end_index = 0; - while (end_index < visits_size) { - start_index = end_index; - end_index = end_index + batch_size < visits_size ? end_index + batch_size - : visits_size; - - // Compose the sql statement with a list of ids. - std::string sql = "SELECT id,source FROM visit_source "; - sql.append("WHERE id IN ("); - // Append all the ids in the statement. - for (size_t j = start_index; j < end_index; j++) { - if (j != start_index) - sql.push_back(','); - sql.append(base::Int64ToString(visits[j].visit_id)); - } - sql.append(") ORDER BY id"); - sql::Statement statement(GetDB().GetUniqueStatement(sql.c_str())); - if (!statement) - return; - - // Get the source entries out of the query result. - while (statement.Step()) { - std::pair<VisitID, VisitSource> source_entry(statement.ColumnInt64(0), - static_cast<VisitSource>(statement.ColumnInt(1))); - sources->insert(source_entry); - } - } -} - } // namespace history diff --git a/chrome/browser/history/visit_database.h b/chrome/browser/history/visit_database.h index 0e97cac..3731c4a 100644 --- a/chrome/browser/history/visit_database.h +++ b/chrome/browser/history/visit_database.h @@ -34,9 +34,8 @@ class VisitDatabase { // Adds a line to the visit database with the given information, returning // the added row ID on success, 0 on failure. The given visit is updated with - // the new row ID on success. In addition, adds its source into visit_source - // table. - VisitID AddVisit(VisitRow* visit, VisitSource source); + // the new row ID on success. + VisitID AddVisit(VisitRow* visit); // Deletes the given visit from the database. If a visit with the given ID // doesn't exist, it will not do anything. @@ -145,10 +144,6 @@ class VisitDatabase { // Get the time of the first item in our database. bool GetStartDate(base::Time* first_visit); - // Get the source information about the given visits. - void GetVisitsSource(const VisitVector& visits, - VisitSourceMap* sources); - protected: // Returns the database for the functions in this interface. virtual sql::Connection& GetDB() = 0; diff --git a/chrome/browser/history/visit_database_unittest.cc b/chrome/browser/history/visit_database_unittest.cc index 28a0e15..ebc2e1b 100644 --- a/chrome/browser/history/visit_database_unittest.cc +++ b/chrome/browser/history/visit_database_unittest.cc @@ -73,19 +73,19 @@ class VisitDatabaseTest : public PlatformTest, TEST_F(VisitDatabaseTest, Add) { // Add one visit. VisitRow visit_info1(1, Time::Now(), 0, PageTransition::LINK, 0); - EXPECT_TRUE(AddVisit(&visit_info1, SOURCE_BROWSED)); + EXPECT_TRUE(AddVisit(&visit_info1)); // Add second visit for the same page. VisitRow visit_info2(visit_info1.url_id, visit_info1.visit_time + TimeDelta::FromSeconds(1), 1, PageTransition::TYPED, 0); - EXPECT_TRUE(AddVisit(&visit_info2, SOURCE_BROWSED)); + EXPECT_TRUE(AddVisit(&visit_info2)); // Add third visit for a different page. VisitRow visit_info3(2, visit_info1.visit_time + TimeDelta::FromSeconds(2), 0, PageTransition::LINK, 0); - EXPECT_TRUE(AddVisit(&visit_info3, SOURCE_BROWSED)); + EXPECT_TRUE(AddVisit(&visit_info3)); // Query the first two. std::vector<VisitRow> matches; @@ -104,17 +104,17 @@ TEST_F(VisitDatabaseTest, Delete) { static const int kTime1 = 1000; VisitRow visit_info1(1, Time::FromInternalValue(kTime1), 0, PageTransition::LINK, 0); - EXPECT_TRUE(AddVisit(&visit_info1, SOURCE_BROWSED)); + EXPECT_TRUE(AddVisit(&visit_info1)); static const int kTime2 = kTime1 + 1; VisitRow visit_info2(1, Time::FromInternalValue(kTime2), visit_info1.visit_id, PageTransition::LINK, 0); - EXPECT_TRUE(AddVisit(&visit_info2, SOURCE_BROWSED)); + EXPECT_TRUE(AddVisit(&visit_info2)); static const int kTime3 = kTime2 + 1; VisitRow visit_info3(1, Time::FromInternalValue(kTime3), visit_info2.visit_id, PageTransition::LINK, 0); - EXPECT_TRUE(AddVisit(&visit_info3, SOURCE_BROWSED)); + EXPECT_TRUE(AddVisit(&visit_info3)); // First make sure all the visits are there. std::vector<VisitRow> matches; @@ -140,7 +140,7 @@ TEST_F(VisitDatabaseTest, Delete) { TEST_F(VisitDatabaseTest, Update) { // Make something in the database. VisitRow original(1, Time::Now(), 23, 22, 19); - AddVisit(&original, SOURCE_BROWSED); + AddVisit(&original); // Mutate that row. VisitRow modification(original); @@ -167,7 +167,7 @@ TEST_F(VisitDatabaseTest, GetVisibleVisitsInRange) { PageTransition::CHAIN_END), 0); visit_info1.visit_id = 1; - EXPECT_TRUE(AddVisit(&visit_info1, SOURCE_BROWSED)); + EXPECT_TRUE(AddVisit(&visit_info1)); // Add second visit for the same page. VisitRow visit_info2(visit_info1.url_id, @@ -177,7 +177,7 @@ TEST_F(VisitDatabaseTest, GetVisibleVisitsInRange) { PageTransition::CHAIN_END), 0); visit_info2.visit_id = 2; - EXPECT_TRUE(AddVisit(&visit_info2, SOURCE_BROWSED)); + EXPECT_TRUE(AddVisit(&visit_info2)); // Add third visit for a different page. VisitRow visit_info3(2, @@ -186,7 +186,7 @@ TEST_F(VisitDatabaseTest, GetVisibleVisitsInRange) { PageTransition::CHAIN_START), 0); visit_info3.visit_id = 3; - EXPECT_TRUE(AddVisit(&visit_info3, SOURCE_BROWSED)); + EXPECT_TRUE(AddVisit(&visit_info3)); // Add a redirect visit from the last page. VisitRow visit_info4(3, @@ -195,7 +195,7 @@ TEST_F(VisitDatabaseTest, GetVisibleVisitsInRange) { PageTransition::CHAIN_END), 0); visit_info4.visit_id = 4; - EXPECT_TRUE(AddVisit(&visit_info4, SOURCE_BROWSED)); + EXPECT_TRUE(AddVisit(&visit_info4)); // Add a subframe visit. VisitRow visit_info5(4, @@ -205,7 +205,7 @@ TEST_F(VisitDatabaseTest, GetVisibleVisitsInRange) { PageTransition::CHAIN_END), 0); visit_info5.visit_id = 5; - EXPECT_TRUE(AddVisit(&visit_info5, SOURCE_BROWSED)); + EXPECT_TRUE(AddVisit(&visit_info5)); // Query the visits for all time, we should not get the first (duplicate of // the second) or the redirect or subframe visits. @@ -227,37 +227,4 @@ TEST_F(VisitDatabaseTest, GetVisibleVisitsInRange) { ASSERT_EQ(static_cast<size_t>(1), results.size()); EXPECT_TRUE(IsVisitInfoEqual(results[0], visit_info4)); } - -TEST_F(VisitDatabaseTest, VisitSource) { - // Add visits. - VisitRow visit_info1(111, Time::Now(), 0, PageTransition::LINK, 0); - ASSERT_TRUE(AddVisit(&visit_info1, SOURCE_BROWSED)); - - VisitRow visit_info2(112, Time::Now(), 1, PageTransition::TYPED, 0); - ASSERT_TRUE(AddVisit(&visit_info2, SOURCE_SYNCED)); - - VisitRow visit_info3(113, Time::Now(), 0, PageTransition::TYPED, 0); - ASSERT_TRUE(AddVisit(&visit_info3, SOURCE_EXTENSION)); - - // Query each visit. - std::vector<VisitRow> matches; - ASSERT_TRUE(GetVisitsForURL(111, &matches)); - ASSERT_EQ(1U, matches.size()); - VisitSourceMap sources; - GetVisitsSource(matches, &sources); - EXPECT_EQ(0U, sources.size()); - - ASSERT_TRUE(GetVisitsForURL(112, &matches)); - ASSERT_EQ(1U, matches.size()); - GetVisitsSource(matches, &sources); - ASSERT_EQ(1U, sources.size()); - EXPECT_EQ(SOURCE_SYNCED, sources[matches[0].visit_id]); - - ASSERT_TRUE(GetVisitsForURL(113, &matches)); - ASSERT_EQ(1U, matches.size()); - GetVisitsSource(matches, &sources); - ASSERT_EQ(1U, sources.size()); - EXPECT_EQ(SOURCE_EXTENSION, sources[matches[0].visit_id]); -} - } // namespace history diff --git a/chrome/browser/importer/firefox3_importer.cc b/chrome/browser/importer/firefox3_importer.cc index 76613b6..4bac89a 100644 --- a/chrome/browser/importer/firefox3_importer.cc +++ b/chrome/browser/importer/firefox3_importer.cc @@ -119,7 +119,7 @@ void Firefox3Importer::ImportHistory() { rows.push_back(row); } if (!rows.empty() && !cancelled()) { - bridge_->SetHistoryItems(rows, history::SOURCE_FIREFOX_IMPORTED); + bridge_->SetHistoryItems(rows); } } diff --git a/chrome/browser/importer/ie_importer.cc b/chrome/browser/importer/ie_importer.cc index 5f0adca..ab0a61c 100644 --- a/chrome/browser/importer/ie_importer.cc +++ b/chrome/browser/importer/ie_importer.cc @@ -330,7 +330,7 @@ void IEImporter::ImportHistory() { } if (!rows.empty() && !cancelled()) { - bridge_->SetHistoryItems(rows, history::SOURCE_IE_IMPORTED); + bridge_->SetHistoryItems(rows); } } } diff --git a/chrome/browser/importer/importer.cc b/chrome/browser/importer/importer.cc index 3c840f0..4217a80 100644 --- a/chrome/browser/importer/importer.cc +++ b/chrome/browser/importer/importer.cc @@ -505,16 +505,14 @@ void ExternalProcessImporterClient::OnHistoryImportStart( } void ExternalProcessImporterClient::OnHistoryImportGroup( - const std::vector<history::URLRow>& history_rows_group, - int visit_source) { + const std::vector<history::URLRow> &history_rows_group) { if (cancelled_) return; history_rows_.insert(history_rows_.end(), history_rows_group.begin(), history_rows_group.end()); if (history_rows_.size() == total_history_rows_count_) - bridge_->SetHistoryItems(history_rows_, - static_cast<history::VisitSource>(visit_source)); + bridge_->SetHistoryItems(history_rows_); } void ExternalProcessImporterClient::OnHomePageImportReady( diff --git a/chrome/browser/importer/importer.h b/chrome/browser/importer/importer.h index e9197ad..8dc42fd 100644 --- a/chrome/browser/importer/importer.h +++ b/chrome/browser/importer/importer.h @@ -344,10 +344,8 @@ class ExternalProcessImporterClient virtual void OnHistoryImportStart(size_t total_history_rows_count); // Called when a group of URLRows has been received. - // The source is passed with history::VisitSource type. virtual void OnHistoryImportGroup( - const std::vector<history::URLRow> &history_rows_group, - int visit_source); + const std::vector<history::URLRow> &history_rows_group); // Called when the home page has been received. virtual void OnHomePageImportReady(const GURL& home_page); diff --git a/chrome/browser/importer/importer_bridge.cc b/chrome/browser/importer/importer_bridge.cc index 079ebe3..5ab94da 100644 --- a/chrome/browser/importer/importer_bridge.cc +++ b/chrome/browser/importer/importer_bridge.cc @@ -61,12 +61,10 @@ void InProcessImporterBridge::SetFavIcons( } void InProcessImporterBridge::SetHistoryItems( - const std::vector<history::URLRow> &rows, - history::VisitSource visit_source) { + const std::vector<history::URLRow> &rows) { ChromeThread::PostTask( ChromeThread::UI, FROM_HERE, - NewRunnableMethod(writer_, &ProfileWriter::AddHistoryPage, - rows, visit_source)); + NewRunnableMethod(writer_, &ProfileWriter::AddHistoryPage, rows)); } void InProcessImporterBridge::SetKeywords( @@ -152,9 +150,8 @@ void ExternalProcessImporterBridge::SetFavIcons( } void ExternalProcessImporterBridge::SetHistoryItems( - const std::vector<history::URLRow> &rows, - history::VisitSource visit_source) { - profile_import_thread_->NotifyHistoryImportReady(rows, visit_source); + const std::vector<history::URLRow> &rows) { + profile_import_thread_->NotifyHistoryImportReady(rows); } void ExternalProcessImporterBridge::SetKeywords( diff --git a/chrome/browser/importer/importer_bridge.h b/chrome/browser/importer/importer_bridge.h index 8b57ab0..3d7d62b 100644 --- a/chrome/browser/importer/importer_bridge.h +++ b/chrome/browser/importer/importer_bridge.h @@ -38,8 +38,7 @@ class ImporterBridge : public base::RefCountedThreadSafe<ImporterBridge> { virtual void SetFavIcons( const std::vector<history::ImportedFavIconUsage>& fav_icons) = 0; - virtual void SetHistoryItems(const std::vector<history::URLRow> &rows, - history::VisitSource visit_source) = 0; + virtual void SetHistoryItems(const std::vector<history::URLRow> &rows) = 0; virtual void SetKeywords(const std::vector<TemplateURL*> &template_urls, int default_keyword_index, bool unique_on_host_and_path) = 0; @@ -96,8 +95,7 @@ class InProcessImporterBridge : public ImporterBridge { virtual void SetFavIcons( const std::vector<history::ImportedFavIconUsage>& fav_icons); - virtual void SetHistoryItems(const std::vector<history::URLRow> &rows, - history::VisitSource visit_source); + virtual void SetHistoryItems(const std::vector<history::URLRow> &rows); virtual void SetKeywords(const std::vector<TemplateURL*>& template_urls, int default_keyword_index, bool unique_on_host_and_path); @@ -142,8 +140,7 @@ class ExternalProcessImporterBridge : public ImporterBridge { virtual void SetFavIcons( const std::vector<history::ImportedFavIconUsage>& fav_icons); - virtual void SetHistoryItems(const std::vector<history::URLRow> &rows, - history::VisitSource visit_source); + virtual void SetHistoryItems(const std::vector<history::URLRow> &rows); virtual void SetKeywords(const std::vector<TemplateURL*>& template_urls, int default_keyword_index, bool unique_on_host_and_path); diff --git a/chrome/browser/importer/importer_messages_internal.h b/chrome/browser/importer/importer_messages_internal.h index 980e397b..b247237 100644 --- a/chrome/browser/importer/importer_messages_internal.h +++ b/chrome/browser/importer/importer_messages_internal.h @@ -49,10 +49,8 @@ IPC_BEGIN_MESSAGES(ProfileImportProcessHost) IPC_MESSAGE_CONTROL1(ProfileImportProcessHostMsg_NotifyHistoryImportStart, int /* total number of history::URLRow items */) - IPC_MESSAGE_CONTROL2(ProfileImportProcessHostMsg_NotifyHistoryImportGroup, - std::vector<history::URLRow>, - int /* the source of URLs as in history::VisitSource.*/ - /* To simplify IPC call, pass as an integer */) + IPC_MESSAGE_CONTROL1(ProfileImportProcessHostMsg_NotifyHistoryImportGroup, + std::vector<history::URLRow>) IPC_MESSAGE_CONTROL1(ProfileImportProcessHostMsg_NotifyHomePageImportReady, GURL /* GURL of home page */) diff --git a/chrome/browser/importer/importer_unittest.cc b/chrome/browser/importer/importer_unittest.cc index 879d7cb..930d57d 100644 --- a/chrome/browser/importer/importer_unittest.cc +++ b/chrome/browser/importer/importer_unittest.cc @@ -259,15 +259,12 @@ class TestObserver : public ProfileWriter, ++password_count_; } - virtual void AddHistoryPage(const std::vector<history::URLRow>& page, - history::VisitSource visit_source) { + virtual void AddHistoryPage(const std::vector<history::URLRow>& page) { // Importer should read the specified URL. - for (size_t i = 0; i < page.size(); ++i) { + for (size_t i = 0; i < page.size(); ++i) if (page[i].title() == kIEIdentifyTitle && page[i].url() == GURL(kIEIdentifyUrl)) ++history_count_; - } - EXPECT_EQ(history::SOURCE_IE_IMPORTED, visit_source); } virtual void AddBookmarkEntry(const std::vector<BookmarkEntry>& bookmark, @@ -613,12 +610,10 @@ class FirefoxObserver : public ProfileWriter, ++password_count_; } - virtual void AddHistoryPage(const std::vector<history::URLRow>& page, - history::VisitSource visit_source) { + virtual void AddHistoryPage(const std::vector<history::URLRow>& page) { ASSERT_EQ(1U, page.size()); EXPECT_EQ("http://en-us.www.mozilla.com/", page[0].url().spec()); EXPECT_EQ(ASCIIToUTF16("Firefox Updated"), page[0].title()); - EXPECT_EQ(history::SOURCE_FIREFOX_IMPORTED, visit_source); ++history_count_; } @@ -811,8 +806,7 @@ class Firefox3Observer : public ProfileWriter, ++password_count_; } - virtual void AddHistoryPage(const std::vector<history::URLRow>& page, - history::VisitSource visit_source) { + virtual void AddHistoryPage(const std::vector<history::URLRow>& page) { ASSERT_EQ(3U, page.size()); EXPECT_EQ("http://www.google.com/", page[0].url().spec()); EXPECT_EQ(ASCIIToUTF16("Google"), page[0].title()); @@ -821,7 +815,6 @@ class Firefox3Observer : public ProfileWriter, EXPECT_EQ("http://www.cs.unc.edu/~jbs/resources/perl/perl-cgi/programs/form1-POST.html", page[2].url().spec()); EXPECT_EQ(ASCIIToUTF16("example form (POST)"), page[2].title()); - EXPECT_EQ(history::SOURCE_FIREFOX_IMPORTED, visit_source); ++history_count_; } diff --git a/chrome/browser/importer/mork_reader.cc b/chrome/browser/importer/mork_reader.cc index ce1ffe8..4207ad6 100644 --- a/chrome/browser/importer/mork_reader.cc +++ b/chrome/browser/importer/mork_reader.cc @@ -584,5 +584,5 @@ void ImportHistoryFromFirefox2(const FilePath& file, ImporterBridge* bridge) { for (MorkReader::iterator i = reader.begin(); i != reader.end(); ++i) AddToHistory(i->second, data, &rows); if (!rows.empty()) - bridge->SetHistoryItems(rows, history::SOURCE_FIREFOX_IMPORTED); + bridge->SetHistoryItems(rows); } diff --git a/chrome/browser/importer/profile_writer.cc b/chrome/browser/importer/profile_writer.cc index 0cd9a77..32f183d 100644 --- a/chrome/browser/importer/profile_writer.cc +++ b/chrome/browser/importer/profile_writer.cc @@ -36,10 +36,9 @@ void ProfileWriter::AddIE7PasswordInfo(const IE7PasswordInfo& info) { } #endif -void ProfileWriter::AddHistoryPage(const std::vector<history::URLRow>& page, - history::VisitSource visit_source) { +void ProfileWriter::AddHistoryPage(const std::vector<history::URLRow>& page) { profile_->GetHistoryService(Profile::EXPLICIT_ACCESS)-> - AddPagesWithDetails(page, visit_source); + AddPagesWithDetails(page); } void ProfileWriter::AddHomepage(const GURL& home_page) { diff --git a/chrome/browser/importer/profile_writer.h b/chrome/browser/importer/profile_writer.h index a8571cb..44d4a87 100644 --- a/chrome/browser/importer/profile_writer.h +++ b/chrome/browser/importer/profile_writer.h @@ -12,7 +12,6 @@ #include "base/ref_counted.h" #include "base/time.h" #include "chrome/browser/bookmarks/bookmark_model_observer.h" -#include "chrome/browser/history/history_types.h" #include "googleurl/src/gurl.h" class Profile; @@ -73,8 +72,7 @@ class ProfileWriter : public base::RefCountedThreadSafe<ProfileWriter> { #if defined(OS_WIN) virtual void AddIE7PasswordInfo(const IE7PasswordInfo& info); #endif - virtual void AddHistoryPage(const std::vector<history::URLRow>& page, - history::VisitSource visit_source); + virtual void AddHistoryPage(const std::vector<history::URLRow>& page); virtual void AddHomepage(const GURL& homepage); // Adds the bookmarks to the BookmarkModel. // |options| is a bitmask of BookmarkOptions and dictates how and diff --git a/chrome/browser/importer/safari_importer.mm b/chrome/browser/importer/safari_importer.mm index 3ff4676..43e7c28 100644 --- a/chrome/browser/importer/safari_importer.mm +++ b/chrome/browser/importer/safari_importer.mm @@ -317,7 +317,7 @@ void SafariImporter::ImportHistory() { ParseHistoryItems(&rows); if (!rows.empty() && !cancelled()) { - bridge_->SetHistoryItems(rows, history::SOURCE_SAFARI_IMPORTED); + bridge_->SetHistoryItems(rows); } } diff --git a/chrome/browser/profile_import_process_host.h b/chrome/browser/profile_import_process_host.h index 8b0d9a3..72754c6 100644 --- a/chrome/browser/profile_import_process_host.h +++ b/chrome/browser/profile_import_process_host.h @@ -51,8 +51,7 @@ class ProfileImportProcessHost : public BrowserChildProcessHost { // the external process to the process host client. virtual void OnHistoryImportStart(size_t total_history_rows_count) {} virtual void OnHistoryImportGroup( - const std::vector<history::URLRow> &history_rows_group, - int visit_source) {} // visit_source has history::VisitSource type. + const std::vector<history::URLRow> &history_rows_group) {} virtual void OnHomePageImportReady( const GURL& home_page) {} diff --git a/chrome/browser/search_engines/template_url_model.cc b/chrome/browser/search_engines/template_url_model.cc index 5f2d5fb..d777225 100644 --- a/chrome/browser/search_engines/template_url_model.cc +++ b/chrome/browser/search_engines/template_url_model.cc @@ -1009,7 +1009,7 @@ void TemplateURLModel::AddTabToSearchVisit(const TemplateURL& t_url) { // autocompleted even if the user doesn't type the url in directly. history->AddPage(url, NULL, 0, GURL(), PageTransition::KEYWORD_GENERATED, - history::RedirectList(), history::SOURCE_BROWSED, false); + history::RedirectList(), false); } // static diff --git a/chrome/browser/search_engines/template_url_model_unittest.cc b/chrome/browser/search_engines/template_url_model_unittest.cc index 5e174e3..baee15a 100644 --- a/chrome/browser/search_engines/template_url_model_unittest.cc +++ b/chrome/browser/search_engines/template_url_model_unittest.cc @@ -689,7 +689,7 @@ TEST_F(TemplateURLModelTest, GenerateVisitOnKeyword) { GURL(t_url->url()->ReplaceSearchTerms(*t_url, L"blah", 0, std::wstring())), NULL, 0, GURL(), PageTransition::KEYWORD, history::RedirectList(), - history::SOURCE_BROWSED, false); + false); // Wait for history to finish processing the request. profile_->BlockUntilHistoryProcessesPendingRequests(); diff --git a/chrome/browser/sync/glue/bookmark_change_processor.cc b/chrome/browser/sync/glue/bookmark_change_processor.cc index 00ed6a2..7ebd8bf 100644 --- a/chrome/browser/sync/glue/bookmark_change_processor.cc +++ b/chrome/browser/sync/glue/bookmark_change_processor.cc @@ -520,7 +520,7 @@ bool BookmarkChangeProcessor::SetBookmarkFavicon( FaviconService* favicon_service = profile->GetFaviconService(Profile::EXPLICIT_ACCESS); - history->AddPage(bookmark_node->GetURL(), history::SOURCE_SYNCED); + history->AddPage(bookmark_node->GetURL()); favicon_service->SetFavicon(bookmark_node->GetURL(), fake_icon_url, icon_bytes_vector); diff --git a/chrome/browser/sync/glue/typed_url_model_associator.cc b/chrome/browser/sync/glue/typed_url_model_associator.cc index d5bf3f1..3cca88a 100644 --- a/chrome/browser/sync/glue/typed_url_model_associator.cc +++ b/chrome/browser/sync/glue/typed_url_model_associator.cc @@ -280,7 +280,7 @@ bool TypedUrlModelAssociator::WriteToHistoryBackend( } } if (new_urls) { - history_backend_->AddPagesWithDetails(*new_urls, history::SOURCE_SYNCED); + history_backend_->AddPagesWithDetails(*new_urls); } if (updated_urls) { for (TypedUrlUpdateVector::const_iterator url = updated_urls->begin(); @@ -294,8 +294,7 @@ bool TypedUrlModelAssociator::WriteToHistoryBackend( if (new_visits) { for (TypedUrlVisitVector::const_iterator visits = new_visits->begin(); visits != new_visits->end(); ++visits) { - if (!history_backend_->AddVisits(visits->first, visits->second, - history::SOURCE_SYNCED)) { + if (!history_backend_->AddVisits(visits->first, visits->second)) { LOG(ERROR) << "Could not add visits."; return false; } diff --git a/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc b/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc index 17137ea4..331f466 100644 --- a/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_typed_url_unittest.cc @@ -78,9 +78,8 @@ class HistoryBackendMock : public HistoryBackend { MOCK_METHOD2(GetVisitsForURL, bool(history::URLID id, history::VisitVector* visits)); MOCK_METHOD2(UpdateURL, bool(history::URLID id, const history::URLRow& url)); - MOCK_METHOD3(AddVisits, bool(const GURL& url, - const std::vector<base::Time>& visits, - history::VisitSource visit_source)); + MOCK_METHOD2(AddVisits, bool(const GURL& url, + const std::vector<base::Time>& visits)); MOCK_METHOD1(RemoveVisits, bool(const history::VisitVector& visits)); MOCK_METHOD2(GetURL, bool(const GURL& url_id, history::URLRow* url_row)); MOCK_METHOD2(SetPageTitle, void(const GURL& url, const std::wstring& title)); @@ -341,8 +340,8 @@ TEST_F(ProfileSyncServiceTypedUrlTest, HasNativeHasSyncNoMerge) { WillOnce(DoAll(SetArgumentPointee<0>(native_entries), Return(true))); EXPECT_CALL((*history_backend_.get()), GetVisitsForURL(_, _)). WillRepeatedly(DoAll(SetArgumentPointee<1>(native_visits), Return(true))); - EXPECT_CALL((*history_backend_.get()), - AddVisits(_, _, history::SOURCE_SYNCED)).WillRepeatedly(Return(true)); + EXPECT_CALL((*history_backend_.get()), AddVisits(_, _)). + WillRepeatedly(Return(true)); std::vector<history::URLRow> sync_entries; sync_entries.push_back(sync_entry); @@ -386,8 +385,8 @@ TEST_F(ProfileSyncServiceTypedUrlTest, HasNativeHasSyncMerge) { WillOnce(DoAll(SetArgumentPointee<0>(native_entries), Return(true))); EXPECT_CALL((*history_backend_.get()), GetVisitsForURL(_, _)). WillRepeatedly(DoAll(SetArgumentPointee<1>(native_visits), Return(true))); - EXPECT_CALL((*history_backend_.get()), - AddVisits(_, _, history::SOURCE_SYNCED)). WillRepeatedly(Return(true)); + EXPECT_CALL((*history_backend_.get()), AddVisits(_, _)). + WillRepeatedly(Return(true)); std::vector<history::URLRow> sync_entries; sync_entries.push_back(sync_entry); diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index f8f1b88..ddeb0fe 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -1745,11 +1745,10 @@ void TabContents::UpdateHistoryForNavigation( if (!redirects.empty()) redirects.back() = virtual_url; hs->AddPage(virtual_url, this, params.page_id, params.referrer, - params.transition, redirects, history::SOURCE_BROWSED, - details.did_replace_entry); + params.transition, redirects, details.did_replace_entry); } else { hs->AddPage(params.url, this, params.page_id, params.referrer, - params.transition, params.redirects, history::SOURCE_BROWSED, + params.transition, params.redirects, details.did_replace_entry); } } diff --git a/chrome/browser/visitedlink_unittest.cc b/chrome/browser/visitedlink_unittest.cc index b534c41..c69c745 100644 --- a/chrome/browser/visitedlink_unittest.cc +++ b/chrome/browser/visitedlink_unittest.cc @@ -371,7 +371,7 @@ TEST_F(VisitedLinkTest, Rebuild) { // initialize the visited link DB. int history_count = g_test_count / 2; for (int i = 0; i < history_count; i++) - history_service_->AddPage(TestURL(i), history::SOURCE_BROWSED); + history_service_->AddPage(TestURL(i)); // Initialize the visited link DB. Since the visited links file doesn't exist // and we don't suppress history rebuilding, this will load from history. diff --git a/chrome/profile_import/profile_import_thread.cc b/chrome/profile_import/profile_import_thread.cc index 6f097b3..e9ba2a5 100644 --- a/chrome/profile_import/profile_import_thread.cc +++ b/chrome/profile_import/profile_import_thread.cc @@ -105,8 +105,7 @@ void ProfileImportThread::NotifyEnded() { } void ProfileImportThread::NotifyHistoryImportReady( - const std::vector<history::URLRow> &rows, - history::VisitSource visit_source) { + const std::vector<history::URLRow> &rows) { Send(new ProfileImportProcessHostMsg_NotifyHistoryImportStart(rows.size())); std::vector<history::URLRow>::const_iterator it; @@ -118,8 +117,7 @@ void ProfileImportThread::NotifyHistoryImportReady( it + kNumHistoryRowsToSend : rows.end(); row_group.assign(it, end_group); - Send(new ProfileImportProcessHostMsg_NotifyHistoryImportGroup(row_group, - visit_source)); + Send(new ProfileImportProcessHostMsg_NotifyHistoryImportGroup(row_group)); } } diff --git a/chrome/profile_import/profile_import_thread.h b/chrome/profile_import/profile_import_thread.h index f780cc5..47f2015 100644 --- a/chrome/profile_import/profile_import_thread.h +++ b/chrome/profile_import/profile_import_thread.h @@ -42,8 +42,7 @@ class ProfileImportThread : public ChildThread { void NotifyEnded(); // Bridging methods that move data back across the process boundary. - void NotifyHistoryImportReady(const std::vector<history::URLRow> &rows, - history::VisitSource visit_source); + void NotifyHistoryImportReady(const std::vector<history::URLRow> &rows); void NotifyHomePageImportReady(const GURL& home_page); void NotifyBookmarksImportReady( const std::vector<ProfileWriter::BookmarkEntry>& bookmarks, diff --git a/chrome/tools/profiles/generate_profile.cc b/chrome/tools/profiles/generate_profile.cc index 9dc7512..2900c28 100644 --- a/chrome/tools/profiles/generate_profile.cc +++ b/chrome/tools/profiles/generate_profile.cc @@ -152,7 +152,7 @@ void InsertURLBatch(const std::wstring& profile_dir, int page_id, history_service->AddPage(url, id_scope, page_id, previous_url, transition, - redirects, history::SOURCE_BROWSED, true); + redirects, true); ThumbnailScore score(0.75, false, false); history_service->SetPageTitle(url, ConstructRandomTitle()); if (!history_only) { |