| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 67 |
| 68 template<> | 68 template<> |
| 69 base::Value* CreateValue(const std::string& param); | 69 base::Value* CreateValue(const std::string& param); |
| 70 | 70 |
| 71 ${types}\ | 71 ${types}\ |
| 72 | 72 |
| 73 } // namespace devtools | 73 } // namespace devtools |
| 74 | 74 |
| 75 class DevToolsProtocolDispatcher { | 75 class DevToolsProtocolDispatcher { |
| 76 public: | 76 public: |
| 77 using Notifier = DevToolsProtocolClient::RawMessageCallback; | |
| 78 using CommandHandler = | 77 using CommandHandler = |
| 79 base::Callback<bool(int, scoped_ptr<base::DictionaryValue>)>; | 78 base::Callback<bool(DevToolsCommandId, |
| 79 scoped_ptr<base::DictionaryValue>)>; |
| 80 | 80 |
| 81 explicit DevToolsProtocolDispatcher(const Notifier& notifier); | 81 explicit DevToolsProtocolDispatcher(DevToolsProtocolDelegate* notifier); |
| 82 ~DevToolsProtocolDispatcher(); | 82 ~DevToolsProtocolDispatcher(); |
| 83 | 83 |
| 84 CommandHandler FindCommandHandler(const std::string& method); | 84 CommandHandler FindCommandHandler(const std::string& method); |
| 85 | 85 |
| 86 ${setters}\ | 86 ${setters}\ |
| 87 | 87 |
| 88 private: | 88 private: |
| 89 using Response = DevToolsProtocolClient::Response; | 89 using Response = DevToolsProtocolClient::Response; |
| 90 using CommandHandlers = std::map<std::string, CommandHandler>; | 90 using CommandHandlers = std::map<std::string, CommandHandler>; |
| 91 | 91 |
| 92 ${methods}\ | 92 ${methods}\ |
| 93 | 93 |
| 94 Notifier notifier_; | 94 DevToolsProtocolDelegate* notifier_; |
| 95 DevToolsProtocolClient client_; | 95 DevToolsProtocolClient client_; |
| 96 CommandHandlers command_handlers_; | 96 CommandHandlers command_handlers_; |
| 97 ${fields}\ | 97 ${fields}\ |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 } // namespace content | 100 } // namespace content |
| 101 | 101 |
| 102 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_DEVTOOLS_PROTOCOL_DISPATCHER_H_ | 102 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_DEVTOOLS_PROTOCOL_DISPATCHER_H_ |
| 103 """) | 103 """) |
| 104 | 104 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 tmpl_handler = string.Template("""\ | 201 tmpl_handler = string.Template("""\ |
| 202 namespace ${domain} { | 202 namespace ${domain} { |
| 203 class ${Domain}Handler; | 203 class ${Domain}Handler; |
| 204 } // namespace domain | 204 } // namespace domain |
| 205 """) | 205 """) |
| 206 | 206 |
| 207 tmpl_client = string.Template("""\ | 207 tmpl_client = string.Template("""\ |
| 208 namespace ${domain} { | 208 namespace ${domain} { |
| 209 class Client : public DevToolsProtocolClient { | 209 class Client : public DevToolsProtocolClient { |
| 210 public: | 210 public: |
| 211 explicit Client(const RawMessageCallback& raw_message_callback); | 211 explicit Client(DevToolsProtocolDelegate* notifier); |
| 212 ~Client() override; | 212 ~Client() override; |
| 213 | 213 |
| 214 ${methods}\ | 214 ${methods}\ |
| 215 }; | 215 }; |
| 216 } // namespace ${domain} | 216 } // namespace ${domain} |
| 217 """) | 217 """) |
| 218 | 218 |
| 219 tmpl_event = string.Template("""\ | 219 tmpl_event = string.Template("""\ |
| 220 void ${Command}( | 220 void ${Command}( |
| 221 scoped_refptr<${Command}Params> params); | 221 scoped_refptr<${Command}Params> params); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 245 template_cc = string.Template(header + """\ | 245 template_cc = string.Template(header + """\ |
| 246 | 246 |
| 247 #include "base/bind.h" | 247 #include "base/bind.h" |
| 248 #include "base/strings/string_number_conversions.h" | 248 #include "base/strings/string_number_conversions.h" |
| 249 #include "base/strings/string_split.h" | 249 #include "base/strings/string_split.h" |
| 250 ${includes}\ | 250 ${includes}\ |
| 251 | 251 |
| 252 namespace content { | 252 namespace content { |
| 253 | 253 |
| 254 DevToolsProtocolDispatcher::DevToolsProtocolDispatcher( | 254 DevToolsProtocolDispatcher::DevToolsProtocolDispatcher( |
| 255 const Notifier& notifier) | 255 DevToolsProtocolDelegate* notifier) |
| 256 : notifier_(notifier), | 256 : notifier_(notifier), |
| 257 client_(notifier), | 257 client_(notifier), |
| 258 ${fields_init} { | 258 ${fields_init} { |
| 259 } | 259 } |
| 260 | 260 |
| 261 DevToolsProtocolDispatcher::~DevToolsProtocolDispatcher() { | 261 DevToolsProtocolDispatcher::~DevToolsProtocolDispatcher() { |
| 262 } | 262 } |
| 263 | 263 |
| 264 DevToolsProtocolDispatcher::CommandHandler | 264 DevToolsProtocolDispatcher::CommandHandler |
| 265 DevToolsProtocolDispatcher::FindCommandHandler(const std::string& method) { | 265 DevToolsProtocolDispatcher::FindCommandHandler(const std::string& method) { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 | 398 |
| 399 tmpl_arg_opt = string.Template( | 399 tmpl_arg_opt = string.Template( |
| 400 "${param}_found ? ${param_pass} : nullptr") | 400 "${param}_found ? ${param_pass} : nullptr") |
| 401 | 401 |
| 402 tmpl_object_pass = string.Template( | 402 tmpl_object_pass = string.Template( |
| 403 "make_scoped_ptr<base::DictionaryValue>(${name}->DeepCopy())") | 403 "make_scoped_ptr<base::DictionaryValue>(${name}->DeepCopy())") |
| 404 | 404 |
| 405 tmpl_client_impl = string.Template("""\ | 405 tmpl_client_impl = string.Template("""\ |
| 406 namespace ${domain} { | 406 namespace ${domain} { |
| 407 | 407 |
| 408 Client::Client(const RawMessageCallback& raw_message_callback) | 408 Client::Client(DevToolsProtocolDelegate* notifier) |
| 409 : DevToolsProtocolClient(raw_message_callback) { | 409 : DevToolsProtocolClient(notifier) { |
| 410 } | 410 } |
| 411 | 411 |
| 412 Client::~Client() { | 412 Client::~Client() { |
| 413 } | 413 } |
| 414 | 414 |
| 415 ${methods}\ | 415 ${methods}\ |
| 416 | 416 |
| 417 } // namespace ${domain} | 417 } // namespace ${domain} |
| 418 """) | 418 """) |
| 419 | 419 |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 output_h_file.close() | 794 output_h_file.close() |
| 795 | 795 |
| 796 output_cc_file.write(template_cc.substitute({}, | 796 output_cc_file.write(template_cc.substitute({}, |
| 797 major = blink_protocol["version"]["major"], | 797 major = blink_protocol["version"]["major"], |
| 798 minor = blink_protocol["version"]["minor"], | 798 minor = blink_protocol["version"]["minor"], |
| 799 includes = "".join(sorted(includes)), | 799 includes = "".join(sorted(includes)), |
| 800 fields_init = ",\n ".join(fields_init), | 800 fields_init = ",\n ".join(fields_init), |
| 801 methods = "\n".join(handler_method_impls), | 801 methods = "\n".join(handler_method_impls), |
| 802 types = "\n".join(type_impls))) | 802 types = "\n".join(type_impls))) |
| 803 output_cc_file.close() | 803 output_cc_file.close() |
| OLD | NEW |