Index: components/dom_distiller/core/distiller.h |
diff --git a/components/dom_distiller/core/distiller.h b/components/dom_distiller/core/distiller.h |
index adbd41b8cbb294a99f14f15740e6b40c839d767e..58513281ac7587921ea94b19cbcf2e82c4a7c4db 100644 |
--- a/components/dom_distiller/core/distiller.h |
+++ b/components/dom_distiller/core/distiller.h |
@@ -6,6 +6,7 @@ |
#define COMPONENTS_DOM_DISTILLER_CORE_DISTILLER_H_ |
#include <map> |
+#include <set> |
#include <string> |
#include "base/callback.h" |
@@ -14,7 +15,7 @@ |
#include "base/values.h" |
#include "components/dom_distiller/core/distiller_page.h" |
#include "components/dom_distiller/core/distiller_url_fetcher.h" |
-#include "components/dom_distiller/core/proto/distilled_page.pb.h" |
+#include "components/dom_distiller/core/proto/distilled_article.pb.h" |
#include "net/url_request/url_request_context_getter.h" |
#include "url/gurl.h" |
@@ -24,8 +25,8 @@ class DistillerImpl; |
class Distiller { |
public: |
- typedef base::Callback<void( |
- scoped_ptr<DistilledPageProto>)> DistillerCallback; |
+ typedef base::Callback<void(scoped_ptr<DistilledArticleProto>)> |
+ DistillerCallback; |
virtual ~Distiller() {} |
// Distills a page, and asynchrounously returns the article HTML to the |
@@ -74,24 +75,43 @@ class DistillerImpl : public Distiller, |
virtual void OnLoadURLDone() OVERRIDE; |
virtual void OnExecuteJavaScriptDone(const base::Value* value) OVERRIDE; |
- void OnFetchImageDone(const std::string& id, const std::string& response); |
+ void OnFetchImageDone(DistilledPageProto* distilled_page_proto, |
+ const std::string& id, |
+ const std::string& response); |
private: |
virtual void LoadURL(const GURL& url); |
- virtual void FetchImage(const std::string& image_id, const std::string& item); |
+ virtual void FetchImage(DistilledPageProto* distilled_page_proto, |
+ const std::string& image_id, |
+ const std::string& item); |
// Injects JavaScript to distill a loaded page down to its important content, |
// e.g., extracting a news article from its surrounding boilerplate. |
void GetDistilledContent(); |
+ // Adds url as a new page to the |article_proto_| and triggers distillation |
+ // for the newly added page. |
+ void AddAndDistillPage(const GURL& url); |
+ |
+ // Distills the page. |
+ void DistillNextPage(const GURL& url); |
+ |
+ // Runs distillation callback when all distillation tasks are finished. |
+ void DistillationTaskComplete(); |
+ |
+ // Returns the last page of |article_proto_|. |
+ DistilledPageProto* GetLastPage() const; |
+ |
const DistillerPageFactory& distiller_page_factory_; |
const DistillerURLFetcherFactory& distiller_url_fetcher_factory_; |
scoped_ptr<DistillerPage> distiller_page_; |
DistillerCallback distillation_cb_; |
std::map<std::string, DistillerURLFetcher* > image_fetchers_; |
- |
- scoped_ptr<DistilledPageProto> proto_; |
+ scoped_ptr<DistilledArticleProto> article_proto_; |
+ bool distillation_in_progress_; |
+ // Set to keep track of which urls are already seen by the distiller. |
+ std::set<std::string> processed_urls_; |
DISALLOW_COPY_AND_ASSIGN(DistillerImpl); |
}; |