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 #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_DEVTOOLS_PROTOCOL_CLIENT_H_ | 5 #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_DEVTOOLS_PROTOCOL_CLIENT_H_ |
6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_DEVTOOLS_PROTOCOL_CLIENT_H_ | 6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_DEVTOOLS_PROTOCOL_CLIENT_H_ |
7 | 7 |
8 #include "content/browser/devtools/devtools_protocol.h" | 8 #include "content/browser/devtools/devtools_protocol.h" |
9 | 9 |
10 namespace content { | 10 namespace content { |
11 | 11 |
12 class DevToolsProtocolClient { | 12 class DevToolsProtocolClient { |
13 public: | 13 public: |
14 typedef base::Callback<void(const std::string& message)> | 14 typedef base::Callback<void(const std::string& event, |
15 RawMessageCallback; | 15 base::DictionaryValue* params)> EventCallback; |
| 16 |
| 17 typedef base::Callback<void(scoped_refptr<DevToolsProtocol::Response>)> |
| 18 ResponseCallback; |
16 | 19 |
17 enum ResponseStatus { | 20 enum ResponseStatus { |
18 RESPONSE_STATUS_FALLTHROUGH, | 21 RESPONSE_STATUS_FALLTHROUGH, |
19 RESPONSE_STATUS_OK, | 22 RESPONSE_STATUS_OK, |
20 RESPONSE_STATUS_INVALID_PARAMS, | 23 RESPONSE_STATUS_INVALID_PARAMS, |
21 RESPONSE_STATUS_INTERNAL_ERROR, | 24 RESPONSE_STATUS_INTERNAL_ERROR, |
22 RESPONSE_STATUS_SERVER_ERROR, | 25 RESPONSE_STATUS_SERVER_ERROR, |
23 }; | 26 }; |
24 | 27 |
25 struct Response { | 28 struct Response { |
(...skipping 17 matching lines...) Expand all Loading... |
43 void SendInvalidParamsResponse( | 46 void SendInvalidParamsResponse( |
44 scoped_refptr<DevToolsProtocol::Command> command, | 47 scoped_refptr<DevToolsProtocol::Command> command, |
45 const std::string& message); | 48 const std::string& message); |
46 void SendInternalErrorResponse( | 49 void SendInternalErrorResponse( |
47 scoped_refptr<DevToolsProtocol::Command> command, | 50 scoped_refptr<DevToolsProtocol::Command> command, |
48 const std::string& message); | 51 const std::string& message); |
49 void SendServerErrorResponse( | 52 void SendServerErrorResponse( |
50 scoped_refptr<DevToolsProtocol::Command> command, | 53 scoped_refptr<DevToolsProtocol::Command> command, |
51 const std::string& message); | 54 const std::string& message); |
52 | 55 |
53 // Sends message to client, the caller is presumed to properly | |
54 // format the message. Do not use unless you must. | |
55 void SendRawMessage(const std::string& message); | |
56 | |
57 protected: | 56 protected: |
58 DevToolsProtocolClient(const RawMessageCallback& raw_message_callback); | 57 DevToolsProtocolClient(const EventCallback& event_callback, |
| 58 const ResponseCallback& response_callback); |
59 | 59 |
60 virtual ~DevToolsProtocolClient(); | 60 virtual ~DevToolsProtocolClient(); |
61 | 61 |
62 void SendNotification(const std::string& method, | 62 void SendNotification(const std::string& method, |
63 base::DictionaryValue* params); | 63 base::DictionaryValue* params); |
64 | 64 |
65 void SendAsyncResponse(scoped_refptr<DevToolsProtocol::Response> response); | 65 void SendAsyncResponse(scoped_refptr<DevToolsProtocol::Response> response); |
66 | 66 |
67 private: | 67 private: |
68 RawMessageCallback raw_message_callback_; | 68 EventCallback event_callback_; |
| 69 ResponseCallback response_callback_; |
69 | 70 |
70 DISALLOW_COPY_AND_ASSIGN(DevToolsProtocolClient); | 71 DISALLOW_COPY_AND_ASSIGN(DevToolsProtocolClient); |
71 }; | 72 }; |
72 | 73 |
73 } // namespace content | 74 } // namespace content |
74 | 75 |
75 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_DEVTOOLS_PROTOCOL_CLIENT_H_ | 76 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_DEVTOOLS_PROTOCOL_CLIENT_H_ |
OLD | NEW |