| Index: components/dom_distiller/core/distiller_page.cc
|
| diff --git a/components/dom_distiller/core/distiller_page.cc b/components/dom_distiller/core/distiller_page.cc
|
| index f9f1dcc3bfe1c0f0e8dc8d463cba0cbd1664b8dc..9a002e445eed480d3448866e53167e42badd327c 100644
|
| --- a/components/dom_distiller/core/distiller_page.cc
|
| +++ b/components/dom_distiller/core/distiller_page.cc
|
| @@ -50,22 +50,6 @@ std::string GetDistillerScriptWithOptions(
|
|
|
| }
|
|
|
| -DistilledPageInfo::DistilledPageInfo() {}
|
| -
|
| -DistilledPageInfo::~DistilledPageInfo() {}
|
| -
|
| -DistilledPageInfo::MarkupArticle::MarkupArticle() {}
|
| -
|
| -DistilledPageInfo::MarkupArticle::~MarkupArticle() {}
|
| -
|
| -DistilledPageInfo::MarkupImage::MarkupImage() {}
|
| -
|
| -DistilledPageInfo::MarkupImage::~MarkupImage() {}
|
| -
|
| -DistilledPageInfo::MarkupInfo::MarkupInfo() {}
|
| -
|
| -DistilledPageInfo::MarkupInfo::~MarkupInfo() {}
|
| -
|
| DistillerPageFactory::~DistillerPageFactory() {}
|
|
|
| DistillerPage::DistillerPage() : ready_(true) {}
|
| @@ -89,59 +73,18 @@ void DistillerPage::OnDistillationDone(const GURL& page_url,
|
| DCHECK(!ready_);
|
| ready_ = true;
|
|
|
| - scoped_ptr<DistilledPageInfo> page_info(new DistilledPageInfo());
|
| - bool found_content = !value->IsType(base::Value::TYPE_NULL);
|
| - if (found_content) {
|
| - dom_distiller::proto::DomDistillerResult distiller_result =
|
| - dom_distiller::proto::json::DomDistillerResult::ReadFromValue(value);
|
| -
|
| - page_info->title = distiller_result.title();
|
| - page_info->html = distiller_result.distilled_content().html();
|
| - page_info->next_page_url = distiller_result.pagination_info().next_page();
|
| - page_info->prev_page_url = distiller_result.pagination_info().prev_page();
|
| - for (int i = 0; i < distiller_result.image_urls_size(); ++i) {
|
| - const std::string image_url = distiller_result.image_urls(i);
|
| - if (GURL(image_url).is_valid()) {
|
| - page_info->image_urls.push_back(image_url);
|
| - }
|
| - }
|
| - const dom_distiller::proto::MarkupInfo& src_markup_info =
|
| - distiller_result.markup_info();
|
| - DistilledPageInfo::MarkupInfo& dst_markup_info = page_info->markup_info;
|
| - dst_markup_info.title = src_markup_info.title();
|
| - dst_markup_info.type = src_markup_info.type();
|
| - dst_markup_info.url = src_markup_info.url();
|
| - dst_markup_info.description = src_markup_info.description();
|
| - dst_markup_info.publisher = src_markup_info.publisher();
|
| - dst_markup_info.copyright = src_markup_info.copyright();
|
| - dst_markup_info.author = src_markup_info.author();
|
| -
|
| - const dom_distiller::proto::MarkupArticle& src_article =
|
| - src_markup_info.article();
|
| - DistilledPageInfo::MarkupArticle& dst_article = dst_markup_info.article;
|
| - dst_article.published_time = src_article.published_time();
|
| - dst_article.modified_time = src_article.modified_time();
|
| - dst_article.expiration_time = src_article.expiration_time();
|
| - dst_article.section = src_article.section();
|
| - for (int i = 0; i < src_article.authors_size(); ++i) {
|
| - dst_article.authors.push_back(src_article.authors(i));
|
| - }
|
| + scoped_ptr<dom_distiller::proto::DomDistillerResult> distiller_result;
|
|
|
| - for (int i = 0; i < src_markup_info.images_size(); ++i) {
|
| - const dom_distiller::proto::MarkupImage& src_image =
|
| - src_markup_info.images(i);
|
| - DistilledPageInfo::MarkupImage dst_image;
|
| - dst_image.url = src_image.url();
|
| - dst_image.secure_url = src_image.secure_url();
|
| - dst_image.type = src_image.type();
|
| - dst_image.caption = src_image.caption();
|
| - dst_image.width = src_image.width();
|
| - dst_image.height = src_image.height();
|
| - dst_markup_info.images.push_back(dst_image);
|
| - }
|
| - if (distiller_result.has_timing_info()) {
|
| + bool found_content;
|
| + if (value->IsType(base::Value::TYPE_NULL)) {
|
| + found_content = false;
|
| + } else {
|
| + found_content = true;
|
| + distiller_result.reset(new dom_distiller::proto::DomDistillerResult(
|
| + dom_distiller::proto::json::DomDistillerResult::ReadFromValue(value)));
|
| + if (distiller_result->has_timing_info()) {
|
| const dom_distiller::proto::TimingInfo& timing =
|
| - distiller_result.timing_info();
|
| + distiller_result->timing_info();
|
| if (timing.has_markup_parsing_time()) {
|
| UMA_HISTOGRAM_TIMES(
|
| "DomDistiller.Time.MarkupParsing",
|
| @@ -174,8 +117,9 @@ void DistillerPage::OnDistillationDone(const GURL& page_url,
|
|
|
| base::MessageLoop::current()->PostTask(
|
| FROM_HERE,
|
| - base::Bind(
|
| - distiller_page_callback_, base::Passed(&page_info), found_content));
|
| + base::Bind(distiller_page_callback_,
|
| + base::Passed(&distiller_result),
|
| + found_content));
|
| }
|
|
|
| } // namespace dom_distiller
|
|
|