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

Unified Diff: chrome/browser/history/history.cc

Issue 11784006: Revert "Remove VisitedLink dependency on rest of chrome" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/history/history.h ('k') | chrome/browser/history/history_backend.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/history/history.cc
diff --git a/chrome/browser/history/history.cc b/chrome/browser/history/history.cc
index 50450bcdc96b210b394406eb245ac37d1cf83b8f..ae0f69a3e98c8c99b1019d1bfe3f4c2fac062fe7 100644
--- a/chrome/browser/history/history.cc
+++ b/chrome/browser/history/history.cc
@@ -111,29 +111,6 @@ void RunWithFaviconResults(
callback.Run(results->bitmap_results, results->size_map);
}
-// Extract history::URLRows into GURLs for VisitedLinkMaster.
-class URLIteratorFromURLRows : public VisitedLinkMaster::URLIterator {
- public:
- explicit URLIteratorFromURLRows(const history::URLRows& url_rows)
- : itr_(url_rows.begin()),
- end_(url_rows.end()) {
- }
-
- virtual const GURL& NextURL() OVERRIDE {
- return (itr_++)->url();
- }
-
- virtual bool HasNextURL() const OVERRIDE {
- return itr_ != end_;
- }
-
- private:
- history::URLRows::const_iterator itr_;
- history::URLRows::const_iterator end_;
-
- DISALLOW_COPY_AND_ASSIGN(URLIteratorFromURLRows);
-};
-
} // namespace
// Sends messages from the backend to us on the main thread. This must be a
@@ -231,8 +208,6 @@ HistoryService::HistoryService(Profile* profile)
: weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
thread_(new base::Thread(kHistoryThreadName)),
profile_(profile),
- visitedlink_master_(new VisitedLinkMaster(
- profile, ALLOW_THIS_IN_INITIALIZER_LIST(this))),
backend_loaded_(false),
current_backend_id_(-1),
bookmark_service_(NULL),
@@ -497,8 +472,10 @@ void HistoryService::AddPage(const history::HistoryAddPageArgs& add_page_args) {
return;
// Add link & all redirects to visited link list.
- if (visitedlink_master_) {
- visitedlink_master_->AddURL(add_page_args.url);
+ VisitedLinkMaster* visited_links;
+ if (profile_ &&
+ (visited_links = VisitedLinkMaster::FromProfile(profile_))) {
+ visited_links->AddURL(add_page_args.url);
if (!add_page_args.redirects.empty()) {
// We should not be asked to add a page in the middle of a redirect chain.
@@ -508,7 +485,7 @@ void HistoryService::AddPage(const history::HistoryAddPageArgs& add_page_args) {
// We need the !redirects.empty() condition above since size_t is unsigned
// and will wrap around when we subtract one from a 0 size.
for (size_t i = 0; i < add_page_args.redirects.size() - 1; i++)
- visitedlink_master_->AddURL(add_page_args.redirects[i]);
+ visited_links->AddURL(add_page_args.redirects[i]);
}
}
@@ -553,8 +530,11 @@ void HistoryService::AddPageWithDetails(const GURL& url,
return;
// Add to the visited links system.
- if (visitedlink_master_)
- visitedlink_master_->AddURL(url);
+ VisitedLinkMaster* visited_links;
+ if (profile_ &&
+ (visited_links = VisitedLinkMaster::FromProfile(profile_))) {
+ visited_links->AddURL(url);
+ }
history::URLRow row(url);
row.set_title(title);
@@ -574,14 +554,16 @@ void HistoryService::AddPagesWithDetails(const history::URLRows& info,
history::VisitSource visit_source) {
DCHECK(thread_checker_.CalledOnValidThread());
// Add to the visited links system.
- if (visitedlink_master_) {
+ VisitedLinkMaster* visited_links;
+ if (profile_ &&
+ (visited_links = VisitedLinkMaster::FromProfile(profile_))) {
std::vector<GURL> urls;
urls.reserve(info.size());
for (history::URLRows::const_iterator i = info.begin(); i != info.end();
++i)
urls.push_back(i->url());
- visitedlink_master_->AddURLs(urls);
+ visited_links->AddURLs(urls);
}
ScheduleAndForget(PRIORITY_NORMAL,
@@ -738,6 +720,11 @@ void HistoryService::SetImportedFavicons(
&HistoryBackend::SetImportedFavicons, favicon_usage);
}
+void HistoryService::IterateURLs(URLEnumerator* enumerator) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::IterateURLs, enumerator);
+}
+
HistoryService::Handle HistoryService::QueryURL(
const GURL& url,
bool want_visits,
@@ -915,16 +902,17 @@ void HistoryService::Observe(int type,
// delete notifications are by time. We would also like to be more
// respectful of privacy and never tell the user something is gone when it
// isn't. Therefore, we update the delete URLs after the fact.
- if (visitedlink_master_) {
- content::Details<history::URLsDeletedDetails> deleted_details(details);
-
- if (deleted_details->all_history) {
- visitedlink_master_->DeleteAllURLs();
- } else {
- URLIteratorFromURLRows iterator(deleted_details->rows);
- visitedlink_master_->DeleteURLs(&iterator);
- }
- }
+ if (!profile_)
+ return; // No profile, probably unit testing.
+ content::Details<history::URLsDeletedDetails> deleted_details(details);
+ VisitedLinkMaster* visited_links =
+ VisitedLinkMaster::FromProfile(profile_);
+ if (!visited_links)
+ return; // Nobody to update.
+ if (deleted_details->all_history)
+ visited_links->DeleteAllURLs();
+ else // Delete individual ones.
+ visited_links->DeleteURLs(deleted_details->rows);
break;
}
@@ -938,22 +926,6 @@ void HistoryService::Observe(int type,
}
}
-bool HistoryService::AreEquivalentContexts(content::BrowserContext* context1,
- content::BrowserContext* context2) {
- DCHECK(context1);
- DCHECK(context2);
-
- Profile* profile1 = Profile::FromBrowserContext(context1);
- Profile* profile2 = Profile::FromBrowserContext(context2);
-
- return profile1->IsSameProfile(profile2);
-}
-
-void HistoryService::RebuildTable(URLEnumerator* enumerator) {
- DCHECK(thread_checker_.CalledOnValidThread());
- ScheduleAndForget(PRIORITY_NORMAL, &HistoryBackend::IterateURLs, enumerator);
-}
-
bool HistoryService::Init(const FilePath& history_dir,
BookmarkService* bookmark_service,
bool no_db) {
@@ -977,12 +949,6 @@ bool HistoryService::Init(const FilePath& history_dir,
// Create the history backend.
LoadBackendIfNecessary();
-
- if (visitedlink_master_) {
- bool result = visitedlink_master_->Init();
- DCHECK(result);
- }
-
return true;
}
« no previous file with comments | « chrome/browser/history/history.h ('k') | chrome/browser/history/history_backend.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698