| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_DOM_DISTILLER_CORE_DISTILLER_H_ | 5 #ifndef COMPONENTS_DOM_DISTILLER_CORE_DISTILLER_H_ |
| 6 #define COMPONENTS_DOM_DISTILLER_CORE_DISTILLER_H_ | 6 #define COMPONENTS_DOM_DISTILLER_CORE_DISTILLER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 class DistillerFactory { | 49 class DistillerFactory { |
| 50 public: | 50 public: |
| 51 virtual scoped_ptr<Distiller> CreateDistiller() = 0; | 51 virtual scoped_ptr<Distiller> CreateDistiller() = 0; |
| 52 virtual ~DistillerFactory() {} | 52 virtual ~DistillerFactory() {} |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 // Factory for creating a Distiller. | 55 // Factory for creating a Distiller. |
| 56 class DistillerFactoryImpl : public DistillerFactory { | 56 class DistillerFactoryImpl : public DistillerFactory { |
| 57 public: | 57 public: |
| 58 DistillerFactoryImpl( | 58 DistillerFactoryImpl( |
| 59 scoped_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory); | 59 scoped_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory, |
| 60 const dom_distiller::proto::DomDistillerOptions& dom_distiller_options); |
| 60 virtual ~DistillerFactoryImpl(); | 61 virtual ~DistillerFactoryImpl(); |
| 61 virtual scoped_ptr<Distiller> CreateDistiller() OVERRIDE; | 62 virtual scoped_ptr<Distiller> CreateDistiller() OVERRIDE; |
| 62 | 63 |
| 63 private: | 64 private: |
| 64 scoped_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory_; | 65 scoped_ptr<DistillerURLFetcherFactory> distiller_url_fetcher_factory_; |
| 66 dom_distiller::proto::DomDistillerOptions dom_distiller_options_; |
| 65 }; | 67 }; |
| 66 | 68 |
| 67 // Distills a article from a page and associated pages. | 69 // Distills a article from a page and associated pages. |
| 68 class DistillerImpl : public Distiller { | 70 class DistillerImpl : public Distiller { |
| 69 public: | 71 public: |
| 70 DistillerImpl( | 72 DistillerImpl( |
| 71 const DistillerURLFetcherFactory& distiller_url_fetcher_factory); | 73 const DistillerURLFetcherFactory& distiller_url_fetcher_factory, |
| 74 const dom_distiller::proto::DomDistillerOptions& dom_distiller_options); |
| 72 virtual ~DistillerImpl(); | 75 virtual ~DistillerImpl(); |
| 73 | 76 |
| 74 virtual void DistillPage( | 77 virtual void DistillPage( |
| 75 const GURL& url, | 78 const GURL& url, |
| 76 scoped_ptr<DistillerPage> distiller_page, | 79 scoped_ptr<DistillerPage> distiller_page, |
| 77 const DistillationFinishedCallback& finished_cb, | 80 const DistillationFinishedCallback& finished_cb, |
| 78 const DistillationUpdateCallback& update_cb) OVERRIDE; | 81 const DistillationUpdateCallback& update_cb) OVERRIDE; |
| 79 | 82 |
| 80 void SetMaxNumPagesInArticle(size_t max_num_pages); | 83 void SetMaxNumPagesInArticle(size_t max_num_pages); |
| 81 | 84 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 void AddPageIfDone(int page_num); | 143 void AddPageIfDone(int page_num); |
| 141 | 144 |
| 142 DistilledPageData* GetPageAtIndex(size_t index) const; | 145 DistilledPageData* GetPageAtIndex(size_t index) const; |
| 143 | 146 |
| 144 // Create an ArticleDistillationUpdate for the current distillation | 147 // Create an ArticleDistillationUpdate for the current distillation |
| 145 // state. | 148 // state. |
| 146 const ArticleDistillationUpdate CreateDistillationUpdate() const; | 149 const ArticleDistillationUpdate CreateDistillationUpdate() const; |
| 147 | 150 |
| 148 const DistillerURLFetcherFactory& distiller_url_fetcher_factory_; | 151 const DistillerURLFetcherFactory& distiller_url_fetcher_factory_; |
| 149 scoped_ptr<DistillerPage> distiller_page_; | 152 scoped_ptr<DistillerPage> distiller_page_; |
| 153 |
| 154 dom_distiller::proto::DomDistillerOptions dom_distiller_options_; |
| 150 DistillationFinishedCallback finished_cb_; | 155 DistillationFinishedCallback finished_cb_; |
| 151 DistillationUpdateCallback update_cb_; | 156 DistillationUpdateCallback update_cb_; |
| 152 | 157 |
| 153 // Set of pages that are under distillation or have finished distillation. | 158 // Set of pages that are under distillation or have finished distillation. |
| 154 // |started_pages_index_| and |finished_pages_index_| maintains the mapping | 159 // |started_pages_index_| and |finished_pages_index_| maintains the mapping |
| 155 // from page number to the indices in |pages_|. | 160 // from page number to the indices in |pages_|. |
| 156 ScopedVector<DistilledPageData> pages_; | 161 ScopedVector<DistilledPageData> pages_; |
| 157 | 162 |
| 158 // Maps page numbers of finished pages to the indices in |pages_|. | 163 // Maps page numbers of finished pages to the indices in |pages_|. |
| 159 std::map<int, size_t> finished_pages_index_; | 164 std::map<int, size_t> finished_pages_index_; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 177 bool destruction_allowed_; | 182 bool destruction_allowed_; |
| 178 | 183 |
| 179 base::WeakPtrFactory<DistillerImpl> weak_factory_; | 184 base::WeakPtrFactory<DistillerImpl> weak_factory_; |
| 180 | 185 |
| 181 DISALLOW_COPY_AND_ASSIGN(DistillerImpl); | 186 DISALLOW_COPY_AND_ASSIGN(DistillerImpl); |
| 182 }; | 187 }; |
| 183 | 188 |
| 184 } // namespace dom_distiller | 189 } // namespace dom_distiller |
| 185 | 190 |
| 186 #endif // COMPONENTS_DOM_DISTILLER_CORE_DISTILLER_H_ | 191 #endif // COMPONENTS_DOM_DISTILLER_CORE_DISTILLER_H_ |
| OLD | NEW |