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

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

Issue 8437035: Revert 108207 - HQP Refactoring (in Preparation for SQLite Cache) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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
===================================================================
--- chrome/browser/history/in_memory_history_backend.cc (revision 108223)
+++ chrome/browser/history/in_memory_history_backend.cc (working copy)
@@ -13,10 +13,13 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/history/history_notifications.h"
#include "chrome/browser/history/in_memory_database.h"
+#include "chrome/browser/history/in_memory_url_index.h"
#include "chrome/browser/history/url_database.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_notification_types.h"
-#include "content/public/browser/notification_service.h"
+#include "chrome/common/chrome_switches.h"
+#include "content/public/browser/notification_details.h"
+#include "content/public/browser/notification_source.h"
namespace history {
@@ -24,14 +27,23 @@
: profile_(NULL) {
}
-InMemoryHistoryBackend::~InMemoryHistoryBackend() {}
+InMemoryHistoryBackend::~InMemoryHistoryBackend() {
+ if (index_.get())
+ index_->ShutDown();
+}
bool InMemoryHistoryBackend::Init(const FilePath& history_filename,
const FilePath& history_dir,
URLDatabase* db,
const std::string& languages) {
db_.reset(new InMemoryDatabase);
- return db_->InitFromDisk(history_filename);
+ bool success = db_->InitFromDisk(history_filename);
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kDisableHistoryQuickProvider)) {
+ index_.reset(new InMemoryURLIndex(history_dir));
+ index_->Init(db, languages);
+ }
+ return success;
}
void InMemoryHistoryBackend::AttachToHistoryService(Profile* profile) {
@@ -119,26 +131,36 @@
db_->UpdateURLRow(id, *i);
else
id = db_->AddURL(*i);
+ if (index_.get())
+ index_->UpdateURL(id, *i);
}
}
void InMemoryHistoryBackend::OnURLsDeleted(const URLsDeletedDetails& details) {
DCHECK(db_.get());
+
if (details.all_history) {
// When all history is deleted, the individual URLs won't be listed. Just
// create a new database to quickly clear everything out.
db_.reset(new InMemoryDatabase);
if (!db_->InitFromScratch())
db_.reset();
+ if (index_.get())
+ index_->ReloadFromHistory(db_.get(), true);
return;
}
// Delete all matching URLs in our database.
- for (std::vector<URLRow>::const_iterator row = details.rows.begin();
- row != details.rows.end(); ++row) {
- // We typically won't have most of them since we only have a subset of
- // history, so ignore errors.
- db_->DeleteURLRow(row->id());
+ for (std::set<GURL>::const_iterator i = details.urls.begin();
+ i != details.urls.end(); ++i) {
+ URLID id = db_->GetRowForURL(*i, NULL);
+ if (id) {
+ // We typically won't have most of them since we only have a subset of
+ // history, so ignore errors.
+ db_->DeleteURLRow(id);
+ if (index_.get())
+ index_->DeleteURL(id);
+ }
}
}
« 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