| 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..86644600d182f737908419764bc859c953fc3107 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(
|
| + std::set<std::string>* whitelist,
|
| + const std::set<std::string>& 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));
|
| @@ -79,10 +75,13 @@ InMemoryURLIndex::RebuildPrivateDataFromHistoryDBTask::
|
|
|
| // 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 std::set<std::string>& client_schemes_to_whitelist)
|
| : bookmark_model_(bookmark_model),
|
| history_service_(history_service),
|
| history_dir_(history_dir),
|
| @@ -91,13 +90,12 @@ InMemoryURLIndex::InMemoryURLIndex(bookmarks::BookmarkModel* bookmark_model,
|
| 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 @@ void InMemoryURLIndex::OnURLsDeleted(history::HistoryService* history_service,
|
| // 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 @@ void InMemoryURLIndex::OnHistoryServiceLoaded(
|
| // 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 @@ void InMemoryURLIndex::OnCacheLoadDone(
|
| 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::ScheduleRebuildFromHistory() {
|
| 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 @@ void InMemoryURLIndex::PostSaveToCacheFileTask() {
|
| 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));
|
| }
|
| }
|
|
|
|
|