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

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

Issue 282663002: [Reland] Update DomDistillerJsUpdater and Roll DomDistillerJs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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
new file mode 100644
index 0000000000000000000000000000000000000000..534899933839e47d7eb77cfc39628447be90988a
--- /dev/null
+++ b/third_party/dom_distiller_js/package/proto_gen/third_party/dom_distiller_js/dom_distiller_json_converter.h
@@ -0,0 +1,184 @@
+// GENERATED FILE
+// This file generated by DomDistillerJs protoc plugin.
+#include "third_party/dom_distiller_js/dom_distiller.pb.h"
+
+// proto dependencies
+
+// base dependencies
+#include "base/values.h"
+#include "base/memory/scoped_ptr.h"
+
+#include <string>
+
+namespace dom_distiller {
+ namespace proto {
+ namespace json {
+ class DistilledContent {
+ public:
+ static dom_distiller::proto::DistilledContent ReadFromValue(const base::Value* json) {
+ dom_distiller::proto::DistilledContent 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_html(field_value);
+ }
+ return message;
+
+ error:
+ return dom_distiller::proto::DistilledContent();
+ }
+
+ static scoped_ptr<base::Value> WriteToValue(const dom_distiller::proto::DistilledContent& message) {
+ scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
+ if (message.has_html()) {
+ dict->SetString("1", message.html());
+ }
+ return dict.PassAs<base::Value>();
+ }
+ };
+
+ class PaginationInfo {
+ public:
+ static dom_distiller::proto::PaginationInfo ReadFromValue(const base::Value* json) {
+ dom_distiller::proto::PaginationInfo 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_next_page(field_value);
+ }
+ if (dict->HasKey("2")) {
+ std::string field_value;
+ if (!dict->GetString("2", &field_value)) {
+ goto error;
+ }
+ message.set_prev_page(field_value);
+ }
+ if (dict->HasKey("3")) {
+ std::string field_value;
+ if (!dict->GetString("3", &field_value)) {
+ goto error;
+ }
+ message.set_canonical_page(field_value);
+ }
+ return message;
+
+ error:
+ return dom_distiller::proto::PaginationInfo();
+ }
+
+ static scoped_ptr<base::Value> WriteToValue(const dom_distiller::proto::PaginationInfo& message) {
+ scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
+ if (message.has_next_page()) {
+ dict->SetString("1", message.next_page());
+ }
+ if (message.has_prev_page()) {
+ dict->SetString("2", message.prev_page());
+ }
+ if (message.has_canonical_page()) {
+ dict->SetString("3", message.canonical_page());
+ }
+ return dict.PassAs<base::Value>();
+ }
+ };
+
+ class DomDistillerResult {
+ public:
+ static dom_distiller::proto::DomDistillerResult ReadFromValue(const base::Value* json) {
+ dom_distiller::proto::DomDistillerResult 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_title(field_value);
+ }
+ if (dict->HasKey("2")) {
+ const base::Value* inner_message_value;
+ if (!dict->Get("2", &inner_message_value)) {
+ goto error;
+ }
+ *message.mutable_distilled_content() =
+ dom_distiller::proto::json::DistilledContent::ReadFromValue(inner_message_value);
+ }
+ if (dict->HasKey("3")) {
+ const base::Value* inner_message_value;
+ if (!dict->Get("3", &inner_message_value)) {
+ goto error;
+ }
+ *message.mutable_pagination_info() =
+ dom_distiller::proto::json::PaginationInfo::ReadFromValue(inner_message_value);
+ }
+ if (dict->HasKey("4")) {
+ const base::ListValue* field_list;
+ if (!dict->GetList("4", &field_list)) {
+ goto error;
+ }
+ for (size_t i = 0; i < field_list->GetSize(); ++i) {
+ std::string field_value;
+ if (!field_list->GetString(i, &field_value)) {
+ goto error;
+ }
+ message.add_image_urls(field_value);
+ }
+ }
+ return message;
+
+ error:
+ return dom_distiller::proto::DomDistillerResult();
+ }
+
+ static scoped_ptr<base::Value> WriteToValue(const dom_distiller::proto::DomDistillerResult& message) {
+ scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
+ if (message.has_title()) {
+ dict->SetString("1", message.title());
+ }
+ if (message.has_distilled_content()) {
+ scoped_ptr<base::Value> inner_message_value =
+ dom_distiller::proto::json::DistilledContent::WriteToValue(message.distilled_content());
+ dict->Set("2", inner_message_value.release());
+ }
+ if (message.has_pagination_info()) {
+ scoped_ptr<base::Value> inner_message_value =
+ dom_distiller::proto::json::PaginationInfo::WriteToValue(message.pagination_info());
+ dict->Set("3", inner_message_value.release());
+ }
+ base::ListValue* field_list = new base::ListValue();
+ dict->Set("4", field_list);
+ for (int i = 0; i < message.image_urls_size(); ++i) {
+ field_list->AppendString(message.image_urls(i));
+ }
+ return dict.PassAs<base::Value>();
+ }
+ };
+
+ class DomDistillerOptions {
+ public:
+ static dom_distiller::proto::DomDistillerOptions ReadFromValue(const base::Value* json) {
+ dom_distiller::proto::DomDistillerOptions message;
+ const base::DictionaryValue* dict;
+ if (!json->GetAsDictionary(&dict)) goto error;
+ return message;
+
+ error:
+ return dom_distiller::proto::DomDistillerOptions();
+ }
+
+ static scoped_ptr<base::Value> WriteToValue(const dom_distiller::proto::DomDistillerOptions& message) {
+ scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
+ return dict.PassAs<base::Value>();
+ }
+ };
+
+ }
+ }
+}
« no previous file with comments | « third_party/dom_distiller_js/package/proto/dom_distiller.proto ('k') | third_party/dom_distiller_js/update_domdistiller_js.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698