| Index: components/dom_distiller/core/dom_distiller_store.h
|
| diff --git a/components/dom_distiller/core/dom_distiller_store.h b/components/dom_distiller/core/dom_distiller_store.h
|
| index 2a741e043949179b796473039e0a2f70e31097de..4eda8391184dc2fd7c2b47bb61b4eee853f1b339 100644
|
| --- a/components/dom_distiller/core/dom_distiller_store.h
|
| +++ b/components/dom_distiller/core/dom_distiller_store.h
|
| @@ -11,6 +11,7 @@
|
| #include "base/containers/hash_tables.h"
|
| #include "base/memory/weak_ptr.h"
|
| #include "base/observer_list.h"
|
| +#include "components/dom_distiller/core/article_attachments_data.h"
|
| #include "components/dom_distiller/core/article_entry.h"
|
| #include "components/dom_distiller/core/dom_distiller_model.h"
|
| #include "components/dom_distiller/core/dom_distiller_observer.h"
|
| @@ -27,6 +28,10 @@ namespace base {
|
| class FilePath;
|
| }
|
|
|
| +namespace syncer {
|
| +class AttachmentStore;
|
| +}
|
| +
|
| namespace dom_distiller {
|
|
|
| // Interface for accessing the stored/synced DomDistiller entries.
|
| @@ -42,6 +47,28 @@ class DomDistillerStoreInterface {
|
| virtual bool UpdateEntry(const ArticleEntry& entry) = 0;
|
| virtual bool RemoveEntry(const ArticleEntry& entry) = 0;
|
|
|
| + typedef base::Callback<void(bool success)> UpdateAttachmentsCallback;
|
| + typedef base::Callback<void(bool success,
|
| + scoped_ptr<ArticleAttachmentsData> attachments)>
|
| + GetAttachmentsCallback;
|
| +
|
| + // Updates the attachments for an entry. The callback will be called with
|
| + // success==true once the new attachments have been stored locally and the
|
| + // entry has been updated. It will be called with success==false if that
|
| + // failed (e.g. storing the attachment failed, the entry couldn't be found,
|
| + // etc.).
|
| + virtual void UpdateAttachments(
|
| + const std::string& entry_id,
|
| + scoped_ptr<ArticleAttachmentsData> attachments,
|
| + const UpdateAttachmentsCallback& callback) = 0;
|
| +
|
| + // Gets the attachments for an entry. If the attachments are available (either
|
| + // locally or from sync), the callback will be called with success==true and
|
| + // a pointer to the attachments. Otherwise it will be called with
|
| + // success==false.
|
| + virtual void GetAttachments(const std::string& entry_id,
|
| + const GetAttachmentsCallback& callback) = 0;
|
| +
|
| // Lookup an ArticleEntry by ID or URL. Returns whether a corresponding entry
|
| // was found. On success, if |entry| is not null, it will contain the entry.
|
| virtual bool GetEntryById(const std::string& entry_id,
|
| @@ -94,12 +121,22 @@ class DomDistillerStore : public syncer::SyncableService,
|
|
|
| // DomDistillerStoreInterface implementation.
|
| syncer::SyncableService* GetSyncableService() override;
|
| +
|
| bool AddEntry(const ArticleEntry& entry) override;
|
| bool UpdateEntry(const ArticleEntry& entry) override;
|
| bool RemoveEntry(const ArticleEntry& entry) override;
|
| +
|
| + virtual void UpdateAttachments(
|
| + const std::string& entry_id,
|
| + scoped_ptr<ArticleAttachmentsData> attachments_data,
|
| + const UpdateAttachmentsCallback& callback) override;
|
| + virtual void GetAttachments(const std::string& entry_id,
|
| + const GetAttachmentsCallback& callback) override;
|
| +
|
| bool GetEntryById(const std::string& entry_id, ArticleEntry* entry) override;
|
| bool GetEntryByUrl(const GURL& url, ArticleEntry* entry) override;
|
| std::vector<ArticleEntry> GetEntries() const override;
|
| +
|
| void AddObserver(DomDistillerObserver* observer) override;
|
| void RemoveObserver(DomDistillerObserver* observer) override;
|
|
|
| @@ -124,6 +161,18 @@ class DomDistillerStore : public syncer::SyncableService,
|
| bool ChangeEntry(const ArticleEntry& entry,
|
| syncer::SyncChange::SyncChangeType changeType);
|
|
|
| + void OnAttachmentsWrite(
|
| + const std::string& entry_id,
|
| + scoped_ptr<sync_pb::ArticleAttachments> article_attachments,
|
| + const UpdateAttachmentsCallback& callback,
|
| + const syncer::AttachmentStore::Result& result);
|
| +
|
| + void OnAttachmentsRead(const sync_pb::ArticleAttachments& attachments_proto,
|
| + const GetAttachmentsCallback& callback,
|
| + const syncer::AttachmentStore::Result& result,
|
| + scoped_ptr<syncer::AttachmentMap> attachments,
|
| + scoped_ptr<syncer::AttachmentIdList> missing);
|
| +
|
| syncer::SyncMergeResult MergeDataWithModel(
|
| const syncer::SyncDataList& data, syncer::SyncChangeList* changes_applied,
|
| syncer::SyncChangeList* changes_missing);
|
| @@ -151,6 +200,7 @@ class DomDistillerStore : public syncer::SyncableService,
|
| scoped_ptr<syncer::SyncErrorFactory> error_factory_;
|
| scoped_ptr<leveldb_proto::ProtoDatabase<ArticleEntry> > database_;
|
| bool database_loaded_;
|
| + scoped_refptr<syncer::AttachmentStore> attachment_store_;
|
| ObserverList<DomDistillerObserver> observers_;
|
|
|
| DomDistillerModel model_;
|
|
|