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