OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/devtools/devtools_protocol.h" | 5 #include "content/browser/devtools/devtools_protocol.h" |
6 | 6 |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 | 10 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 171 |
172 scoped_refptr<DevToolsProtocol::Response> | 172 scoped_refptr<DevToolsProtocol::Response> |
173 DevToolsProtocol::Handler::HandleCommand( | 173 DevToolsProtocol::Handler::HandleCommand( |
174 scoped_refptr<DevToolsProtocol::Command> command) { | 174 scoped_refptr<DevToolsProtocol::Command> command) { |
175 CommandHandlers::iterator it = command_handlers_.find(command->method()); | 175 CommandHandlers::iterator it = command_handlers_.find(command->method()); |
176 if (it == command_handlers_.end()) | 176 if (it == command_handlers_.end()) |
177 return NULL; | 177 return NULL; |
178 return (it->second).Run(command); | 178 return (it->second).Run(command); |
179 } | 179 } |
180 | 180 |
181 void DevToolsProtocol::Handler::HandleNotification( | |
182 scoped_refptr<DevToolsProtocol::Notification> notification) { | |
183 NotificationHandlers::iterator it = | |
184 notification_handlers_.find(notification->method()); | |
185 if (it == notification_handlers_.end()) | |
186 return; | |
187 (it->second).Run(notification); | |
188 } | |
189 | |
190 void DevToolsProtocol::Handler::SetNotifier(const Notifier& notifier) { | 181 void DevToolsProtocol::Handler::SetNotifier(const Notifier& notifier) { |
191 notifier_ = notifier; | 182 notifier_ = notifier; |
192 } | 183 } |
193 | 184 |
194 DevToolsProtocol::Handler::Handler() { | 185 DevToolsProtocol::Handler::Handler() { |
195 } | 186 } |
196 | 187 |
197 void DevToolsProtocol::Handler::RegisterCommandHandler( | 188 void DevToolsProtocol::Handler::RegisterCommandHandler( |
198 const std::string& command, | 189 const std::string& command, |
199 const CommandHandler& handler) { | 190 const CommandHandler& handler) { |
200 command_handlers_[command] = handler; | 191 command_handlers_[command] = handler; |
201 } | 192 } |
202 | 193 |
203 void DevToolsProtocol::Handler::RegisterNotificationHandler( | |
204 const std::string& notification, | |
205 const NotificationHandler& handler) { | |
206 notification_handlers_[notification] = handler; | |
207 } | |
208 | |
209 void DevToolsProtocol::Handler::SendNotification( | 194 void DevToolsProtocol::Handler::SendNotification( |
210 const std::string& method, | 195 const std::string& method, |
211 base::DictionaryValue* params) { | 196 base::DictionaryValue* params) { |
212 scoped_refptr<DevToolsProtocol::Notification> notification = | 197 scoped_refptr<DevToolsProtocol::Notification> notification = |
213 new DevToolsProtocol::Notification(method, params); | 198 new DevToolsProtocol::Notification(method, params); |
214 SendRawMessage(notification->Serialize()); | 199 SendRawMessage(notification->Serialize()); |
215 } | 200 } |
216 | 201 |
217 void DevToolsProtocol::Handler::SendAsyncResponse( | 202 void DevToolsProtocol::Handler::SendAsyncResponse( |
218 scoped_refptr<DevToolsProtocol::Response> response) { | 203 scoped_refptr<DevToolsProtocol::Response> response) { |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 new Response(0, kErrorParseError, error_message); | 322 new Response(0, kErrorParseError, error_message); |
338 if (error_response) | 323 if (error_response) |
339 *error_response = response->Serialize(); | 324 *error_response = response->Serialize(); |
340 return NULL; | 325 return NULL; |
341 } | 326 } |
342 | 327 |
343 return static_cast<base::DictionaryValue*>(message.release()); | 328 return static_cast<base::DictionaryValue*>(message.release()); |
344 } | 329 } |
345 | 330 |
346 } // namespace content | 331 } // namespace content |
OLD | NEW |