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

Unified Diff: chrome/browser/autocomplete/in_memory_url_index.cc

Issue 1181353003: Revert of Revert of Abstract //content-level dependencies out of InMemoryURLIndex (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
Index: chrome/browser/autocomplete/in_memory_url_index.cc
diff --git a/chrome/browser/autocomplete/in_memory_url_index.cc b/chrome/browser/autocomplete/in_memory_url_index.cc
index 582a43fec3e688ae8313521c42b3e29d0d626da2..bd0a33c19e3d58e91eaa5e57ae24d015e481d53e 100644
--- a/chrome/browser/autocomplete/in_memory_url_index.cc
+++ b/chrome/browser/autocomplete/in_memory_url_index.cc
@@ -8,27 +8,23 @@
#include "base/strings/utf_string_conversions.h"
#include "base/trace_event/trace_event.h"
#include "chrome/browser/autocomplete/url_index_private_data.h"
-#include "chrome/common/url_constants.h"
#include "components/history/core/browser/history_service.h"
#include "components/history/core/browser/url_database.h"
-#include "content/public/browser/browser_thread.h"
using in_memory_url_index::InMemoryURLIndexCacheItem;
-// Called by DoSaveToCacheFile to delete any old cache file at |path| when
-// there is no private data to save. Runs on the blocking pool.
-void DeleteCacheFile(const base::FilePath& path) {
- DCHECK(!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- base::DeleteFile(path, false);
-}
-
// Initializes a whitelist of URL schemes.
-void InitializeSchemeWhitelist(std::set<std::string>* whitelist) {
+void InitializeSchemeWhitelist(
+ SchemeSet* whitelist,
+ const SchemeSet& client_schemes_to_whitelist) {
DCHECK(whitelist);
if (!whitelist->empty())
return; // Nothing to do, already initialized.
+
+ whitelist->insert(client_schemes_to_whitelist.begin(),
+ client_schemes_to_whitelist.end());
+
whitelist->insert(std::string(url::kAboutScheme));
- whitelist->insert(std::string(content::kChromeUIScheme));
whitelist->insert(std::string(url::kFileScheme));
whitelist->insert(std::string(url::kFtpScheme));
whitelist->insert(std::string(url::kHttpScheme));
@@ -50,7 +46,7 @@
RebuildPrivateDataFromHistoryDBTask(
InMemoryURLIndex* index,
const std::string& languages,
- const std::set<std::string>& scheme_whitelist)
+ const SchemeSet& scheme_whitelist)
: index_(index),
languages_(languages),
scheme_whitelist_(scheme_whitelist),
@@ -79,10 +75,13 @@
// InMemoryURLIndex ------------------------------------------------------------
-InMemoryURLIndex::InMemoryURLIndex(bookmarks::BookmarkModel* bookmark_model,
- history::HistoryService* history_service,
- const base::FilePath& history_dir,
- const std::string& languages)
+InMemoryURLIndex::InMemoryURLIndex(
+ bookmarks::BookmarkModel* bookmark_model,
+ history::HistoryService* history_service,
+ base::SequencedWorkerPool* worker_pool,
+ const base::FilePath& history_dir,
+ const std::string& languages,
+ const SchemeSet& client_schemes_to_whitelist)
: bookmark_model_(bookmark_model),
history_service_(history_service),
history_dir_(history_dir),
@@ -91,13 +90,12 @@
restore_cache_observer_(NULL),
save_cache_observer_(NULL),
task_runner_(
- content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner(
- content::BrowserThread::GetBlockingPool()->GetSequenceToken())),
+ worker_pool->GetSequencedTaskRunner(worker_pool->GetSequenceToken())),
shutdown_(false),
restored_(false),
needs_to_be_cached_(false),
listen_to_history_service_loaded_(false) {
- InitializeSchemeWhitelist(&scheme_whitelist_);
+ InitializeSchemeWhitelist(&scheme_whitelist_, client_schemes_to_whitelist);
// TODO(mrossetti): Register for language change notifications.
if (history_service_)
history_service_->AddObserver(this);
@@ -195,7 +193,9 @@
// would be odd and confusing. It's better to force a rebuild.
base::FilePath path;
if (needs_to_be_cached_ && GetCacheFilePath(&path))
- task_runner_->PostTask(FROM_HERE, base::Bind(DeleteCacheFile, path));
+ task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(base::IgnoreResult(base::DeleteFile), path, false));
}
void InMemoryURLIndex::OnHistoryServiceLoaded(
@@ -208,7 +208,7 @@
// Restoring from Cache --------------------------------------------------------
void InMemoryURLIndex::PostRestoreFromCacheFileTask() {
- DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ DCHECK(thread_checker_.CalledOnValidThread());
TRACE_EVENT0("browser", "InMemoryURLIndex::PostRestoreFromCacheFileTask");
base::FilePath path;
@@ -241,7 +241,9 @@
base::FilePath path;
if (!GetCacheFilePath(&path) || shutdown_)
return;
- task_runner_->PostTask(FROM_HERE, base::Bind(DeleteCacheFile, path));
+ task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(base::IgnoreResult(base::DeleteFile), path, false));
if (history_service_->backend_loaded()) {
ScheduleRebuildFromHistory();
} else {
@@ -286,7 +288,7 @@
void InMemoryURLIndex::DoneRebuidingPrivateDataFromHistoryDB(
bool succeeded,
scoped_refptr<URLIndexPrivateData> private_data) {
- DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ DCHECK(thread_checker_.CalledOnValidThread());
if (succeeded) {
private_data_tracker_.TryCancelAll();
private_data_ = private_data;
@@ -330,7 +332,9 @@
base::Bind(&InMemoryURLIndex::OnCacheSaveDone, AsWeakPtr()));
} else {
// If there is no data in our index then delete any existing cache file.
- task_runner_->PostTask(FROM_HERE, base::Bind(DeleteCacheFile, path));
+ task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(base::IgnoreResult(base::DeleteFile), path, false));
}
}
« no previous file with comments | « chrome/browser/autocomplete/in_memory_url_index.h ('k') | chrome/browser/autocomplete/in_memory_url_index_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698