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