| Index: components/dom_distiller/core/task_tracker.cc
|
| diff --git a/components/dom_distiller/core/task_tracker.cc b/components/dom_distiller/core/task_tracker.cc
|
| index 5dd17d3a598b6976caabd263374948ae3f358c58..c6829897e9a974d735747c9c9e823b86bc4fb32a 100644
|
| --- a/components/dom_distiller/core/task_tracker.cc
|
| +++ b/components/dom_distiller/core/task_tracker.cc
|
| @@ -6,6 +6,7 @@
|
|
|
| #include "base/auto_reset.h"
|
| #include "base/message_loop/message_loop.h"
|
| +#include "components/dom_distiller/core/distilled_content_store.h"
|
| #include "components/dom_distiller/core/proto/distilled_article.pb.h"
|
| #include "components/dom_distiller/core/proto/distilled_page.pb.h"
|
|
|
| @@ -20,8 +21,11 @@ ViewerHandle::~ViewerHandle() {
|
| }
|
| }
|
|
|
| -TaskTracker::TaskTracker(const ArticleEntry& entry, CancelCallback callback)
|
| +TaskTracker::TaskTracker(const ArticleEntry& entry,
|
| + CancelCallback callback,
|
| + DistilledContentStore* content_store)
|
| : cancel_callback_(callback),
|
| + content_store_(content_store),
|
| entry_(entry),
|
| distilled_article_(),
|
| content_ready_(false),
|
| @@ -40,7 +44,6 @@ void TaskTracker::StartDistiller(DistillerFactory* factory) {
|
| if (entry_.pages_size() == 0) {
|
| return;
|
| }
|
| -
|
| GURL url(entry_.pages(0).url());
|
| DCHECK(url.is_valid());
|
|
|
| @@ -53,9 +56,11 @@ void TaskTracker::StartDistiller(DistillerFactory* factory) {
|
| }
|
|
|
| void TaskTracker::StartBlobFetcher() {
|
| - // TODO(cjhopman): There needs to be some local storage for the distilled
|
| - // blob. When that happens, this should start some task to fetch the blob for
|
| - // |entry_| and asynchronously notify |this| when it is done.
|
| + if (content_store_) {
|
| + content_store_->LoadContent(entry_,
|
| + base::Bind(&TaskTracker::OnBlobFetched,
|
| + weak_ptr_factory_.GetWeakPtr()));
|
| + }
|
| }
|
|
|
| void TaskTracker::AddSaveCallback(const SaveCallback& callback) {
|
| @@ -146,11 +151,23 @@ void TaskTracker::NotifyViewer(ViewRequestDelegate* delegate) {
|
|
|
| void TaskTracker::OnDistillerFinished(
|
| scoped_ptr<DistilledArticleProto> distilled_article) {
|
| - OnDistilledArticleReady(distilled_article.Pass());
|
| + if (!content_ready_) {
|
| + OnDistilledArticleReady(distilled_article.Pass());
|
| + }
|
| +}
|
| +
|
| +void TaskTracker::OnBlobFetched(
|
| + bool success,
|
| + scoped_ptr<DistilledArticleProto> distilled_article) {
|
| + if (!content_ready_ && success) {
|
| + OnDistilledArticleReady(distilled_article.Pass());
|
| + }
|
| }
|
|
|
| void TaskTracker::OnDistilledArticleReady(
|
| scoped_ptr<DistilledArticleProto> distilled_article) {
|
| + DCHECK(!content_ready_);
|
| + content_ready_ = true;
|
| distilled_article_ = distilled_article.Pass();
|
| bool distillation_successful = false;
|
| if (distilled_article_->pages_size() > 0) {
|
|
|