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

Unified Diff: chrome/browser/resources/ssl/tls_error_assistant/gen_tls_error_assistant_proto.py

Issue 2567483002: Add proto for TLS error assistant, refactor proto generator code. (Closed)
Patch Set: Created 4 years 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: chrome/browser/resources/ssl/tls_error_assistant/gen_tls_error_assistant_proto.py
diff --git a/chrome/browser/resources/ssl/tls_error_assistant/gen_tls_error_assistant_proto.py b/chrome/browser/resources/ssl/tls_error_assistant/gen_tls_error_assistant_proto.py
new file mode 100755
index 0000000000000000000000000000000000000000..f57a69b7acb35c5759d3d9e1d44f9b5b51a76b3f
--- /dev/null
+++ b/chrome/browser/resources/ssl/tls_error_assistant/gen_tls_error_assistant_proto.py
@@ -0,0 +1,40 @@
+#!/usr/bin/python
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""
+ Convert the ASCII tls_error_assistant.asciipb proto into a binary resource.
+"""
+
+import os
+import sys
+
+proto_generator_path = os.path.normpath(os.path.join(os.path.abspath(__file__),
Nathan Parker 2016/12/10 00:56:50 Add a comment describing this magic incantation
meacer 2016/12/13 02:30:16 Done.
+ *[os.path.pardir] * 6 + ['chrome/browser/resources/protobufs']))
+sys.path.insert(0, proto_generator_path)
+from binary_proto_generator import BinaryProtoGenerator
+
+
+class TLSErrorAssistantProtoGenerator(BinaryProtoGenerator):
+ def ImportProtoModule(self):
+ import tls_error_assistant_pb2
+ globals()['tls_error_assistant_pb2'] = tls_error_assistant_pb2
+
+ def EmptyProtoInstance(self):
+ return tls_error_assistant_pb2.TLSErrorAssistantConfig()
+
+ def ValidatePb(self, opts, pb):
+ assert pb.version_id > 0;
Nathan Parker 2016/12/10 00:56:50 How about verifying that there's at least one entr
meacer 2016/12/13 02:30:16 Done.
+
+ def ProcessPb(self, opts, pb):
+ binary_pb_str = pb.SerializeToString()
+ outfile = os.path.join(opts.outdir, opts.outbasename)
+ open(outfile, 'wb').write(binary_pb_str)
+
+
+def main():
+ return TLSErrorAssistantProtoGenerator().Run()
+
+if __name__ == '__main__':
+ sys.exit(main())

Powered by Google App Engine
This is Rietveld 408576698