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

Side by Side Diff: content/browser/devtools/protocol/devtools_protocol_handler_generator.py

Issue 635733003: [DevTools] Migrate DevToolsTracingHandler to generated handler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 6 years, 2 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 unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import sys 6 import sys
7 import string 7 import string
8 import json 8 import json
9 9
10 input_json_path = sys.argv[1] 10 input_json_path = sys.argv[1]
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 tmpl_handler = string.Template("""\ 113 tmpl_handler = string.Template("""\
114 namespace ${domain} { 114 namespace ${domain} {
115 class ${Domain}Handler; 115 class ${Domain}Handler;
116 } // namespace domain 116 } // namespace domain
117 """) 117 """)
118 118
119 tmpl_client = string.Template("""\ 119 tmpl_client = string.Template("""\
120 namespace ${domain} { 120 namespace ${domain} {
121 class Client : public DevToolsProtocolClient { 121 class Client : public DevToolsProtocolClient {
122 public: 122 public:
123 Client(const EventCallback& event_callback, 123 Client(const RawMessageCallback& raw_message_callback);
124 const ResponseCallback& response_callback);
125 virtual ~Client(); 124 virtual ~Client();
126 125
127 ${methods}\ 126 ${methods}\
128 }; 127 };
129 } // namespace ${domain} 128 } // namespace ${domain}
130 """) 129 """)
131 130
132 tmpl_event = string.Template("""\ 131 tmpl_event = string.Template("""\
133 void ${Command}( 132 void ${Command}(
134 const ${Command}Params& params); 133 const ${Command}Params& params);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 RegisterCommandHandler( 238 RegisterCommandHandler(
240 "${Domain}.${command}", 239 "${Domain}.${command}",
241 base::Bind( 240 base::Bind(
242 &DevToolsProtocolHandlerImpl::On${Domain}${Command}, 241 &DevToolsProtocolHandlerImpl::On${Domain}${Command},
243 base::Unretained(this))); 242 base::Unretained(this)));
244 """) 243 """)
245 244
246 tmpl_init_client = string.Template("""\ 245 tmpl_init_client = string.Template("""\
247 ${domain}_handler_->SetClient(make_scoped_ptr( 246 ${domain}_handler_->SetClient(make_scoped_ptr(
248 new devtools::${domain}::Client( 247 new devtools::${domain}::Client(
249 base::Bind(&DevToolsProtocolHandlerImpl::SendNotification, 248 base::Bind(&DevToolsProtocolHandlerImpl::SendRawMessage,
250 base::Unretained(this)),
251 base::Bind(&DevToolsProtocolHandlerImpl::SendAsyncResponse,
252 base::Unretained(this))))); 249 base::Unretained(this)))));
253 """) 250 """)
254 251
255 tmpl_callback_impl = string.Template("""\ 252 tmpl_callback_impl = string.Template("""\
256 scoped_refptr<DevToolsProtocol::Response> 253 scoped_refptr<DevToolsProtocol::Response>
257 DevToolsProtocolHandlerImpl::On${Domain}${Command}( 254 DevToolsProtocolHandlerImpl::On${Domain}${Command}(
258 scoped_refptr<DevToolsProtocol::Command> command) { 255 scoped_refptr<DevToolsProtocol::Command> command) {
259 ${prep}\ 256 ${prep}\
260 Response response = ${domain}_handler_->${Command}(${args}); 257 Response response = ${domain}_handler_->${Command}(${args});
261 scoped_refptr<DevToolsProtocol::Response> protocol_response; 258 scoped_refptr<DevToolsProtocol::Response> protocol_response;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 void ${declared_name}::set_${param}( 348 void ${declared_name}::set_${param}(
352 ${pass_type} ${param}) { 349 ${pass_type} ${param}) {
353 ${param}_ = ${param}; 350 ${param}_ = ${param};
354 has_${param}_ = true; 351 has_${param}_ = true;
355 } 352 }
356 """) 353 """)
357 354
358 tmpl_client_impl = string.Template("""\ 355 tmpl_client_impl = string.Template("""\
359 namespace ${domain} { 356 namespace ${domain} {
360 357
361 Client::Client(const EventCallback& event_callback, 358 Client::Client(const RawMessageCallback& raw_message_callback)
362 const ResponseCallback& response_callback) 359 : DevToolsProtocolClient(raw_message_callback) {
363 : DevToolsProtocolClient(event_callback, response_callback) {
364 } 360 }
365 361
366 Client::~Client() { 362 Client::~Client() {
367 } 363 }
368 364
369 ${methods}\ 365 ${methods}\
370 366
371 } // namespace ${domain} 367 } // namespace ${domain}
372 """) 368 """)
373 369
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 methods = "".join(handler_methods), 767 methods = "".join(handler_methods),
772 fields = "".join(fields))) 768 fields = "".join(fields)))
773 output_h_file.close() 769 output_h_file.close()
774 770
775 output_cc_file.write(template_cc.substitute({}, 771 output_cc_file.write(template_cc.substitute({},
776 includes = "".join(sorted(includes)), 772 includes = "".join(sorted(includes)),
777 fields_init = ",\n ".join(fields_init), 773 fields_init = ",\n ".join(fields_init),
778 methods = "\n".join(handler_method_impls), 774 methods = "\n".join(handler_method_impls),
779 types = "\n".join(type_impls))) 775 types = "\n".join(type_impls)))
780 output_cc_file.close() 776 output_cc_file.close()
OLDNEW
« no previous file with comments | « content/browser/devtools/protocol/devtools_protocol_client.cc ('k') | content/browser/devtools/protocol/tracing_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698