Commit e1378363 authored by yfriedman's avatar yfriedman Committed by Commit bot

Roll dom_distiller_js

Picked up changes:
078e633 Add support for outputting debug info in result.
0cc1705 Instrument DomDistiller with timing information.
73e3327 rejiggle 1 table classification heuristic

BUG=368941

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

Cr-Commit-Position: refs/heads/master@{#292194}
parent fd497eb3
Name: dom-distiller-js
URL: https://code.google.com/p/dom-distiller
Version: ddc9a76075
Version: 078e633ac4
License: BSD
Security Critical: yes
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -48,12 +48,26 @@ message MarkupInfo {
repeated MarkupImage images = 9;
}
message TimingInfo {
optional double markup_parsing_time = 1;
optional double document_construction_time = 2;
optional double article_processing_time = 3;
optional double formatting_time = 4;
optional double total_time = 5;
}
message DebugInfo {
optional string log = 1;
}
message DomDistillerResult {
optional string title = 1;
optional DistilledContent distilled_content = 2;
optional PaginationInfo pagination_info = 3;
repeated string image_urls = 4;
optional MarkupInfo markup_info = 5;
optional TimingInfo timing_info = 6;
optional DebugInfo debug_info = 7;
}
message DomDistillerOptions {
......
......@@ -365,6 +365,102 @@ namespace dom_distiller {
}
};
class TimingInfo {
public:
static dom_distiller::proto::TimingInfo ReadFromValue(const base::Value* json) {
dom_distiller::proto::TimingInfo message;
const base::DictionaryValue* dict;
if (!json->GetAsDictionary(&dict)) goto error;
if (dict->HasKey("1")) {
double field_value;
if (!dict->GetDouble("1", &field_value)) {
goto error;
}
message.set_markup_parsing_time(field_value);
}
if (dict->HasKey("2")) {
double field_value;
if (!dict->GetDouble("2", &field_value)) {
goto error;
}
message.set_document_construction_time(field_value);
}
if (dict->HasKey("3")) {
double field_value;
if (!dict->GetDouble("3", &field_value)) {
goto error;
}
message.set_article_processing_time(field_value);
}
if (dict->HasKey("4")) {
double field_value;
if (!dict->GetDouble("4", &field_value)) {
goto error;
}
message.set_formatting_time(field_value);
}
if (dict->HasKey("5")) {
double field_value;
if (!dict->GetDouble("5", &field_value)) {
goto error;
}
message.set_total_time(field_value);
}
return message;
error:
return dom_distiller::proto::TimingInfo();
}
static scoped_ptr<base::Value> WriteToValue(const dom_distiller::proto::TimingInfo& message) {
scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
if (message.has_markup_parsing_time()) {
dict->SetDouble("1", message.markup_parsing_time());
}
if (message.has_document_construction_time()) {
dict->SetDouble("2", message.document_construction_time());
}
if (message.has_article_processing_time()) {
dict->SetDouble("3", message.article_processing_time());
}
if (message.has_formatting_time()) {
dict->SetDouble("4", message.formatting_time());
}
if (message.has_total_time()) {
dict->SetDouble("5", message.total_time());
}
return dict.PassAs<base::Value>();
}
};
class DebugInfo {
public:
static dom_distiller::proto::DebugInfo ReadFromValue(const base::Value* json) {
dom_distiller::proto::DebugInfo message;
const base::DictionaryValue* dict;
if (!json->GetAsDictionary(&dict)) goto error;
if (dict->HasKey("1")) {
std::string field_value;
if (!dict->GetString("1", &field_value)) {
goto error;
}
message.set_log(field_value);
}
return message;
error:
return dom_distiller::proto::DebugInfo();
}
static scoped_ptr<base::Value> WriteToValue(const dom_distiller::proto::DebugInfo& message) {
scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
if (message.has_log()) {
dict->SetString("1", message.log());
}
return dict.PassAs<base::Value>();
}
};
class DomDistillerResult {
public:
static dom_distiller::proto::DomDistillerResult ReadFromValue(const base::Value* json) {
......@@ -415,6 +511,22 @@ namespace dom_distiller {
*message.mutable_markup_info() =
dom_distiller::proto::json::MarkupInfo::ReadFromValue(inner_message_value);
}
if (dict->HasKey("6")) {
const base::Value* inner_message_value;
if (!dict->Get("6", &inner_message_value)) {
goto error;
}
*message.mutable_timing_info() =
dom_distiller::proto::json::TimingInfo::ReadFromValue(inner_message_value);
}
if (dict->HasKey("7")) {
const base::Value* inner_message_value;
if (!dict->Get("7", &inner_message_value)) {
goto error;
}
*message.mutable_debug_info() =
dom_distiller::proto::json::DebugInfo::ReadFromValue(inner_message_value);
}
return message;
error:
......@@ -446,6 +558,16 @@ namespace dom_distiller {
dom_distiller::proto::json::MarkupInfo::WriteToValue(message.markup_info());
dict->Set("5", inner_message_value.release());
}
if (message.has_timing_info()) {
scoped_ptr<base::Value> inner_message_value =
dom_distiller::proto::json::TimingInfo::WriteToValue(message.timing_info());
dict->Set("6", inner_message_value.release());
}
if (message.has_debug_info()) {
scoped_ptr<base::Value> inner_message_value =
dom_distiller::proto::json::DebugInfo::WriteToValue(message.debug_info());
dict->Set("7", inner_message_value.release());
}
return dict.PassAs<base::Value>();
}
};
......
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