summaryrefslogtreecommitdiff
path: root/chromium/components/history
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-04-05 14:08:31 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2017-04-11 07:46:53 +0000
commit6a4cabb866f66d4128a97cdc6d9d08ce074f1247 (patch)
treeab00f70a5e89278d6a0d16ff0c42578dc4d84a2d /chromium/components/history
parente733310db58160074f574c429d48f8308c0afe17 (diff)
downloadqtwebengine-chromium-6a4cabb866f66d4128a97cdc6d9d08ce074f1247.tar.gz
BASELINE: Update Chromium to 57.0.2987.144
Change-Id: I29db402ff696c71a04c4dbaec822c2e53efe0267 Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
Diffstat (limited to 'chromium/components/history')
-rw-r--r--chromium/components/history/core/browser/BUILD.gn1
-rw-r--r--chromium/components/history/core/browser/DEPS3
-rw-r--r--chromium/components/history/core/browser/history_backend.cc9
-rw-r--r--chromium/components/history/core/browser/history_backend.h7
-rw-r--r--chromium/components/history/core/browser/history_client.h7
-rw-r--r--chromium/components/history/core/browser/history_database.h1
-rw-r--r--chromium/components/history/core/browser/history_delete_directives_data_type_controller.cc9
-rw-r--r--chromium/components/history/core/browser/history_delete_directives_data_type_controller.h6
-rw-r--r--chromium/components/history/core/browser/history_service.cc253
-rw-r--r--chromium/components/history/core/browser/history_service.h18
-rw-r--r--chromium/components/history/core/browser/history_types.h1
-rw-r--r--chromium/components/history/core/browser/in_memory_history_backend.h1
-rw-r--r--chromium/components/history/core/browser/page_usage_data.h2
-rw-r--r--chromium/components/history/core/browser/top_sites.h20
-rw-r--r--chromium/components/history/core/browser/top_sites_database.cc1
-rw-r--r--chromium/components/history/core/browser/top_sites_impl.cc214
-rw-r--r--chromium/components/history/core/browser/top_sites_impl.h7
-rw-r--r--chromium/components/history/core/browser/typed_url_data_type_controller.cc14
-rw-r--r--chromium/components/history/core/browser/typed_url_data_type_controller.h19
-rw-r--r--chromium/components/history/core/browser/typed_url_syncable_service.cc16
-rw-r--r--chromium/components/history/core/browser/typed_url_syncable_service.h8
-rw-r--r--chromium/components/history/core/browser/web_history_service.cc12
22 files changed, 284 insertions, 345 deletions
diff --git a/chromium/components/history/core/browser/BUILD.gn b/chromium/components/history/core/browser/BUILD.gn
index b3406b54a44..03e359e9289 100644
--- a/chromium/components/history/core/browser/BUILD.gn
+++ b/chromium/components/history/core/browser/BUILD.gn
@@ -100,6 +100,7 @@ static_library("browser") {
"//components/signin/core/browser",
"//components/sync",
"//components/url_formatter",
+ "//components/variations",
"//components/version_info",
"//google_apis",
"//net",
diff --git a/chromium/components/history/core/browser/DEPS b/chromium/components/history/core/browser/DEPS
new file mode 100644
index 00000000000..80f6f908e13
--- /dev/null
+++ b/chromium/components/history/core/browser/DEPS
@@ -0,0 +1,3 @@
+include_rules = [
+ "+components/variations",
+]
diff --git a/chromium/components/history/core/browser/history_backend.cc b/chromium/components/history/core/browser/history_backend.cc
index 1565486d534..08cacf54212 100644
--- a/chromium/components/history/core/browser/history_backend.cc
+++ b/chromium/components/history/core/browser/history_backend.cc
@@ -1168,11 +1168,16 @@ void HistoryBackend::QueryDownloads(std::vector<DownloadRow>* rows) {
}
// Update a particular download entry.
-void HistoryBackend::UpdateDownload(const DownloadRow& data) {
+void HistoryBackend::UpdateDownload(
+ const DownloadRow& data,
+ bool should_commit_immediately) {
if (!db_)
return;
db_->UpdateDownload(data);
- ScheduleCommit();
+ if (should_commit_immediately)
+ Commit();
+ else
+ ScheduleCommit();
}
bool HistoryBackend::CreateDownload(const DownloadRow& history_info) {
diff --git a/chromium/components/history/core/browser/history_backend.h b/chromium/components/history/core/browser/history_backend.h
index 130d9b7b614..6959994ab1a 100644
--- a/chromium/components/history/core/browser/history_backend.h
+++ b/chromium/components/history/core/browser/history_backend.h
@@ -34,11 +34,8 @@
#include "components/history/core/browser/visit_tracker.h"
#include "sql/init_status.h"
-class HistoryURLProvider;
-struct HistoryURLProviderParams;
class SkBitmap;
class TestingProfile;
-struct ThumbnailScore;
namespace base {
class SingleThreadTaskRunner;
@@ -53,11 +50,11 @@ class HistoryBackendObserver;
class HistoryBackendTest;
class HistoryDatabase;
struct HistoryDatabaseParams;
-struct HistoryDetails;
class HistoryDBTask;
class InMemoryHistoryBackend;
class TypedUrlSyncableService;
class HistoryBackendHelper;
+class URLDatabase;
// The maximum number of icons URLs per page which can be stored in the
// thumbnail database.
@@ -337,7 +334,7 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>,
uint32_t GetNextDownloadId();
void QueryDownloads(std::vector<DownloadRow>* rows);
- void UpdateDownload(const DownloadRow& data);
+ void UpdateDownload(const DownloadRow& data, bool should_commit_immediately);
bool CreateDownload(const DownloadRow& history_info);
void RemoveDownloads(const std::set<uint32_t>& ids);
diff --git a/chromium/components/history/core/browser/history_client.h b/chromium/components/history/core/browser/history_client.h
index 4d6b7e522b9..4a5b53371c0 100644
--- a/chromium/components/history/core/browser/history_client.h
+++ b/chromium/components/history/core/browser/history_client.h
@@ -12,17 +12,10 @@
class GURL;
-namespace base {
-class FilePath;
-}
-
namespace history {
-class HistoryBackend;
class HistoryBackendClient;
-class HistoryDatabase;
class HistoryService;
-class ThumbnailDatabase;
// This class abstracts operations that depend on the embedder's environment,
// e.g. Chrome.
diff --git a/chromium/components/history/core/browser/history_database.h b/chromium/components/history/core/browser/history_database.h
index b1b490cf198..9a26ae98194 100644
--- a/chromium/components/history/core/browser/history_database.h
+++ b/chromium/components/history/core/browser/history_database.h
@@ -29,7 +29,6 @@ namespace base {
class FilePath;
}
-class HistoryQuickProviderTest;
class InMemoryURLIndexTest;
namespace history {
diff --git a/chromium/components/history/core/browser/history_delete_directives_data_type_controller.cc b/chromium/components/history/core/browser/history_delete_directives_data_type_controller.cc
index f067ab9a636..f7a40626a4b 100644
--- a/chromium/components/history/core/browser/history_delete_directives_data_type_controller.cc
+++ b/chromium/components/history/core/browser/history_delete_directives_data_type_controller.cc
@@ -4,6 +4,7 @@
#include "components/history/core/browser/history_delete_directives_data_type_controller.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "components/sync/driver/sync_client.h"
#include "components/sync/driver/sync_service.h"
@@ -12,9 +13,11 @@ namespace browser_sync {
HistoryDeleteDirectivesDataTypeController::
HistoryDeleteDirectivesDataTypeController(const base::Closure& dump_stack,
syncer::SyncClient* sync_client)
- : syncer::UIDataTypeController(syncer::HISTORY_DELETE_DIRECTIVES,
- dump_stack,
- sync_client),
+ : syncer::AsyncDirectoryTypeController(syncer::HISTORY_DELETE_DIRECTIVES,
+ dump_stack,
+ sync_client,
+ syncer::GROUP_UI,
+ base::ThreadTaskRunnerHandle::Get()),
sync_client_(sync_client) {}
HistoryDeleteDirectivesDataTypeController::
diff --git a/chromium/components/history/core/browser/history_delete_directives_data_type_controller.h b/chromium/components/history/core/browser/history_delete_directives_data_type_controller.h
index 07016e763b6..a000181eec4 100644
--- a/chromium/components/history/core/browser/history_delete_directives_data_type_controller.h
+++ b/chromium/components/history/core/browser/history_delete_directives_data_type_controller.h
@@ -7,15 +7,15 @@
#include "base/macros.h"
#include "components/sync/device_info/local_device_info_provider.h"
+#include "components/sync/driver/async_directory_type_controller.h"
#include "components/sync/driver/sync_service_observer.h"
-#include "components/sync/driver/ui_data_type_controller.h"
namespace browser_sync {
// A controller for delete directives, which cannot sync when full encryption
// is enabled.
class HistoryDeleteDirectivesDataTypeController
- : public syncer::UIDataTypeController,
+ : public syncer::AsyncDirectoryTypeController,
public syncer::SyncServiceObserver {
public:
// |dump_stack| is called when an unrecoverable error occurs.
@@ -23,7 +23,7 @@ class HistoryDeleteDirectivesDataTypeController
syncer::SyncClient* sync_client);
~HistoryDeleteDirectivesDataTypeController() override;
- // UIDataTypeController override.
+ // AsyncDirectoryTypeController override.
bool ReadyForStart() const override;
bool StartModels() override;
void StopModels() override;
diff --git a/chromium/components/history/core/browser/history_service.cc b/chromium/components/history/core/browser/history_service.cc
index a97677666b6..b154b3237e1 100644
--- a/chromium/components/history/core/browser/history_service.cc
+++ b/chromium/components/history/core/browser/history_service.cc
@@ -28,6 +28,8 @@
#include "base/memory/ref_counted.h"
#include "base/metrics/histogram_macros.h"
#include "base/single_thread_task_runner.h"
+#include "base/task_runner_util.h"
+#include "base/task_scheduler/post_task.h"
#include "base/threading/thread.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
@@ -49,6 +51,7 @@
#include "components/history/core/browser/web_history_service.h"
#include "components/history/core/common/thumbnail_score.h"
#include "components/sync/model/sync_error_factory.h"
+#include "components/variations/variations_associated_data.h"
#include "third_party/skia/include/core/SkBitmap.h"
#if defined(OS_IOS)
@@ -182,19 +185,15 @@ class HistoryService::BackendDelegate : public HistoryBackend::Delegate {
const scoped_refptr<base::SequencedTaskRunner> service_task_runner_;
};
-// The history thread is intentionally not a BrowserThread because the
-// sync integration unit tests depend on being able to create more than one
-// history thread.
-HistoryService::HistoryService()
- : thread_(new base::Thread(kHistoryThreadName)),
- history_client_(nullptr),
- backend_loaded_(false),
- weak_ptr_factory_(this) {
-}
+HistoryService::HistoryService() : HistoryService(nullptr, nullptr) {}
HistoryService::HistoryService(std::unique_ptr<HistoryClient> history_client,
std::unique_ptr<VisitDelegate> visit_delegate)
- : thread_(new base::Thread(kHistoryThreadName)),
+ : thread_(variations::GetVariationParamValue("BrowserScheduler",
+ "RedirectHistoryService") ==
+ "true"
+ ? nullptr
+ : new base::Thread(kHistoryThreadName)),
history_client_(std::move(history_client)),
visit_delegate_(std::move(visit_delegate)),
backend_loaded_(false),
@@ -213,7 +212,7 @@ bool HistoryService::BackendLoaded() {
#if defined(OS_IOS)
void HistoryService::HandleBackgrounding() {
- if (!thread_ || !history_backend_.get())
+ if (!backend_task_runner_ || !history_backend_.get())
return;
ScheduleTask(PRIORITY_NORMAL,
@@ -223,7 +222,7 @@ void HistoryService::HandleBackgrounding() {
#endif
void HistoryService::ClearCachedDataForContextID(ContextID context_id) {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
ScheduleTask(PRIORITY_NORMAL,
base::Bind(&HistoryBackend::ClearCachedDataForContextID,
@@ -247,7 +246,7 @@ void HistoryService::Shutdown() {
void HistoryService::SetKeywordSearchTermsForURL(const GURL& url,
KeywordID keyword_id,
const base::string16& term) {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
ScheduleTask(PRIORITY_UI,
base::Bind(&HistoryBackend::SetKeywordSearchTermsForURL,
@@ -255,7 +254,7 @@ void HistoryService::SetKeywordSearchTermsForURL(const GURL& url,
}
void HistoryService::DeleteAllSearchTermsForKeyword(KeywordID keyword_id) {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
if (in_memory_backend_)
@@ -267,7 +266,7 @@ void HistoryService::DeleteAllSearchTermsForKeyword(KeywordID keyword_id) {
}
void HistoryService::DeleteKeywordSearchTermForURL(const GURL& url) {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
ScheduleTask(PRIORITY_UI,
base::Bind(&HistoryBackend::DeleteKeywordSearchTermForURL,
@@ -276,7 +275,7 @@ void HistoryService::DeleteKeywordSearchTermForURL(const GURL& url) {
void HistoryService::DeleteMatchingURLsForKeyword(KeywordID keyword_id,
const base::string16& term) {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
ScheduleTask(PRIORITY_UI,
base::Bind(&HistoryBackend::DeleteMatchingURLsForKeyword,
@@ -284,7 +283,7 @@ void HistoryService::DeleteMatchingURLsForKeyword(KeywordID keyword_id,
}
void HistoryService::URLsNoLongerBookmarked(const std::set<GURL>& urls) {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
ScheduleTask(PRIORITY_NORMAL,
base::Bind(&HistoryBackend::URLsNoLongerBookmarked,
@@ -304,7 +303,7 @@ void HistoryService::RemoveObserver(HistoryServiceObserver* observer) {
base::CancelableTaskTracker::TaskId HistoryService::ScheduleDBTask(
std::unique_ptr<HistoryDBTask> task,
base::CancelableTaskTracker* tracker) {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
base::CancelableTaskTracker::IsCanceledCallback is_canceled;
base::CancelableTaskTracker::TaskId task_id =
@@ -312,20 +311,20 @@ base::CancelableTaskTracker::TaskId HistoryService::ScheduleDBTask(
// Use base::ThreadTaskRunnerHandler::Get() to get a task runner for
// the current message loop so that we can forward the call to the method
// HistoryDBTask::DoneRunOnMainThread() in the correct thread.
- thread_->task_runner()->PostTask(
- FROM_HERE, base::Bind(&HistoryBackend::ProcessDBTask,
- history_backend_, base::Passed(&task),
+ backend_task_runner_->PostTask(
+ FROM_HERE, base::Bind(&HistoryBackend::ProcessDBTask, history_backend_,
+ base::Passed(&task),
base::ThreadTaskRunnerHandle::Get(), is_canceled));
return task_id;
}
void HistoryService::FlushForTest(const base::Closure& flushed) {
- thread_->task_runner()->PostTaskAndReply(
- FROM_HERE, base::Bind(&base::DoNothing), flushed);
+ backend_task_runner_->PostTaskAndReply(FROM_HERE,
+ base::Bind(&base::DoNothing), flushed);
}
void HistoryService::SetOnBackendDestroyTask(const base::Closure& task) {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
ScheduleTask(
PRIORITY_NORMAL,
@@ -335,10 +334,10 @@ void HistoryService::SetOnBackendDestroyTask(const base::Closure& task) {
void HistoryService::TopHosts(size_t num_hosts,
const TopHostsCallback& callback) const {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
PostTaskAndReplyWithResult(
- thread_->task_runner().get(), FROM_HERE,
+ backend_task_runner_.get(), FROM_HERE,
base::Bind(&HistoryBackend::TopHosts, history_backend_, num_hosts),
callback);
}
@@ -346,10 +345,10 @@ void HistoryService::TopHosts(size_t num_hosts,
void HistoryService::GetCountsAndLastVisitForOrigins(
const std::set<GURL>& origins,
const GetCountsAndLastVisitForOriginsCallback& callback) const {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
PostTaskAndReplyWithResult(
- thread_->task_runner().get(), FROM_HERE,
+ backend_task_runner_.get(), FROM_HERE,
base::Bind(&HistoryBackend::GetCountsAndLastVisitForOrigins,
history_backend_, origins),
callback);
@@ -358,12 +357,12 @@ void HistoryService::GetCountsAndLastVisitForOrigins(
void HistoryService::HostRankIfAvailable(
const GURL& url,
const base::Callback<void(int)>& callback) const {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
- PostTaskAndReplyWithResult(thread_->task_runner().get(), FROM_HERE,
- base::Bind(&HistoryBackend::HostRankIfAvailable,
- history_backend_, url),
- callback);
+ PostTaskAndReplyWithResult(
+ backend_task_runner_.get(), FROM_HERE,
+ base::Bind(&HistoryBackend::HostRankIfAvailable, history_backend_, url),
+ callback);
}
void HistoryService::AddPage(const GURL& url,
@@ -391,7 +390,7 @@ void HistoryService::AddPage(const GURL& url,
}
void HistoryService::AddPage(const HistoryAddPageArgs& add_page_args) {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
// Filter out unwanted URLs. We don't add auto-subframe URLs. They are a
@@ -422,7 +421,7 @@ void HistoryService::AddPage(const HistoryAddPageArgs& add_page_args) {
void HistoryService::AddPageNoVisitForBookmark(const GURL& url,
const base::string16& title) {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
if (history_client_ && !history_client_->CanAddURL(url))
return;
@@ -434,7 +433,7 @@ void HistoryService::AddPageNoVisitForBookmark(const GURL& url,
void HistoryService::SetPageTitle(const GURL& url,
const base::string16& title) {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
ScheduleTask(PRIORITY_NORMAL, base::Bind(&HistoryBackend::SetPageTitle,
history_backend_, url, title));
@@ -444,7 +443,7 @@ void HistoryService::UpdateWithPageEndTime(ContextID context_id,
int nav_entry_id,
const GURL& url,
Time end_ts) {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
ScheduleTask(
PRIORITY_NORMAL,
@@ -459,7 +458,7 @@ void HistoryService::AddPageWithDetails(const GURL& url,
Time last_visit,
bool hidden,
VisitSource visit_source) {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
// Filter out unwanted URLs.
if (history_client_ && !history_client_->CanAddURL(url))
@@ -486,7 +485,7 @@ void HistoryService::AddPageWithDetails(const GURL& url,
void HistoryService::AddPagesWithDetails(const URLRows& info,
VisitSource visit_source) {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
// Inform the VisitDelegate of the URLs
@@ -510,14 +509,14 @@ base::CancelableTaskTracker::TaskId HistoryService::GetFavicons(
const favicon_base::FaviconResultsCallback& callback,
base::CancelableTaskTracker* tracker) {
TRACE_EVENT0("browser", "HistoryService::GetFavicons");
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
std::vector<favicon_base::FaviconRawBitmapResult>* results =
new std::vector<favicon_base::FaviconRawBitmapResult>();
return tracker->PostTaskAndReply(
- thread_->task_runner().get(), FROM_HERE,
- base::Bind(&HistoryBackend::GetFavicons, history_backend_,
- icon_urls, icon_types, desired_sizes, results),
+ backend_task_runner_.get(), FROM_HERE,
+ base::Bind(&HistoryBackend::GetFavicons, history_backend_, icon_urls,
+ icon_types, desired_sizes, results),
base::Bind(&RunWithFaviconResults, callback, base::Owned(results)));
}
@@ -528,14 +527,14 @@ base::CancelableTaskTracker::TaskId HistoryService::GetFaviconsForURL(
const favicon_base::FaviconResultsCallback& callback,
base::CancelableTaskTracker* tracker) {
TRACE_EVENT0("browser", "HistoryService::GetFaviconsForURL");
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
std::vector<favicon_base::FaviconRawBitmapResult>* results =
new std::vector<favicon_base::FaviconRawBitmapResult>();
return tracker->PostTaskAndReply(
- thread_->task_runner().get(), FROM_HERE,
- base::Bind(&HistoryBackend::GetFaviconsForURL, history_backend_,
- page_url, icon_types, desired_sizes, results),
+ backend_task_runner_.get(), FROM_HERE,
+ base::Bind(&HistoryBackend::GetFaviconsForURL, history_backend_, page_url,
+ icon_types, desired_sizes, results),
base::Bind(&RunWithFaviconResults, callback, base::Owned(results)));
}
@@ -545,15 +544,14 @@ base::CancelableTaskTracker::TaskId HistoryService::GetLargestFaviconForURL(
int minimum_size_in_pixels,
const favicon_base::FaviconRawBitmapCallback& callback,
base::CancelableTaskTracker* tracker) {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
favicon_base::FaviconRawBitmapResult* result =
new favicon_base::FaviconRawBitmapResult();
return tracker->PostTaskAndReply(
- thread_->task_runner().get(), FROM_HERE,
- base::Bind(&HistoryBackend::GetLargestFaviconForURL,
- history_backend_, page_url, icon_types,
- minimum_size_in_pixels, result),
+ backend_task_runner_.get(), FROM_HERE,
+ base::Bind(&HistoryBackend::GetLargestFaviconForURL, history_backend_,
+ page_url, icon_types, minimum_size_in_pixels, result),
base::Bind(&RunWithFaviconResult, callback, base::Owned(result)));
}
@@ -563,14 +561,14 @@ base::CancelableTaskTracker::TaskId HistoryService::GetFaviconForID(
const favicon_base::FaviconResultsCallback& callback,
base::CancelableTaskTracker* tracker) {
TRACE_EVENT0("browser", "HistoryService::GetFaviconForID");
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
std::vector<favicon_base::FaviconRawBitmapResult>* results =
new std::vector<favicon_base::FaviconRawBitmapResult>();
return tracker->PostTaskAndReply(
- thread_->task_runner().get(), FROM_HERE,
- base::Bind(&HistoryBackend::GetFaviconForID, history_backend_,
- favicon_id, desired_size, results),
+ backend_task_runner_.get(), FROM_HERE,
+ base::Bind(&HistoryBackend::GetFaviconForID, history_backend_, favicon_id,
+ desired_size, results),
base::Bind(&RunWithFaviconResults, callback, base::Owned(results)));
}
@@ -583,12 +581,12 @@ HistoryService::UpdateFaviconMappingsAndFetch(
const favicon_base::FaviconResultsCallback& callback,
base::CancelableTaskTracker* tracker) {
TRACE_EVENT0("browser", "HistoryService::UpdateFaviconMappingsAndFetch");
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
std::vector<favicon_base::FaviconRawBitmapResult>* results =
new std::vector<favicon_base::FaviconRawBitmapResult>();
return tracker->PostTaskAndReply(
- thread_->task_runner().get(), FROM_HERE,
+ backend_task_runner_.get(), FROM_HERE,
base::Bind(&HistoryBackend::UpdateFaviconMappingsAndFetch,
history_backend_, page_url, icon_urls, icon_types,
desired_sizes, results),
@@ -602,7 +600,7 @@ void HistoryService::MergeFavicon(
scoped_refptr<base::RefCountedMemory> bitmap_data,
const gfx::Size& pixel_size) {
TRACE_EVENT0("browser", "HistoryService::MergeFavicon");
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
if (history_client_ && !history_client_->CanAddURL(page_url))
return;
@@ -617,7 +615,7 @@ void HistoryService::SetFavicons(const GURL& page_url,
favicon_base::IconType icon_type,
const GURL& icon_url,
const std::vector<SkBitmap>& bitmaps) {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
if (history_client_ && !history_client_->CanAddURL(page_url))
return;
@@ -628,7 +626,7 @@ void HistoryService::SetFavicons(const GURL& page_url,
}
void HistoryService::SetFaviconsOutOfDateForPage(const GURL& page_url) {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
ScheduleTask(PRIORITY_NORMAL,
base::Bind(&HistoryBackend::SetFaviconsOutOfDateForPage,
@@ -637,7 +635,7 @@ void HistoryService::SetFaviconsOutOfDateForPage(const GURL& page_url) {
void HistoryService::SetImportedFavicons(
const favicon_base::FaviconUsageDataList& favicon_usage) {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
ScheduleTask(PRIORITY_NORMAL,
base::Bind(&HistoryBackend::SetImportedFavicons,
@@ -649,13 +647,13 @@ base::CancelableTaskTracker::TaskId HistoryService::QueryURL(
bool want_visits,
const QueryURLCallback& callback,
base::CancelableTaskTracker* tracker) {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
QueryURLResult* query_url_result = new QueryURLResult();
return tracker->PostTaskAndReply(
- thread_->task_runner().get(), FROM_HERE,
- base::Bind(&HistoryBackend::QueryURL, history_backend_, url,
- want_visits, base::Unretained(query_url_result)),
+ backend_task_runner_.get(), FROM_HERE,
+ base::Bind(&HistoryBackend::QueryURL, history_backend_, url, want_visits,
+ base::Unretained(query_url_result)),
base::Bind(&RunWithQueryURLResult, callback,
base::Owned(query_url_result)));
}
@@ -667,14 +665,12 @@ base::CancelableTaskTracker::TaskId HistoryService::GetHistoryCount(
const Time& end_time,
const GetHistoryCountCallback& callback,
base::CancelableTaskTracker* tracker) {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
return tracker->PostTaskAndReplyWithResult(
- thread_->task_runner().get(), FROM_HERE,
- base::Bind(&HistoryBackend::GetHistoryCount,
- history_backend_,
- begin_time,
+ backend_task_runner_.get(), FROM_HERE,
+ base::Bind(&HistoryBackend::GetHistoryCount, history_backend_, begin_time,
end_time),
callback);
}
@@ -686,19 +682,19 @@ base::CancelableTaskTracker::TaskId HistoryService::GetHistoryCount(
void HistoryService::CreateDownload(
const DownloadRow& create_info,
const HistoryService::DownloadCreateCallback& callback) {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
- PostTaskAndReplyWithResult(thread_->task_runner().get(), FROM_HERE,
+ PostTaskAndReplyWithResult(backend_task_runner_.get(), FROM_HERE,
base::Bind(&HistoryBackend::CreateDownload,
history_backend_, create_info),
callback);
}
void HistoryService::GetNextDownloadId(const DownloadIdCallback& callback) {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
PostTaskAndReplyWithResult(
- thread_->task_runner().get(), FROM_HERE,
+ backend_task_runner_.get(), FROM_HERE,
base::Bind(&HistoryBackend::GetNextDownloadId, history_backend_),
callback);
}
@@ -706,7 +702,7 @@ void HistoryService::GetNextDownloadId(const DownloadIdCallback& callback) {
// Handle queries for a list of all downloads in the history database's
// 'downloads' table.
void HistoryService::QueryDownloads(const DownloadQueryCallback& callback) {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
std::vector<DownloadRow>* rows = new std::vector<DownloadRow>();
std::unique_ptr<std::vector<DownloadRow>> scoped_rows(rows);
@@ -714,7 +710,7 @@ void HistoryService::QueryDownloads(const DownloadQueryCallback& callback) {
// base::Passed(&scoped_rows) nullifies |scoped_rows|, and compilers do not
// guarantee that the first Bind's arguments are evaluated before the second
// Bind's arguments.
- thread_->task_runner()->PostTaskAndReply(
+ backend_task_runner_->PostTaskAndReply(
FROM_HERE,
base::Bind(&HistoryBackend::QueryDownloads, history_backend_, rows),
base::Bind(callback, base::Passed(&scoped_rows)));
@@ -722,15 +718,18 @@ void HistoryService::QueryDownloads(const DownloadQueryCallback& callback) {
// Handle updates for a particular download. This is a 'fire and forget'
// operation, so we don't need to be called back.
-void HistoryService::UpdateDownload(const DownloadRow& data) {
- DCHECK(thread_) << "History service being called after cleanup";
+void HistoryService::UpdateDownload(
+ const DownloadRow& data,
+ bool should_commit_immediately) {
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
ScheduleTask(PRIORITY_NORMAL, base::Bind(&HistoryBackend::UpdateDownload,
- history_backend_, data));
+ history_backend_, data,
+ should_commit_immediately));
}
void HistoryService::RemoveDownloads(const std::set<uint32_t>& ids) {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
ScheduleTask(PRIORITY_NORMAL, base::Bind(&HistoryBackend::RemoveDownloads,
history_backend_, ids));
@@ -741,13 +740,13 @@ base::CancelableTaskTracker::TaskId HistoryService::QueryHistory(
const QueryOptions& options,
const QueryHistoryCallback& callback,
base::CancelableTaskTracker* tracker) {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
QueryResults* query_results = new QueryResults();
return tracker->PostTaskAndReply(
- thread_->task_runner().get(), FROM_HERE,
- base::Bind(&HistoryBackend::QueryHistory, history_backend_,
- text_query, options, base::Unretained(query_results)),
+ backend_task_runner_.get(), FROM_HERE,
+ base::Bind(&HistoryBackend::QueryHistory, history_backend_, text_query,
+ options, base::Unretained(query_results)),
base::Bind(callback, base::Owned(query_results)));
}
@@ -755,11 +754,11 @@ base::CancelableTaskTracker::TaskId HistoryService::QueryRedirectsFrom(
const GURL& from_url,
const QueryRedirectsCallback& callback,
base::CancelableTaskTracker* tracker) {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
RedirectList* result = new RedirectList();
return tracker->PostTaskAndReply(
- thread_->task_runner().get(), FROM_HERE,
+ backend_task_runner_.get(), FROM_HERE,
base::Bind(&HistoryBackend::QueryRedirectsFrom, history_backend_,
from_url, base::Unretained(result)),
base::Bind(callback, base::Owned(result)));
@@ -769,13 +768,13 @@ base::CancelableTaskTracker::TaskId HistoryService::QueryRedirectsTo(
const GURL& to_url,
const QueryRedirectsCallback& callback,
base::CancelableTaskTracker* tracker) {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
RedirectList* result = new RedirectList();
return tracker->PostTaskAndReply(
- thread_->task_runner().get(), FROM_HERE,
- base::Bind(&HistoryBackend::QueryRedirectsTo, history_backend_,
- to_url, base::Unretained(result)),
+ backend_task_runner_.get(), FROM_HERE,
+ base::Bind(&HistoryBackend::QueryRedirectsTo, history_backend_, to_url,
+ base::Unretained(result)),
base::Bind(callback, base::Owned(result)));
}
@@ -783,13 +782,13 @@ base::CancelableTaskTracker::TaskId HistoryService::GetVisibleVisitCountToHost(
const GURL& url,
const GetVisibleVisitCountToHostCallback& callback,
base::CancelableTaskTracker* tracker) {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
VisibleVisitCountToHostResult* result = new VisibleVisitCountToHostResult();
return tracker->PostTaskAndReply(
- thread_->task_runner().get(), FROM_HERE,
- base::Bind(&HistoryBackend::GetVisibleVisitCountToHost,
- history_backend_, url, base::Unretained(result)),
+ backend_task_runner_.get(), FROM_HERE,
+ base::Bind(&HistoryBackend::GetVisibleVisitCountToHost, history_backend_,
+ url, base::Unretained(result)),
base::Bind(&RunWithVisibleVisitCountToHostResult, callback,
base::Owned(result)));
}
@@ -799,11 +798,11 @@ base::CancelableTaskTracker::TaskId HistoryService::QueryMostVisitedURLs(
int days_back,
const QueryMostVisitedURLsCallback& callback,
base::CancelableTaskTracker* tracker) {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
MostVisitedURLList* result = new MostVisitedURLList();
return tracker->PostTaskAndReply(
- thread_->task_runner().get(), FROM_HERE,
+ backend_task_runner_.get(), FROM_HERE,
base::Bind(&HistoryBackend::QueryMostVisitedURLs, history_backend_,
result_count, days_back, base::Unretained(result)),
base::Bind(callback, base::Owned(result)));
@@ -811,7 +810,7 @@ base::CancelableTaskTracker::TaskId HistoryService::QueryMostVisitedURLs(
void HistoryService::Cleanup() {
DCHECK(thread_checker_.CalledOnValidThread());
- if (!thread_) {
+ if (!backend_task_runner_) {
// We've already cleaned up.
return;
}
@@ -856,15 +855,14 @@ void HistoryService::Cleanup() {
closing_task.Reset();
HistoryBackend* raw_ptr = history_backend_.get();
history_backend_ = nullptr;
- thread_->task_runner()->ReleaseSoon(FROM_HERE, raw_ptr);
+ backend_task_runner_->ReleaseSoon(FROM_HERE, raw_ptr);
}
- // Delete the thread, which joins with the background thread. We defensively
- // nullptr the pointer before deleting it in case somebody tries to use it
- // during shutdown, but this shouldn't happen.
- base::Thread* thread = thread_;
- thread_ = nullptr;
- delete thread;
+ // Clear |backend_task_runner_| to make sure it's not used after Cleanup().
+ backend_task_runner_ = nullptr;
+
+ // Join the background thread, if any.
+ thread_.reset();
}
bool HistoryService::Init(
@@ -872,14 +870,24 @@ bool HistoryService::Init(
const HistoryDatabaseParams& history_database_params) {
TRACE_EVENT0("browser,startup", "HistoryService::Init")
SCOPED_UMA_HISTOGRAM_TIMER("History.HistoryServiceInitTime");
- DCHECK(thread_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(!backend_task_runner_);
- base::Thread::Options options;
- options.timer_slack = base::TIMER_SLACK_MAXIMUM;
- if (!thread_->StartWithOptions(options)) {
- Cleanup();
- return false;
+ if (thread_) {
+ base::Thread::Options options;
+ options.timer_slack = base::TIMER_SLACK_MAXIMUM;
+ if (!thread_->StartWithOptions(options)) {
+ Cleanup();
+ return false;
+ }
+ backend_task_runner_ = thread_->task_runner();
+ } else {
+ backend_task_runner_ = base::CreateSequencedTaskRunnerWithTraits(
+ base::TaskTraits()
+ .WithPriority(base::TaskPriority::USER_BLOCKING)
+ .WithShutdownBehavior(base::TaskShutdownBehavior::BLOCK_SHUTDOWN)
+ .MayBlock()
+ .WithBaseSyncPrimitives());
}
// Create the history backend.
@@ -887,7 +895,7 @@ bool HistoryService::Init(
new BackendDelegate(weak_ptr_factory_.GetWeakPtr(),
base::ThreadTaskRunnerHandle::Get()),
history_client_ ? history_client_->CreateBackendClient() : nullptr,
- thread_->task_runner()));
+ backend_task_runner_));
history_backend_.swap(backend);
ScheduleTask(PRIORITY_UI,
@@ -913,10 +921,9 @@ void HistoryService::ScheduleAutocomplete(
void HistoryService::ScheduleTask(SchedulePriority priority,
const base::Closure& task) {
DCHECK(thread_checker_.CalledOnValidThread());
- CHECK(thread_);
- CHECK(thread_->message_loop());
+ CHECK(backend_task_runner_);
// TODO(brettw): Do prioritization.
- thread_->task_runner()->PostTask(FROM_HERE, task);
+ backend_task_runner_->PostTask(FROM_HERE, task);
}
base::WeakPtr<HistoryService> HistoryService::AsWeakPtr() {
@@ -968,7 +975,7 @@ void HistoryService::SetInMemoryBackend(
std::unique_ptr<InMemoryHistoryBackend> mem_backend) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(!in_memory_backend_) << "Setting mem DB twice";
- in_memory_backend_.reset(mem_backend.release());
+ in_memory_backend_ = std::move(mem_backend);
// The database requires additional initialization once we own it.
in_memory_backend_->AttachToHistoryService(this);
@@ -982,7 +989,7 @@ void HistoryService::NotifyProfileError(sql::InitStatus init_status,
}
void HistoryService::DeleteURL(const GURL& url) {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
// We will update the visited links when we observe the delete notifications.
ScheduleTask(PRIORITY_NORMAL, base::Bind(&HistoryBackend::DeleteURL,
@@ -990,7 +997,7 @@ void HistoryService::DeleteURL(const GURL& url) {
}
void HistoryService::DeleteURLsForTest(const std::vector<GURL>& urls) {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
// We will update the visited links when we observe the delete
// notifications.
@@ -1004,10 +1011,10 @@ void HistoryService::ExpireHistoryBetween(
Time end_time,
const base::Closure& callback,
base::CancelableTaskTracker* tracker) {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
tracker->PostTaskAndReply(
- thread_->task_runner().get(), FROM_HERE,
+ backend_task_runner_.get(), FROM_HERE,
base::Bind(&HistoryBackend::ExpireHistoryBetween, history_backend_,
restrict_urls, begin_time, end_time),
callback);
@@ -1017,10 +1024,10 @@ void HistoryService::ExpireHistory(
const std::vector<ExpireHistoryArgs>& expire_list,
const base::Closure& callback,
base::CancelableTaskTracker* tracker) {
- DCHECK(thread_) << "History service being called after cleanup";
+ DCHECK(backend_task_runner_) << "History service being called after cleanup";
DCHECK(thread_checker_.CalledOnValidThread());
tracker->PostTaskAndReply(
- thread_->task_runner().get(), FROM_HERE,
+ backend_task_runner_.get(), FROM_HERE,
base::Bind(&HistoryBackend::ExpireHistory, history_backend_, expire_list),
callback);
}
@@ -1078,7 +1085,7 @@ void HistoryService::NotifyURLsDeleted(bool all_history,
const URLRows& deleted_rows,
const std::set<GURL>& favicon_urls) {
DCHECK(thread_checker_.CalledOnValidThread());
- if (!thread_)
+ if (!backend_task_runner_)
return;
// Inform the VisitDelegate of the deleted URLs. We will inform the delegate
diff --git a/chromium/components/history/core/browser/history_service.h b/chromium/components/history/core/browser/history_service.h
index 43003713385..8e34834e22a 100644
--- a/chromium/components/history/core/browser/history_service.h
+++ b/chromium/components/history/core/browser/history_service.h
@@ -22,6 +22,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
+#include "base/sequenced_task_runner.h"
#include "base/strings/string16.h"
#include "base/task/cancelable_task_tracker.h"
#include "base/threading/thread_checker.h"
@@ -41,7 +42,6 @@
class GURL;
class HistoryQuickProviderTest;
class HistoryURLProvider;
-class HistoryURLProviderTest;
class InMemoryURLIndexTest;
class SkBitmap;
class SyncBookmarkDataTypeControllerTest;
@@ -63,13 +63,11 @@ struct HistoryAddPageArgs;
class HistoryBackend;
class HistoryClient;
class HistoryDBTask;
-class HistoryDatabase;
struct HistoryDatabaseParams;
class HistoryQueryTest;
class HistoryServiceObserver;
class HistoryServiceTest;
class InMemoryHistoryBackend;
-struct KeywordSearchTermVisit;
class URLDatabase;
class VisitDelegate;
class WebHistoryService;
@@ -421,7 +419,7 @@ class HistoryService : public syncer::SyncableService, public KeyedService {
// Called to update the history service about the current state of a download.
// This is a 'fire and forget' query, so just pass the relevant state info to
// the database with no need for a callback.
- void UpdateDownload(const DownloadRow& data);
+ void UpdateDownload(const DownloadRow& data, bool should_commit_immediately);
// Permanently remove some downloads from the history system. This is a 'fire
// and forget' operation.
@@ -795,9 +793,15 @@ class HistoryService : public syncer::SyncableService, public KeyedService {
base::ThreadChecker thread_checker_;
- // The thread used by the history service to run complicated operations.
- // |thread_| is null once Cleanup() is called.
- base::Thread* thread_;
+ // The thread used by the history service to run HistoryBackend operations.
+ // Intentionally not a BrowserThread because the sync integration unit tests
+ // need to create multiple HistoryServices which each have their own thread.
+ // Nullptr if TaskScheduler is used for HistoryBackend operations.
+ std::unique_ptr<base::Thread> thread_;
+
+ // The TaskRunner to which HistoryBackend tasks are posted. Nullptr once
+ // Cleanup() is called.
+ scoped_refptr<base::SequencedTaskRunner> backend_task_runner_;
// This class has most of the implementation and runs on the 'thread_'.
// You MUST communicate with this class ONLY through the thread_'s
diff --git a/chromium/components/history/core/browser/history_types.h b/chromium/components/history/core/browser/history_types.h
index 64f34c30416..e560ed7c020 100644
--- a/chromium/components/history/core/browser/history_types.h
+++ b/chromium/components/history/core/browser/history_types.h
@@ -35,7 +35,6 @@ namespace history {
// Forward declaration for friend statements.
class HistoryBackend;
class PageUsageData;
-class URLDatabase;
// Container for a list of URLs.
typedef std::vector<GURL> RedirectList;
diff --git a/chromium/components/history/core/browser/in_memory_history_backend.h b/chromium/components/history/core/browser/in_memory_history_backend.h
index 6bcb7470cab..2462543c512 100644
--- a/chromium/components/history/core/browser/in_memory_history_backend.h
+++ b/chromium/components/history/core/browser/in_memory_history_backend.h
@@ -39,7 +39,6 @@ class HistoryBackendTestBase;
class HistoryService;
class InMemoryDatabase;
class InMemoryHistoryBackendTest;
-class URLDatabase;
class URLRow;
class InMemoryHistoryBackend : public HistoryServiceObserver {
diff --git a/chromium/components/history/core/browser/page_usage_data.h b/chromium/components/history/core/browser/page_usage_data.h
index 4ce691df9e5..4371dcb3001 100644
--- a/chromium/components/history/core/browser/page_usage_data.h
+++ b/chromium/components/history/core/browser/page_usage_data.h
@@ -9,8 +9,6 @@
#include "components/history/core/browser/history_types.h"
#include "url/gurl.h"
-class SkBitmap;
-
namespace history {
/////////////////////////////////////////////////////////////////////////////
diff --git a/chromium/components/history/core/browser/top_sites.h b/chromium/components/history/core/browser/top_sites.h
index 8e826058f3e..2b5e080f4b5 100644
--- a/chromium/components/history/core/browser/top_sites.h
+++ b/chromium/components/history/core/browser/top_sites.h
@@ -10,7 +10,6 @@
#include "base/callback.h"
#include "base/macros.h"
#include "base/observer_list.h"
-#include "base/task/cancelable_task_tracker.h"
#include "components/history/core/browser/history_types.h"
#include "components/history/core/browser/top_sites_observer.h"
#include "components/history/core/common/thumbnail_score.h"
@@ -21,14 +20,11 @@
class GURL;
namespace base {
-class FilePath;
-class RefCountedBytes;
class RefCountedMemory;
}
namespace history {
-class TopSitesCache;
class TopSitesObserver;
// PrepopulatedPage stores information for prepopulated page for the
@@ -68,12 +64,6 @@ class TopSites : public RefcountedKeyedService {
const gfx::Image& thumbnail,
const ThumbnailScore& score) = 0;
- // While testing the history system, we want to set the thumbnail to a piece
- // of static memory.
- virtual bool SetPageThumbnailToJPEGBytes(const GURL& url,
- const base::RefCountedMemory* memory,
- const ThumbnailScore& score) = 0;
-
typedef base::Callback<void(const MostVisitedURLList&)>
GetMostVisitedURLsCallback;
@@ -131,20 +121,10 @@ class TopSites : public RefcountedKeyedService {
// Clear the blacklist. Should be called from the UI thread.
virtual void ClearBlacklistedURLs() = 0;
- // Query history service for the list of available thumbnails. Returns the
- // task id for the request, or |base::CancelableTaskTracker::kBadTaskId| if a
- // request could not be made. Public only for testing purposes.
- virtual base::CancelableTaskTracker::TaskId StartQueryForMostVisited() = 0;
-
// Returns true if the given URL is known to the top sites service.
// This function also returns false if TopSites isn't loaded yet.
virtual bool IsKnownURL(const GURL& url) = 0;
- // Follows the cached redirect chain to convert any URL to its
- // canonical version. If no redirect chain is known for the URL,
- // return it without modification.
- virtual const std::string& GetCanonicalURLString(const GURL& url) const = 0;
-
// Returns true if the top sites list of non-forced URLs is full (i.e. we
// already have the maximum number of non-forced top sites). This function
// also returns false if TopSites isn't loaded yet.
diff --git a/chromium/components/history/core/browser/top_sites_database.cc b/chromium/components/history/core/browser/top_sites_database.cc
index 191b36d547d..7e9fc819a0a 100644
--- a/chromium/components/history/core/browser/top_sites_database.cc
+++ b/chromium/components/history/core/browser/top_sites_database.cc
@@ -8,6 +8,7 @@
#include <stdint.h>
#include <utility>
+#include "base/bind.h"
#include "base/files/file_util.h"
#include "base/memory/ref_counted.h"
#include "base/metrics/histogram_macros.h"
diff --git a/chromium/components/history/core/browser/top_sites_impl.cc b/chromium/components/history/core/browser/top_sites_impl.cc
index 57e72498d65..b9ae71596b5 100644
--- a/chromium/components/history/core/browser/top_sites_impl.cc
+++ b/chromium/components/history/core/browser/top_sites_impl.cc
@@ -172,41 +172,6 @@ bool TopSitesImpl::SetPageThumbnail(const GURL& url,
return SetPageThumbnailEncoded(url, thumbnail_data.get(), score);
}
-bool TopSitesImpl::SetPageThumbnailToJPEGBytes(
- const GURL& url,
- const base::RefCountedMemory* memory,
- const ThumbnailScore& score) {
- DCHECK(thread_checker_.CalledOnValidThread());
-
- if (!loaded_) {
- // TODO(sky): I need to cache these and apply them after the load
- // completes.
- return false;
- }
-
- bool add_temp_thumbnail = false;
- if (!IsKnownURL(url)) {
- if (!IsNonForcedFull()) {
- add_temp_thumbnail = true;
- } else {
- return false; // This URL is not known to us.
- }
- }
-
- if (!can_add_url_to_history_.Run(url))
- return false; // It's not a real webpage.
-
- if (add_temp_thumbnail) {
- // Always remove the existing entry and then add it back. That way if we end
- // up with too many temp thumbnails we'll prune the oldest first.
- RemoveTemporaryThumbnailByURL(url);
- AddTemporaryThumbnail(url, memory, score);
- return true;
- }
-
- return SetPageThumbnailEncoded(url, memory, score);
-}
-
// WARNING: this function may be invoked on any thread.
void TopSitesImpl::GetMostVisitedURLs(
const GetMostVisitedURLsCallback& callback,
@@ -366,6 +331,79 @@ void TopSitesImpl::ClearBlacklistedURLs() {
NotifyTopSitesChanged(TopSitesObserver::ChangeReason::BLACKLIST);
}
+bool TopSitesImpl::IsKnownURL(const GURL& url) {
+ return loaded_ && cache_->IsKnownURL(url);
+}
+
+bool TopSitesImpl::IsNonForcedFull() {
+ return loaded_ && cache_->GetNumNonForcedURLs() >= kNonForcedTopSitesNumber;
+}
+
+bool TopSitesImpl::IsForcedFull() {
+ return loaded_ && cache_->GetNumForcedURLs() >= kForcedTopSitesNumber;
+}
+
+PrepopulatedPageList TopSitesImpl::GetPrepopulatedPages() {
+ return prepopulated_pages_;
+}
+
+bool TopSitesImpl::loaded() const {
+ return loaded_;
+}
+
+bool TopSitesImpl::AddForcedURL(const GURL& url, const base::Time& time) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+
+ if (!loaded_) {
+ // Optimally we could cache this and apply it after the load completes, but
+ // in practice it's not an issue since AddForcedURL will be called again
+ // next time the user hits the NTP.
+ return false;
+ }
+
+ size_t num_forced = cache_->GetNumForcedURLs();
+ MostVisitedURLList new_list(cache_->top_sites());
+ MostVisitedURL new_url;
+
+ if (cache_->IsKnownURL(url)) {
+ size_t index = cache_->GetURLIndex(url);
+ // Do nothing if we currently have that URL as non-forced.
+ if (new_list[index].last_forced_time.is_null())
+ return false;
+
+ // Update the |last_forced_time| of the already existing URL. Delete it and
+ // reinsert it at the right location.
+ new_url = new_list[index];
+ new_list.erase(new_list.begin() + index);
+ num_forced--;
+ } else {
+ new_url.url = url;
+ new_url.redirects.push_back(url);
+ }
+ new_url.last_forced_time = time;
+ // Add forced URLs and sort. Added to the end of the list of forced URLs
+ // since this is almost always where it needs to go, unless the user's local
+ // clock is fiddled with.
+ MostVisitedURLList::iterator mid = new_list.begin() + num_forced;
+ new_list.insert(mid, new_url);
+ mid = new_list.begin() + num_forced; // Mid was invalidated.
+ std::inplace_merge(new_list.begin(), mid, mid + 1, ForcedURLComparator);
+ SetTopSites(new_list, CALL_LOCATION_FROM_FORCED_URLS);
+ return true;
+}
+
+void TopSitesImpl::OnNavigationCommitted(const GURL& url) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ if (!loaded_ || IsNonForcedFull())
+ return;
+
+ if (!cache_->IsKnownURL(url) && can_add_url_to_history_.Run(url)) {
+ // To avoid slamming history we throttle requests when the url updates. To
+ // do otherwise negatively impacts perf tests.
+ RestartQueryForTopSitesTimer(GetUpdateDelay());
+ }
+}
+
void TopSitesImpl::ShutdownOnUIThread() {
history_service_ = nullptr;
history_service_observer_.RemoveAll();
@@ -382,6 +420,20 @@ void TopSitesImpl::RegisterPrefs(PrefRegistrySimple* registry) {
registry->RegisterDictionaryPref(kMostVisitedURLsBlacklist);
}
+TopSitesImpl::~TopSitesImpl() = default;
+
+void TopSitesImpl::StartQueryForMostVisited() {
+ DCHECK(loaded_);
+ if (!history_service_)
+ return;
+
+ history_service_->QueryMostVisitedURLs(
+ num_results_to_request_from_history(), kDaysOfHistory,
+ base::Bind(&TopSitesImpl::OnTopSitesAvailableFromHistory,
+ base::Unretained(this)),
+ &cancelable_task_tracker_);
+}
+
// static
void TopSitesImpl::DiffMostVisited(const MostVisitedURLList& old_list,
const MostVisitedURLList& new_list,
@@ -444,37 +496,6 @@ void TopSitesImpl::DiffMostVisited(const MostVisitedURLList& old_list,
}
}
-base::CancelableTaskTracker::TaskId TopSitesImpl::StartQueryForMostVisited() {
- DCHECK(loaded_);
- if (!history_service_)
- return base::CancelableTaskTracker::kBadTaskId;
-
- return history_service_->QueryMostVisitedURLs(
- num_results_to_request_from_history(), kDaysOfHistory,
- base::Bind(&TopSitesImpl::OnTopSitesAvailableFromHistory,
- base::Unretained(this)),
- &cancelable_task_tracker_);
-}
-
-bool TopSitesImpl::IsKnownURL(const GURL& url) {
- return loaded_ && cache_->IsKnownURL(url);
-}
-
-const std::string& TopSitesImpl::GetCanonicalURLString(const GURL& url) const {
- return cache_->GetCanonicalURL(url).spec();
-}
-
-bool TopSitesImpl::IsNonForcedFull() {
- return loaded_ && cache_->GetNumNonForcedURLs() >= kNonForcedTopSitesNumber;
-}
-
-bool TopSitesImpl::IsForcedFull() {
- return loaded_ && cache_->GetNumForcedURLs() >= kForcedTopSitesNumber;
-}
-
-TopSitesImpl::~TopSitesImpl() {
-}
-
bool TopSitesImpl::SetPageThumbnailNoDB(
const GURL& url,
const base::RefCountedMemory* thumbnail_data,
@@ -581,67 +602,6 @@ int TopSitesImpl::GetRedirectDistanceForURL(const MostVisitedURL& most_visited,
return 0;
}
-PrepopulatedPageList TopSitesImpl::GetPrepopulatedPages() {
- return prepopulated_pages_;
-}
-
-bool TopSitesImpl::loaded() const {
- return loaded_;
-}
-
-bool TopSitesImpl::AddForcedURL(const GURL& url, const base::Time& time) {
- DCHECK(thread_checker_.CalledOnValidThread());
-
- if (!loaded_) {
- // Optimally we could cache this and apply it after the load completes, but
- // in practice it's not an issue since AddForcedURL will be called again
- // next time the user hits the NTP.
- return false;
- }
-
- size_t num_forced = cache_->GetNumForcedURLs();
- MostVisitedURLList new_list(cache_->top_sites());
- MostVisitedURL new_url;
-
- if (cache_->IsKnownURL(url)) {
- size_t index = cache_->GetURLIndex(url);
- // Do nothing if we currently have that URL as non-forced.
- if (new_list[index].last_forced_time.is_null())
- return false;
-
- // Update the |last_forced_time| of the already existing URL. Delete it and
- // reinsert it at the right location.
- new_url = new_list[index];
- new_list.erase(new_list.begin() + index);
- num_forced--;
- } else {
- new_url.url = url;
- new_url.redirects.push_back(url);
- }
- new_url.last_forced_time = time;
- // Add forced URLs and sort. Added to the end of the list of forced URLs
- // since this is almost always where it needs to go, unless the user's local
- // clock is fiddled with.
- MostVisitedURLList::iterator mid = new_list.begin() + num_forced;
- new_list.insert(mid, new_url);
- mid = new_list.begin() + num_forced; // Mid was invalidated.
- std::inplace_merge(new_list.begin(), mid, mid + 1, ForcedURLComparator);
- SetTopSites(new_list, CALL_LOCATION_FROM_FORCED_URLS);
- return true;
-}
-
-void TopSitesImpl::OnNavigationCommitted(const GURL& url) {
- DCHECK(thread_checker_.CalledOnValidThread());
- if (!loaded_ || IsNonForcedFull())
- return;
-
- if (!cache_->IsKnownURL(url) && can_add_url_to_history_.Run(url)) {
- // To avoid slamming history we throttle requests when the url updates. To
- // do otherwise negatively impacts perf tests.
- RestartQueryForTopSitesTimer(GetUpdateDelay());
- }
-}
-
bool TopSitesImpl::AddPrepopulatedPages(MostVisitedURLList* urls,
size_t num_forced_urls) {
bool added = false;
diff --git a/chromium/components/history/core/browser/top_sites_impl.h b/chromium/components/history/core/browser/top_sites_impl.h
index 338c2a5e3fa..c83cb0a883a 100644
--- a/chromium/components/history/core/browser/top_sites_impl.h
+++ b/chromium/components/history/core/browser/top_sites_impl.h
@@ -73,9 +73,6 @@ class TopSitesImpl : public TopSites, public HistoryServiceObserver {
bool SetPageThumbnail(const GURL& url,
const gfx::Image& thumbnail,
const ThumbnailScore& score) override;
- bool SetPageThumbnailToJPEGBytes(const GURL& url,
- const base::RefCountedMemory* memory,
- const ThumbnailScore& score) override;
void GetMostVisitedURLs(const GetMostVisitedURLsCallback& callback,
bool include_forced_urls) override;
bool GetPageThumbnail(const GURL& url,
@@ -90,9 +87,7 @@ class TopSitesImpl : public TopSites, public HistoryServiceObserver {
void RemoveBlacklistedURL(const GURL& url) override;
bool IsBlacklisted(const GURL& url) override;
void ClearBlacklistedURLs() override;
- base::CancelableTaskTracker::TaskId StartQueryForMostVisited() override;
bool IsKnownURL(const GURL& url) override;
- const std::string& GetCanonicalURLString(const GURL& url) const override;
bool IsNonForcedFull() override;
bool IsForcedFull() override;
PrepopulatedPageList GetPrepopulatedPages() override;
@@ -137,6 +132,8 @@ class TopSitesImpl : public TopSites, public HistoryServiceObserver {
typedef std::list<TempImage> TempImages;
typedef std::vector<PendingCallback> PendingCallbacks;
+ void StartQueryForMostVisited();
+
// Generates the diff of things that happened between "old" and "new."
//
// This treats forced URLs separately than non-forced URLs.
diff --git a/chromium/components/history/core/browser/typed_url_data_type_controller.cc b/chromium/components/history/core/browser/typed_url_data_type_controller.cc
index 8e99a0032b1..d27a4f61a7e 100644
--- a/chromium/components/history/core/browser/typed_url_data_type_controller.cc
+++ b/chromium/components/history/core/browser/typed_url_data_type_controller.cc
@@ -51,7 +51,11 @@ TypedUrlDataTypeController::TypedUrlDataTypeController(
const base::Closure& dump_stack,
syncer::SyncClient* sync_client,
const char* history_disabled_pref_name)
- : NonUIDataTypeController(syncer::TYPED_URLS, dump_stack, sync_client),
+ : AsyncDirectoryTypeController(syncer::TYPED_URLS,
+ dump_stack,
+ sync_client,
+ syncer::GROUP_HISTORY,
+ nullptr),
history_disabled_pref_name_(history_disabled_pref_name),
sync_client_(sync_client) {
pref_registrar_.Init(sync_client->GetPrefService());
@@ -62,10 +66,6 @@ TypedUrlDataTypeController::TypedUrlDataTypeController(
base::AsWeakPtr(this)));
}
-syncer::ModelSafeGroup TypedUrlDataTypeController::model_safe_group() const {
- return syncer::GROUP_HISTORY;
-}
-
bool TypedUrlDataTypeController::ReadyForStart() const {
DCHECK(CalledOnValidThread());
return !sync_client_->GetPrefService()->GetBoolean(
@@ -79,7 +79,7 @@ void TypedUrlDataTypeController::OnSavingBrowserHistoryDisabledChanged() {
// generate an unrecoverable error. This can be fixed by restarting
// Chrome (on restart, typed urls will not be a registered type).
if (state() != NOT_RUNNING && state() != STOPPING) {
- PostTaskOnBackendThread(
+ PostTaskOnModelThread(
FROM_HERE,
base::Bind(&syncer::DataTypeErrorHandler::OnUnrecoverableError,
base::Passed(CreateErrorHandler()),
@@ -90,7 +90,7 @@ void TypedUrlDataTypeController::OnSavingBrowserHistoryDisabledChanged() {
}
}
-bool TypedUrlDataTypeController::PostTaskOnBackendThread(
+bool TypedUrlDataTypeController::PostTaskOnModelThread(
const tracked_objects::Location& from_here,
const base::Closure& task) {
DCHECK(CalledOnValidThread());
diff --git a/chromium/components/history/core/browser/typed_url_data_type_controller.h b/chromium/components/history/core/browser/typed_url_data_type_controller.h
index b3bf9a36f37..2f5e1d06bc7 100644
--- a/chromium/components/history/core/browser/typed_url_data_type_controller.h
+++ b/chromium/components/history/core/browser/typed_url_data_type_controller.h
@@ -11,19 +11,13 @@
#include "base/macros.h"
#include "base/task/cancelable_task_tracker.h"
#include "components/prefs/pref_change_registrar.h"
-#include "components/sync/driver/non_ui_data_type_controller.h"
+#include "components/sync/driver/async_directory_type_controller.h"
#include "components/sync/driver/sync_api_component_factory.h"
-namespace history {
-class HistoryBackend;
-}
-
namespace browser_sync {
-class ControlTask;
-
// A class that manages the startup and shutdown of typed_url sync.
-class TypedUrlDataTypeController : public syncer::NonUIDataTypeController {
+class TypedUrlDataTypeController : public syncer::AsyncDirectoryTypeController {
public:
// |dump_stack| is called when an unrecoverable error occurs.
TypedUrlDataTypeController(const base::Closure& dump_stack,
@@ -31,14 +25,13 @@ class TypedUrlDataTypeController : public syncer::NonUIDataTypeController {
const char* history_disabled_pref_name);
~TypedUrlDataTypeController() override;
- // NonUIDataTypeController implementation
- syncer::ModelSafeGroup model_safe_group() const override;
+ // AsyncDirectoryTypeController implementation.
bool ReadyForStart() const override;
protected:
- // NonUIDataTypeController interface.
- bool PostTaskOnBackendThread(const tracked_objects::Location& from_here,
- const base::Closure& task) override;
+ // AsyncDirectoryTypeController implementation.
+ bool PostTaskOnModelThread(const tracked_objects::Location& from_here,
+ const base::Closure& task) override;
private:
void OnSavingBrowserHistoryDisabledChanged();
diff --git a/chromium/components/history/core/browser/typed_url_syncable_service.cc b/chromium/components/history/core/browser/typed_url_syncable_service.cc
index 0397d59dba9..deaf6b27d76 100644
--- a/chromium/components/history/core/browser/typed_url_syncable_service.cc
+++ b/chromium/components/history/core/browser/typed_url_syncable_service.cc
@@ -71,7 +71,7 @@ TypedUrlSyncableService::TypedUrlSyncableService(
num_db_errors_(0),
history_backend_observer_(this) {
DCHECK(history_backend_);
- DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(sequence_checker_.CalledOnValidSequence());
}
TypedUrlSyncableService::~TypedUrlSyncableService() {
@@ -82,7 +82,7 @@ syncer::SyncMergeResult TypedUrlSyncableService::MergeDataAndStartSyncing(
const syncer::SyncDataList& initial_sync_data,
std::unique_ptr<syncer::SyncChangeProcessor> sync_processor,
std::unique_ptr<syncer::SyncErrorFactory> error_handler) {
- DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(sequence_checker_.CalledOnValidSequence());
DCHECK(!sync_processor_.get());
DCHECK(sync_processor.get());
DCHECK(error_handler.get());
@@ -211,7 +211,7 @@ syncer::SyncMergeResult TypedUrlSyncableService::MergeDataAndStartSyncing(
}
void TypedUrlSyncableService::StopSyncing(syncer::ModelType type) {
- DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(sequence_checker_.CalledOnValidSequence());
DCHECK_EQ(type, syncer::TYPED_URLS);
// Clear cache of server state.
@@ -227,7 +227,7 @@ void TypedUrlSyncableService::StopSyncing(syncer::ModelType type) {
syncer::SyncDataList TypedUrlSyncableService::GetAllSyncData(
syncer::ModelType type) const {
- DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(sequence_checker_.CalledOnValidSequence());
syncer::SyncDataList list;
// TODO(sync): Add implementation
@@ -238,7 +238,7 @@ syncer::SyncDataList TypedUrlSyncableService::GetAllSyncData(
syncer::SyncError TypedUrlSyncableService::ProcessSyncChanges(
const tracked_objects::Location& from_here,
const syncer::SyncChangeList& change_list) {
- DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(sequence_checker_.CalledOnValidSequence());
std::vector<GURL> pending_deleted_urls;
history::URLRows new_synced_urls;
@@ -288,7 +288,7 @@ syncer::SyncError TypedUrlSyncableService::ProcessSyncChanges(
void TypedUrlSyncableService::OnURLsModified(
history::HistoryBackend* history_backend,
const history::URLRows& changed_urls) {
- DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(sequence_checker_.CalledOnValidSequence());
if (processing_syncer_changes_)
return; // These are changes originating from us, ignore.
@@ -318,7 +318,7 @@ void TypedUrlSyncableService::OnURLVisited(
const history::URLRow& row,
const history::RedirectList& redirects,
base::Time visit_time) {
- DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(sequence_checker_.CalledOnValidSequence());
if (processing_syncer_changes_)
return; // These are changes originating from us, ignore.
@@ -343,7 +343,7 @@ void TypedUrlSyncableService::OnURLsDeleted(
bool expired,
const history::URLRows& deleted_rows,
const std::set<GURL>& favicon_urls) {
- DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(sequence_checker_.CalledOnValidSequence());
if (processing_syncer_changes_)
return; // These are changes originating from us, ignore.
diff --git a/chromium/components/history/core/browser/typed_url_syncable_service.h b/chromium/components/history/core/browser/typed_url_syncable_service.h
index bf2f3302069..838e83efc6d 100644
--- a/chromium/components/history/core/browser/typed_url_syncable_service.h
+++ b/chromium/components/history/core/browser/typed_url_syncable_service.h
@@ -12,7 +12,7 @@
#include "base/macros.h"
#include "base/scoped_observer.h"
-#include "base/threading/thread_checker.h"
+#include "base/sequence_checker.h"
#include "components/history/core/browser/history_backend_observer.h"
#include "components/history/core/browser/history_types.h"
#include "components/sync/model/sync_change.h"
@@ -24,10 +24,6 @@
class GURL;
-namespace base {
-class MessageLoop;
-};
-
namespace sync_pb {
class TypedUrlSpecifics;
};
@@ -236,7 +232,7 @@ class TypedUrlSyncableService : public syncer::SyncableService,
int num_db_accesses_;
int num_db_errors_;
- base::ThreadChecker thread_checker_;
+ base::SequenceChecker sequence_checker_;
ScopedObserver<history::HistoryBackend, history::HistoryBackendObserver>
history_backend_observer_;
diff --git a/chromium/components/history/core/browser/web_history_service.cc b/chromium/components/history/core/browser/web_history_service.cc
index abe202c87cd..e90d3b884e4 100644
--- a/chromium/components/history/core/browser/web_history_service.cc
+++ b/chromium/components/history/core/browser/web_history_service.cc
@@ -275,11 +275,15 @@ GURL GetQueryUrl(const base::string16& text_query,
url = net::AppendQueryParameter(url, "titles", "1");
// Take |begin_time|, |end_time|, and |max_count| from the original query
- // options, and convert them to the equivalent URL parameters.
+ // options, and convert them to the equivalent URL parameters. Note that
+ // QueryOptions uses exclusive |end_time| while the history.google.com API
+ // uses it inclusively, so we subtract 1us during conversion.
base::Time end_time =
- std::min(base::Time::FromInternalValue(options.EffectiveEndTime()),
- base::Time::Now());
+ options.end_time.is_null()
+ ? base::Time::Now()
+ : std::min(options.end_time - base::TimeDelta::FromMicroseconds(1),
+ base::Time::Now());
url = net::AppendQueryParameter(url, "max", ServerTimeString(end_time));
if (!options.begin_time.is_null()) {
@@ -360,7 +364,7 @@ std::unique_ptr<base::DictionaryValue> WebHistoryService::ReadResponse(
if (request->GetResponseCode() == net::HTTP_OK) {
std::unique_ptr<base::Value> value =
base::JSONReader::Read(request->GetResponseBody());
- if (value.get() && value.get()->IsType(base::Value::TYPE_DICTIONARY))
+ if (value.get() && value.get()->IsType(base::Value::Type::DICTIONARY))
result.reset(static_cast<base::DictionaryValue*>(value.release()));
else
DLOG(WARNING) << "Non-JSON response received from history server.";