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

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

Issue 631253002: Refactor sending NOTIFICATION_HISTORY_URL_VISITED (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests on Android Created 6 years, 2 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/in_memory_history_backend.h ('k') | chrome/browser/history/in_memory_url_index.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/history/in_memory_history_backend.cc
diff --git a/chrome/browser/history/in_memory_history_backend.cc b/chrome/browser/history/in_memory_history_backend.cc
index e630a095f3f3e319ba11b8c0cb131336126668c5..baac0e427643228e10c78709afd1e2db8ad39e5c 100644
--- a/chrome/browser/history/in_memory_history_backend.cc
+++ b/chrome/browser/history/in_memory_history_backend.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/history/history_notifications.h"
+#include "chrome/browser/history/history_service.h"
#include "chrome/browser/profiles/profile.h"
#include "components/history/core/browser/in_memory_database.h"
#include "components/history/core/browser/url_database.h"
@@ -22,22 +23,31 @@
namespace history {
InMemoryHistoryBackend::InMemoryHistoryBackend()
- : profile_(NULL) {
+ : profile_(nullptr), history_service_(nullptr) {
}
-InMemoryHistoryBackend::~InMemoryHistoryBackend() {}
+InMemoryHistoryBackend::~InMemoryHistoryBackend() {
+ if (history_service_)
+ history_service_->RemoveObserver(this);
+}
bool InMemoryHistoryBackend::Init(const base::FilePath& history_filename) {
db_.reset(new InMemoryDatabase);
return db_->InitFromDisk(history_filename);
}
-void InMemoryHistoryBackend::AttachToHistoryService(Profile* profile) {
+void InMemoryHistoryBackend::AttachToHistoryService(
+ Profile* profile,
+ HistoryService* history_service) {
if (!db_) {
NOTREACHED();
return;
}
+ DCHECK(history_service);
+ history_service_ = history_service;
+ history_service_->AddObserver(this);
+
profile_ = profile;
// TODO(evanm): this is currently necessitated by generate_profile, which
@@ -49,7 +59,6 @@ void InMemoryHistoryBackend::AttachToHistoryService(Profile* profile) {
// Register for the notifications we care about.
// We only want notifications for the associated profile.
content::Source<Profile> source(profile_);
- registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URL_VISITED, source);
registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, source);
registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_DELETED, source);
registrar_.Add(
@@ -65,14 +74,19 @@ void InMemoryHistoryBackend::DeleteAllSearchTermsForKeyword(
db_->DeleteAllSearchTermsForKeyword(keyword_id);
}
+void InMemoryHistoryBackend::OnURLVisited(HistoryService* history_service,
+ ui::PageTransition transition,
+ const URLRow& row,
+ const RedirectList& redirects,
+ base::Time visit_time) {
+ OnURLVisitedOrModified(row);
+}
+
void InMemoryHistoryBackend::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
switch (type) {
- case chrome::NOTIFICATION_HISTORY_URL_VISITED:
- OnURLVisitedOrModified(content::Details<URLVisitedDetails>(details)->row);
- break;
case chrome::NOTIFICATION_HISTORY_KEYWORD_SEARCH_TERM_UPDATED:
OnKeywordSearchTermUpdated(
*content::Details<KeywordSearchUpdatedDetails>(details).ptr());
« no previous file with comments | « chrome/browser/history/in_memory_history_backend.h ('k') | chrome/browser/history/in_memory_url_index.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698