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); |
+ } |
} |
} |