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

Unified Diff: components/ntp_snippets/remote/ntp_snippets_database.h

Issue 2379113002: Extended the ProtoDatabase to provide LoadKeys() functionality. (Closed)
Patch Set: Garbage Collect orphaned images on service start-up. Created 4 years, 2 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/leveldb_proto/testing/fake_db.h ('k') | components/ntp_snippets/remote/ntp_snippets_database.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ntp_snippets/remote/ntp_snippets_database.h
diff --git a/components/ntp_snippets/remote/ntp_snippets_database.h b/components/ntp_snippets/remote/ntp_snippets_database.h
index 9c903f0a86c9343b46ae41a6c8a137f1927b9aa3..37c8b78a220bd2e5496686626ac0a6edd13adb03 100644
--- a/components/ntp_snippets/remote/ntp_snippets_database.h
+++ b/components/ntp_snippets/remote/ntp_snippets_database.h
@@ -6,6 +6,7 @@
#define COMPONENTS_NTP_SNIPPETS_REMOTE_NTP_SNIPPETS_DATABASE_H_
#include <memory>
+#include <set>
#include <string>
#include <utility>
#include <vector>
@@ -74,6 +75,10 @@ class NTPSnippetsDatabase {
void DeleteImage(const std::string& snippet_id);
// Deletes the image data for the given snippets (identified by their IDs).
void DeleteImages(const NTPSnippet::PtrVector& snippets);
+ // Deletes all images which are not associated with any of the provided
+ // snippets.
+ void GarbageCollectImages(
+ std::unique_ptr<std::set<std::string>> alive_snippets);
private:
friend class NTPSnippetsDatabaseTest;
@@ -111,6 +116,10 @@ class NTPSnippetsDatabase {
const SnippetImageCallback& callback);
void DeleteImagesImpl(
std::unique_ptr<std::vector<std::string>> keys_to_remove);
+ void DeleteUnreferencedImages(
+ std::unique_ptr<std::set<std::string>> references,
+ bool success,
+ std::unique_ptr<std::vector<std::string>> keys);
std::unique_ptr<leveldb_proto::ProtoDatabase<SnippetProto>> database_;
bool database_initialized_;
« no previous file with comments | « components/leveldb_proto/testing/fake_db.h ('k') | components/ntp_snippets/remote/ntp_snippets_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698