Commit 3d377a4a authored by nyquist's avatar nyquist Committed by Commit bot

Add DebugInfo to DistilledPageProto.

Adds a DebugInfo message to the DistilledPageProto. The data for this message
is copied from the DomDistillerResult proto DebugInfo.

For now, only a field for the distiller log exists.

Depends on https://codereview.chromium.org/493853006/

BUG=409274

Review URL: https://codereview.chromium.org/504263002

Cr-Commit-Position: refs/heads/master@{#293205}
parent bfa75d81
...@@ -155,6 +155,11 @@ void DistillerImpl::OnPageDistillationFinished( ...@@ -155,6 +155,11 @@ void DistillerImpl::OnPageDistillationFinished(
page_data->distilled_page_proto->data.set_html( page_data->distilled_page_proto->data.set_html(
distiller_result->distilled_content().html()); distiller_result->distilled_content().html());
} }
if (distiller_result->has_debug_info() &&
distiller_result->debug_info().has_log()) {
page_data->distilled_page_proto->data.mutable_debug_info()->set_log(
distiller_result->debug_info().log());
}
if (distiller_result->has_pagination_info()) { if (distiller_result->has_pagination_info()) {
proto::PaginationInfo pagination_info = proto::PaginationInfo pagination_info =
......
...@@ -45,6 +45,7 @@ const size_t kTotalImages = 2; ...@@ -45,6 +45,7 @@ const size_t kTotalImages = 2;
const char* kImageURLs[kTotalImages] = {"http://a.com/img1.jpg", const char* kImageURLs[kTotalImages] = {"http://a.com/img1.jpg",
"http://a.com/img2.jpg"}; "http://a.com/img2.jpg"};
const char* kImageData[kTotalImages] = {"abcde", "12345"}; const char* kImageData[kTotalImages] = {"abcde", "12345"};
const char kDebugLog[] = "Debug Log";
const string GetImageName(int page_num, int image_num) { const string GetImageName(int page_num, int image_num) {
return base::IntToString(page_num) + "_" + base::IntToString(image_num); return base::IntToString(page_num) + "_" + base::IntToString(image_num);
...@@ -341,6 +342,20 @@ TEST_F(DistillerTest, DistillPage) { ...@@ -341,6 +342,20 @@ TEST_F(DistillerTest, DistillPage) {
EXPECT_EQ(kURL, first_page.url()); EXPECT_EQ(kURL, first_page.url());
} }
TEST_F(DistillerTest, DistillPageWithDebugInfo) {
base::MessageLoopForUI loop;
DomDistillerResult dd_result;
dd_result.mutable_debug_info()->set_log(kDebugLog);
scoped_ptr<base::Value> result =
dom_distiller::proto::json::DomDistillerResult::WriteToValue(dd_result);
distiller_.reset(
new DistillerImpl(url_fetcher_factory_, DomDistillerOptions()));
DistillPage(kURL, CreateMockDistillerPage(result.get(), GURL(kURL)).Pass());
base::MessageLoop::current()->RunUntilIdle();
const DistilledPageProto& first_page = article_proto_->pages(0);
EXPECT_EQ(kDebugLog, first_page.debug_info().log());
}
TEST_F(DistillerTest, DistillPageWithImages) { TEST_F(DistillerTest, DistillPageWithImages) {
base::MessageLoopForUI loop; base::MessageLoopForUI loop;
vector<int> image_indices; vector<int> image_indices;
......
...@@ -31,4 +31,12 @@ message DistilledPageProto { ...@@ -31,4 +31,12 @@ message DistilledPageProto {
// Title for the current page. // Title for the current page.
optional string title = 5; optional string title = 5;
}
\ No newline at end of file message DebugInfo {
// Contains the log from the JS distiller.
optional string log = 1;
}
// Debug information about this page.
optional DebugInfo debug_info = 6;
}
...@@ -143,6 +143,8 @@ std::string GetReadableArticleString( ...@@ -143,6 +143,8 @@ std::string GetReadableArticleString(
output << "Page " << i << std::endl; output << "Page " << i << std::endl;
output << "URL: " << page.url() << std::endl; output << "URL: " << page.url() << std::endl;
output << "Content: " << page.html() << std::endl; output << "Content: " << page.html() << std::endl;
if (page.has_debug_info() && page.debug_info().has_log())
output << "Log: " << page.debug_info().log() << std::endl;
} }
return output.str(); return output.str();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment