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

Unified Diff: third_party/dom_distiller_js/package/proto_gen/third_party/dom_distiller_js/dom_distiller_json_converter.h

Issue 608583003: Roll dom_distiller_js and add UMA for word count for distilled pages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments from isherman and rolled dom distiller Created 6 years, 3 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: third_party/dom_distiller_js/package/proto_gen/third_party/dom_distiller_js/dom_distiller_json_converter.h
diff --git a/third_party/dom_distiller_js/package/proto_gen/third_party/dom_distiller_js/dom_distiller_json_converter.h b/third_party/dom_distiller_js/package/proto_gen/third_party/dom_distiller_js/dom_distiller_json_converter.h
index 701cae118c91379d018f25eda365d26a7c4b3679..91a0ecf0a0bf7b889de63e4fc225c4dd8ab7a67a 100644
--- a/third_party/dom_distiller_js/package/proto_gen/third_party/dom_distiller_js/dom_distiller_json_converter.h
+++ b/third_party/dom_distiller_js/package/proto_gen/third_party/dom_distiller_js/dom_distiller_json_converter.h
@@ -456,6 +456,33 @@ namespace dom_distiller {
}
};
+ class StatisticsInfo {
+ public:
+ static bool ReadFromValue(const base::Value* json, dom_distiller::proto::StatisticsInfo* message) {
+ const base::DictionaryValue* dict;
+ if (!json->GetAsDictionary(&dict)) goto error;
+ if (dict->HasKey("1")) {
+ int field_value;
+ if (!dict->GetInteger("1", &field_value)) {
+ goto error;
+ }
+ message->set_word_count(field_value);
+ }
+ return true;
+
+ error:
+ return false;
+ }
+
+ static scoped_ptr<base::Value> WriteToValue(const dom_distiller::proto::StatisticsInfo& message) {
+ scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
+ if (message.has_word_count()) {
+ dict->SetInteger("1", message.word_count());
+ }
+ return dict.PassAs<base::Value>();
+ }
+ };
+
class DomDistillerResult {
public:
static bool ReadFromValue(const base::Value* json, dom_distiller::proto::DomDistillerResult* message) {
@@ -526,6 +553,15 @@ namespace dom_distiller {
goto error;
}
}
+ if (dict->HasKey("8")) {
+ const base::Value* inner_message_value;
+ if (!dict->Get("8", &inner_message_value)) {
+ goto error;
+ }
+ if (!dom_distiller::proto::json::StatisticsInfo::ReadFromValue(inner_message_value, message->mutable_statistics_info())) {
+ goto error;
+ }
+ }
return true;
error:
@@ -567,6 +603,11 @@ namespace dom_distiller {
dom_distiller::proto::json::DebugInfo::WriteToValue(message.debug_info());
dict->Set("7", inner_message_value.release());
}
+ if (message.has_statistics_info()) {
+ scoped_ptr<base::Value> inner_message_value =
+ dom_distiller::proto::json::StatisticsInfo::WriteToValue(message.statistics_info());
+ dict->Set("8", inner_message_value.release());
+ }
return dict.PassAs<base::Value>();
}
};
« no previous file with comments | « third_party/dom_distiller_js/package/proto/dom_distiller.proto ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698