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

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: rebase 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 EventCallback& event_callback,
124 const ResponseCallback& response_callback); 124 const ResponseCallback& response_callback,
125 const RawMessageCallback& raw_message_callback);
125 virtual ~Client(); 126 virtual ~Client();
126 127
127 ${methods}\ 128 ${methods}\
128 }; 129 };
129 } // namespace ${domain} 130 } // namespace ${domain}
130 """) 131 """)
131 132
132 tmpl_event = string.Template("""\ 133 tmpl_event = string.Template("""\
133 void ${Command}( 134 void ${Command}(
134 const ${Command}Params& params); 135 const ${Command}Params& params);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 &DevToolsProtocolHandlerImpl::On${Domain}${Command}, 243 &DevToolsProtocolHandlerImpl::On${Domain}${Command},
243 base::Unretained(this))); 244 base::Unretained(this)));
244 """) 245 """)
245 246
246 tmpl_init_client = string.Template("""\ 247 tmpl_init_client = string.Template("""\
247 ${domain}_handler_->SetClient(make_scoped_ptr( 248 ${domain}_handler_->SetClient(make_scoped_ptr(
248 new devtools::${domain}::Client( 249 new devtools::${domain}::Client(
249 base::Bind(&DevToolsProtocolHandlerImpl::SendNotification, 250 base::Bind(&DevToolsProtocolHandlerImpl::SendNotification,
250 base::Unretained(this)), 251 base::Unretained(this)),
251 base::Bind(&DevToolsProtocolHandlerImpl::SendAsyncResponse, 252 base::Bind(&DevToolsProtocolHandlerImpl::SendAsyncResponse,
253 base::Unretained(this)),
254 base::Bind(&DevToolsProtocolHandlerImpl::SendRawMessage,
252 base::Unretained(this))))); 255 base::Unretained(this)))));
253 """) 256 """)
254 257
255 tmpl_callback_impl = string.Template("""\ 258 tmpl_callback_impl = string.Template("""\
256 scoped_refptr<DevToolsProtocol::Response> 259 scoped_refptr<DevToolsProtocol::Response>
257 DevToolsProtocolHandlerImpl::On${Domain}${Command}( 260 DevToolsProtocolHandlerImpl::On${Domain}${Command}(
258 scoped_refptr<DevToolsProtocol::Command> command) { 261 scoped_refptr<DevToolsProtocol::Command> command) {
259 ${prep}\ 262 ${prep}\
260 Response response = ${domain}_handler_->${Command}(${args}); 263 Response response = ${domain}_handler_->${Command}(${args});
261 scoped_refptr<DevToolsProtocol::Response> protocol_response; 264 scoped_refptr<DevToolsProtocol::Response> protocol_response;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 ${pass_type} ${param}) { 355 ${pass_type} ${param}) {
353 ${param}_ = ${param}; 356 ${param}_ = ${param};
354 has_${param}_ = true; 357 has_${param}_ = true;
355 } 358 }
356 """) 359 """)
357 360
358 tmpl_client_impl = string.Template("""\ 361 tmpl_client_impl = string.Template("""\
359 namespace ${domain} { 362 namespace ${domain} {
360 363
361 Client::Client(const EventCallback& event_callback, 364 Client::Client(const EventCallback& event_callback,
362 const ResponseCallback& response_callback) 365 const ResponseCallback& response_callback,
363 : DevToolsProtocolClient(event_callback, response_callback) { 366 const RawMessageCallback& raw_message_callback)
367 : DevToolsProtocolClient(
368 event_callback, response_callback, raw_message_callback) {
364 } 369 }
365 370
366 Client::~Client() { 371 Client::~Client() {
367 } 372 }
368 373
369 ${methods}\ 374 ${methods}\
370 375
371 } // namespace ${domain} 376 } // namespace ${domain}
372 """) 377 """)
373 378
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 methods = "".join(handler_methods), 773 methods = "".join(handler_methods),
769 fields = "".join(fields))) 774 fields = "".join(fields)))
770 output_h_file.close() 775 output_h_file.close()
771 776
772 output_cc_file.write(template_cc.substitute({}, 777 output_cc_file.write(template_cc.substitute({},
773 includes = "".join(sorted(includes)), 778 includes = "".join(sorted(includes)),
774 fields_init = ",\n ".join(fields_init), 779 fields_init = ",\n ".join(fields_init),
775 methods = "\n".join(handler_method_impls), 780 methods = "\n".join(handler_method_impls),
776 types = "\n".join(type_impls))) 781 types = "\n".join(type_impls)))
777 output_cc_file.close() 782 output_cc_file.close()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698