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

Unified Diff: components/precache/core/precache_database.cc

Issue 1961153003: Add pause/resume functionality to precache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: test fix Created 4 years, 7 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 | « components/precache/core/precache_database.h ('k') | components/precache/core/precache_fetcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/precache/core/precache_database.cc
diff --git a/components/precache/core/precache_database.cc b/components/precache/core/precache_database.cc
index c6362fe3c226c8da6ed82fe4e5c97711292ca7c3..e9d53ecad16d8bc30ebd4415013430d1bd131dda 100644
--- a/components/precache/core/precache_database.cc
+++ b/components/precache/core/precache_database.cc
@@ -12,6 +12,7 @@
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
#include "components/history/core/browser/history_constants.h"
+#include "components/precache/core/proto/unfinished_work.pb.h"
#include "sql/connection.h"
#include "sql/transaction.h"
#include "url/gurl.h"
@@ -51,7 +52,8 @@ bool PrecacheDatabase::Init(const base::FilePath& db_path) {
return false;
}
- if (!precache_url_table_.Init(db_.get())) {
+ if (!precache_url_table_.Init(db_.get()) ||
+ !precache_session_table_.Init(db_.get())) {
// Raze and close the database connection to indicate that it's not usable,
// and so that the database will be created anew next time, in case it's
// corrupted.
@@ -259,4 +261,26 @@ void PrecacheDatabase::MaybePostFlush() {
is_flush_posted_ = true;
}
+std::unique_ptr<PrecacheUnfinishedWork>
+PrecacheDatabase::GetUnfinishedWork() {
+ std::unique_ptr<PrecacheUnfinishedWork> unfinished_work =
+ precache_session_table_.GetUnfinishedWork();
+ precache_session_table_.DeleteUnfinishedWork();
+ return unfinished_work;
+}
+
+void PrecacheDatabase::SaveUnfinishedWork(
+ std::unique_ptr<PrecacheUnfinishedWork> unfinished_work) {
+ precache_session_table_.SaveUnfinishedWork(
+ std::move(unfinished_work));
+}
+
+void PrecacheDatabase::DeleteUnfinishedWork() {
+ precache_session_table_.DeleteUnfinishedWork();
+}
+
+base::WeakPtr<PrecacheDatabase> PrecacheDatabase::GetWeakPtr() {
+ return weak_factory_.GetWeakPtr();
+}
+
} // namespace precache
« no previous file with comments | « components/precache/core/precache_database.h ('k') | components/precache/core/precache_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698