OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/protocol/devtools_protocol_client.h" | 5 #include "content/browser/devtools/protocol/devtools_protocol_client.h" |
6 | 6 |
7 namespace content { | 7 namespace content { |
8 | 8 |
9 DevToolsProtocolClient::DevToolsProtocolClient( | 9 DevToolsProtocolClient::DevToolsProtocolClient( |
10 const EventCallback& event_callback, | 10 const RawMessageCallback& raw_message_callback) |
11 const ResponseCallback& response_callback) | 11 : raw_message_callback_(raw_message_callback) { |
12 : event_callback_(event_callback), | |
13 response_callback_(response_callback) { | |
14 } | 12 } |
15 | 13 |
16 DevToolsProtocolClient::~DevToolsProtocolClient() { | 14 DevToolsProtocolClient::~DevToolsProtocolClient() { |
17 } | 15 } |
18 | 16 |
19 void DevToolsProtocolClient::SendNotification(const std::string& method, | 17 void DevToolsProtocolClient::SendNotification(const std::string& method, |
20 base::DictionaryValue* params) { | 18 base::DictionaryValue* params) { |
21 event_callback_.Run(method, params); | 19 scoped_refptr<DevToolsProtocol::Notification> notification = |
| 20 new DevToolsProtocol::Notification(method, params); |
| 21 SendRawMessage(notification->Serialize()); |
22 } | 22 } |
23 | 23 |
24 void DevToolsProtocolClient::SendAsyncResponse( | 24 void DevToolsProtocolClient::SendAsyncResponse( |
25 scoped_refptr<DevToolsProtocol::Response> response) { | 25 scoped_refptr<DevToolsProtocol::Response> response) { |
26 response_callback_.Run(response); | 26 SendRawMessage(response->Serialize()); |
| 27 } |
| 28 |
| 29 void DevToolsProtocolClient::SendRawMessage(const std::string& message) { |
| 30 raw_message_callback_.Run(message); |
27 } | 31 } |
28 | 32 |
29 void DevToolsProtocolClient::SendInvalidParamsResponse( | 33 void DevToolsProtocolClient::SendInvalidParamsResponse( |
30 scoped_refptr<DevToolsProtocol::Command> command, | 34 scoped_refptr<DevToolsProtocol::Command> command, |
31 const std::string& message) { | 35 const std::string& message) { |
32 SendAsyncResponse(command->InvalidParamResponse(message)); | 36 SendAsyncResponse(command->InvalidParamResponse(message)); |
33 } | 37 } |
34 | 38 |
35 void DevToolsProtocolClient::SendInternalErrorResponse( | 39 void DevToolsProtocolClient::SendInternalErrorResponse( |
36 scoped_refptr<DevToolsProtocol::Command> command, | 40 scoped_refptr<DevToolsProtocol::Command> command, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 } | 88 } |
85 | 89 |
86 const std::string& Response::message() const { | 90 const std::string& Response::message() const { |
87 return message_; | 91 return message_; |
88 } | 92 } |
89 | 93 |
90 Response::Response() { | 94 Response::Response() { |
91 } | 95 } |
92 | 96 |
93 } // namespace content | 97 } // namespace content |
OLD | NEW |