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

Unified Diff: ios/chrome/browser/dom_distiller/distiller_viewer.h

Issue 2666643002: Remove usage of DomDistillerService in ReadingListDownloadService. (Closed)
Patch Set: feedback Created 3 years, 11 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
Index: ios/chrome/browser/dom_distiller/distiller_viewer.h
diff --git a/ios/chrome/browser/dom_distiller/distiller_viewer.h b/ios/chrome/browser/dom_distiller/distiller_viewer.h
index b4a82b37732736244914d2eb6e0e24ab0b4fa572..a67f4cad78189538585a57d9eccc73eb8e7b3541 100644
--- a/ios/chrome/browser/dom_distiller/distiller_viewer.h
+++ b/ios/chrome/browser/dom_distiller/distiller_viewer.h
@@ -17,6 +17,7 @@ class GURL;
namespace dom_distiller {
class DistilledPagePrefs;
+class Distiller;
// An interface for a dom_distiller ViewRequestDelegate that distills a URL and
// calls the given callback with the distilled HTML string and the images it
@@ -35,8 +36,7 @@ class DistillerViewerInterface : public DomDistillerRequestViewBase {
const std::string& title)>
DistillationFinishedCallback;
- DistillerViewerInterface(dom_distiller::DomDistillerService* distillerService,
- PrefService* prefs)
+ DistillerViewerInterface(PrefService* prefs)
: DomDistillerRequestViewBase(new DistilledPagePrefs(prefs)) {}
~DistillerViewerInterface() override {}
@@ -52,29 +52,48 @@ class DistillerViewerInterface : public DomDistillerRequestViewBase {
class DistillerViewer : public DistillerViewerInterface {
public:
// Creates a |DistillerView| that will be used to distill |url|.
- // If |page| is not null, it will be used to load |url| and inject the page.
- // If |page| is null, the default factory of |distillerService| will be used.
// |callback| is called when distillation is finished with the protobuf
// containing the distilled page.
DistillerViewer(dom_distiller::DomDistillerService* distillerService,
PrefService* prefs,
const GURL& url,
- const DistillationFinishedCallback& callback,
- std::unique_ptr<dom_distiller::DistillerPage> page);
+ const DistillationFinishedCallback& callback);
+
+ // Creates a |DistillerView| without depending on the DomDistillerService.
+ // Caller must provide |distiller_factory| and |page| which cannot be null.
+ // |callback| is called when distillation is finished with the protobuf
+ // containing the distilled page.
+ DistillerViewer(dom_distiller::DistillerFactory* distiller_factory,
+ std::unique_ptr<dom_distiller::DistillerPage> page,
+ PrefService* prefs,
+ const GURL& url,
+ const DistillationFinishedCallback& callback);
~DistillerViewer() override;
+ // DistillerViewerInterface implementation
+ // Called by the distiller service when article is ready.
void OnArticleReady(
const dom_distiller::DistilledArticleProto* article_proto) override;
void SendJavaScript(const std::string& buffer) override;
private:
+ // Called by the distiller when article is ready.
+ void OnDistillerFinished(
+ std::unique_ptr<dom_distiller::DistilledArticleProto> distilled_article);
+
+ // Called by the distiller when article is updated.
+ void OnArticleDistillationUpdated(
+ const dom_distiller::ArticleDistillationUpdate& article_update);
+
// The url of the distilled page.
const GURL url_;
// JavaScript buffer.
std::string js_buffer_;
// Callback to run once distillation is complete.
const DistillationFinishedCallback callback_;
+ // Keep reference of the distiller_ during distillation.
+ std::unique_ptr<Distiller> distiller_;
DISALLOW_COPY_AND_ASSIGN(DistillerViewer);
};

Powered by Google App Engine
This is Rietveld 408576698