Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 blink_protocol_path = sys.argv[1] | 10 blink_protocol_path = sys.argv[1] |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 // content/public/browser/devtools_protocol_handler_generator.py from | 22 // content/public/browser/devtools_protocol_handler_generator.py from |
| 23 // third_party/WebKit/Source/devtools/protocol.json and | 23 // third_party/WebKit/Source/devtools/protocol.json and |
| 24 // content/browser/devtools/browser_protocol.json | 24 // content/browser/devtools/browser_protocol.json |
| 25 """ | 25 """ |
| 26 | 26 |
| 27 template_h = string.Template(header + """\ | 27 template_h = string.Template(header + """\ |
| 28 | 28 |
| 29 #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_DEVTOOLS_PROTOCOL_DISPATCHER_H_ | 29 #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_DEVTOOLS_PROTOCOL_DISPATCHER_H_ |
| 30 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_DEVTOOLS_PROTOCOL_DISPATCHER_H_ | 30 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_DEVTOOLS_PROTOCOL_DISPATCHER_H_ |
| 31 | 31 |
| 32 #include <utility> | |
| 33 | |
| 32 #include "content/browser/devtools/protocol/devtools_protocol_client.h" | 34 #include "content/browser/devtools/protocol/devtools_protocol_client.h" |
| 33 | 35 |
| 34 namespace content { | 36 namespace content { |
| 35 | 37 |
| 36 class DevToolsProtocolDispatcher; | 38 class DevToolsProtocolDispatcher; |
| 37 | 39 |
| 38 namespace devtools { | 40 namespace devtools { |
| 39 | 41 |
| 40 extern const char kProtocolVersion[]; | 42 extern const char kProtocolVersion[]; |
| 41 | 43 |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 327 scoped_ptr<base::DictionaryValue> params) { | 329 scoped_ptr<base::DictionaryValue> params) { |
| 328 ${prep}\ | 330 ${prep}\ |
| 329 Response response = ${domain}_handler_->${Command}(${args}); | 331 Response response = ${domain}_handler_->${Command}(${args}); |
| 330 scoped_ptr<base::DictionaryValue> protocol_response; | 332 scoped_ptr<base::DictionaryValue> protocol_response; |
| 331 if (client_.SendError(command_id, response)) | 333 if (client_.SendError(command_id, response)) |
| 332 return true; | 334 return true; |
| 333 if (response.IsFallThrough()) | 335 if (response.IsFallThrough()) |
| 334 return false; | 336 return false; |
| 335 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue()); | 337 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue()); |
| 336 ${wrap}\ | 338 ${wrap}\ |
| 337 client_.SendSuccess(command_id, result.Pass()); | 339 client_.SendSuccess(command_id, std::move(result)); |
| 338 return true; | 340 return true; |
| 339 } | 341 } |
| 340 """) | 342 """) |
| 341 | 343 |
| 342 tmpl_wrap = string.Template("""\ | 344 tmpl_wrap = string.Template("""\ |
| 343 result->Set("${proto_param}", devtools::CreateValue(out_${param})); | 345 result->Set("${proto_param}", devtools::CreateValue(out_${param})); |
| 344 """) | 346 """) |
| 345 | 347 |
| 346 tmpl_callback_async_impl = string.Template("""\ | 348 tmpl_callback_async_impl = string.Template("""\ |
| 347 bool DevToolsProtocolDispatcher::On${Domain}${Command}( | 349 bool DevToolsProtocolDispatcher::On${Domain}${Command}( |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 414 | 416 |
| 415 ${methods}\ | 417 ${methods}\ |
| 416 | 418 |
| 417 } // namespace ${domain} | 419 } // namespace ${domain} |
| 418 """) | 420 """) |
| 419 | 421 |
| 420 tmpl_event_impl = string.Template("""\ | 422 tmpl_event_impl = string.Template("""\ |
| 421 void Client::${Command}( | 423 void Client::${Command}( |
| 422 scoped_refptr<${Command}Params> params) { | 424 scoped_refptr<${Command}Params> params) { |
| 423 SendNotification("${Domain}.${command}", | 425 SendNotification("${Domain}.${command}", |
| 424 params->ToValue().Pass()); | 426 params->ToValue()); |
|
Avi (use Gerrit)
2015/12/28 15:00:22
wrap back to previous line?
| |
| 425 } | 427 } |
| 426 """) | 428 """) |
| 427 | 429 |
| 428 tmpl_response_impl = string.Template("""\ | 430 tmpl_response_impl = string.Template("""\ |
| 429 void Client::Send${Command}Response( | 431 void Client::Send${Command}Response( |
| 430 DevToolsCommandId command_id, | 432 DevToolsCommandId command_id, |
| 431 scoped_refptr<${Command}Response> params) { | 433 scoped_refptr<${Command}Response> params) { |
| 432 SendSuccess(command_id, params->ToValue().Pass()); | 434 SendSuccess(command_id, params->ToValue()); |
| 433 } | 435 } |
| 434 """) | 436 """) |
| 435 | 437 |
| 436 tmpl_typename = string.Template("devtools::${domain}::${declared_name}") | 438 tmpl_typename = string.Template("devtools::${domain}::${declared_name}") |
| 437 | 439 |
| 438 def Capitalize(s): | 440 def Capitalize(s): |
| 439 return s[:1].upper() + s[1:] | 441 return s[:1].upper() + s[1:] |
| 440 | 442 |
| 441 def Uncamelcase(s): | 443 def Uncamelcase(s): |
| 442 result = "" | 444 result = "" |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 794 output_h_file.close() | 796 output_h_file.close() |
| 795 | 797 |
| 796 output_cc_file.write(template_cc.substitute({}, | 798 output_cc_file.write(template_cc.substitute({}, |
| 797 major = blink_protocol["version"]["major"], | 799 major = blink_protocol["version"]["major"], |
| 798 minor = blink_protocol["version"]["minor"], | 800 minor = blink_protocol["version"]["minor"], |
| 799 includes = "".join(sorted(includes)), | 801 includes = "".join(sorted(includes)), |
| 800 fields_init = ",\n ".join(fields_init), | 802 fields_init = ",\n ".join(fields_init), |
| 801 methods = "\n".join(handler_method_impls), | 803 methods = "\n".join(handler_method_impls), |
| 802 types = "\n".join(type_impls))) | 804 types = "\n".join(type_impls))) |
| 803 output_cc_file.close() | 805 output_cc_file.close() |
| OLD | NEW |