#include "base/guid.h"
#include "base/message_loop/message_loop.h"
#include "components/dom_distiller/core/dom_distiller_store.h"
+#include "components/dom_distiller/core/proto/distilled_article.pb.h"
#include "components/dom_distiller/core/task_tracker.h"
#include "url/gurl.h"
void RunArticleAvailableCallback(
const DomDistillerService::ArticleAvailableCallback& article_cb,
const ArticleEntry& entry,
- DistilledPageProto* proto,
+ const DistilledArticleProto* article_proto,
bool distillation_succeeded) {
article_cb.Run(distillation_succeeded);
}
scoped_ptr<ArticleEntry> DomDistillerService::RemoveEntry(
const std::string& entry_id) {
scoped_ptr<ArticleEntry> entry(new ArticleEntry);
- if (!store_->GetEntryById(entry_id, entry.get())) {
- return scoped_ptr<ArticleEntry>();
- }
-
+ entry->set_entry_id(entry_id);
TaskTracker* task_tracker = GetTaskTrackerForEntry(*entry);
if (task_tracker != NULL) {
task_tracker->CancelSaveCallbacks();
}
+ if (!store_->GetEntryById(entry_id, entry.get())) {
+ return scoped_ptr<ArticleEntry>();
+ }
+
if (store_->RemoveEntry(*entry)) {
return entry.Pass();
}
ArticleEntry skeleton_entry = CreateSkeletonEntryForUrl(url);
TaskTracker* task_tracker = CreateTaskTracker(skeleton_entry);
- store_->AddEntry(skeleton_entry);
return task_tracker;
}
}
}
-void DomDistillerService::AddDistilledPageToList(const ArticleEntry& entry,
- DistilledPageProto* proto,
- bool distillation_succeeded) {
+void DomDistillerService::AddDistilledPageToList(
+ const ArticleEntry& entry,
+ const DistilledArticleProto* article_proto,
+ bool distillation_succeeded) {
DCHECK(IsEntryValid(entry));
if (distillation_succeeded) {
- DCHECK(proto);
- store_->UpdateEntry(entry);
+ DCHECK(article_proto);
+ DCHECK_GT(article_proto->pages_size(), 0);
+ store_->AddEntry(entry);
+ DCHECK_EQ(article_proto->pages_size(), entry.pages_size());
}
}