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 #ifndef CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_PROTOCOL_H_ | 5 #ifndef CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_PROTOCOL_H_ |
6 #define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_PROTOCOL_H_ | 6 #define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_PROTOCOL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "content/common/content_export.h" | |
16 | 17 |
17 namespace content { | 18 namespace content { |
18 | 19 |
19 // Utility classes for processing DevTools remote debugging messages. | 20 // Utility classes for processing DevTools remote debugging messages. |
20 // https://developers.google.com/chrome-developer-tools/docs/debugger-protocol | 21 // https://developers.google.com/chrome-developer-tools/docs/debugger-protocol |
21 class DevToolsProtocol { | 22 class DevToolsProtocol { |
22 public: | 23 public: |
23 typedef base::Callback<void(const std::string& message)> Notifier; | 24 typedef base::Callback<void(const std::string& message)> Notifier; |
24 | 25 |
25 class Response; | 26 class Response; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 friend class DevToolsProtocol; | 113 friend class DevToolsProtocol; |
113 virtual ~Notification(); | 114 virtual ~Notification(); |
114 | 115 |
115 // Takes ownership of |params|. | 116 // Takes ownership of |params|. |
116 Notification(const std::string& method, | 117 Notification(const std::string& method, |
117 base::DictionaryValue* params); | 118 base::DictionaryValue* params); |
118 | 119 |
119 DISALLOW_COPY_AND_ASSIGN(Notification); | 120 DISALLOW_COPY_AND_ASSIGN(Notification); |
120 }; | 121 }; |
121 | 122 |
122 class Handler { | 123 class CONTENT_EXPORT Handler { |
Vladislav Kaznacheev
2013/08/28 10:46:14
Why is this necessary? For tests?
SeRya
2013/08/29 14:24:16
Yes, otherwise content_browsertests fails to build
| |
123 public: | 124 public: |
124 typedef base::Callback<scoped_refptr<DevToolsProtocol::Response>( | 125 typedef base::Callback<scoped_refptr<DevToolsProtocol::Response>( |
125 scoped_refptr<DevToolsProtocol::Command> command)> CommandHandler; | 126 scoped_refptr<DevToolsProtocol::Command> command)> CommandHandler; |
126 | 127 |
127 virtual ~Handler(); | 128 virtual ~Handler(); |
128 | 129 |
129 virtual scoped_refptr<DevToolsProtocol::Response> HandleCommand( | 130 virtual scoped_refptr<DevToolsProtocol::Response> HandleCommand( |
130 scoped_refptr<DevToolsProtocol::Command> command); | 131 scoped_refptr<DevToolsProtocol::Command> command); |
131 | 132 |
132 void SetNotifier(const Notifier& notifier); | 133 void SetNotifier(const Notifier& notifier); |
(...skipping 16 matching lines...) Expand all Loading... | |
149 | 150 |
150 private: | 151 private: |
151 typedef std::map<std::string, CommandHandler> CommandHandlers; | 152 typedef std::map<std::string, CommandHandler> CommandHandlers; |
152 | 153 |
153 Notifier notifier_; | 154 Notifier notifier_; |
154 CommandHandlers command_handlers_; | 155 CommandHandlers command_handlers_; |
155 | 156 |
156 DISALLOW_COPY_AND_ASSIGN(Handler); | 157 DISALLOW_COPY_AND_ASSIGN(Handler); |
157 }; | 158 }; |
158 | 159 |
159 static scoped_refptr<Command> ParseCommand(const std::string& json, | 160 CONTENT_EXPORT static scoped_refptr<Command> ParseCommand( |
160 std::string* error_response); | 161 const std::string& json, |
162 std::string* error_response); | |
161 | 163 |
162 static scoped_refptr<Notification> ParseNotification( | 164 static scoped_refptr<Notification> ParseNotification( |
163 const std::string& json); | 165 const std::string& json); |
164 | 166 |
165 static scoped_refptr<Notification> CreateNotification( | 167 static scoped_refptr<Notification> CreateNotification( |
166 const std::string& method, base::DictionaryValue* params); | 168 const std::string& method, base::DictionaryValue* params); |
167 | 169 |
168 private: | 170 private: |
169 static base::DictionaryValue* ParseMessage(const std::string& json, | 171 static base::DictionaryValue* ParseMessage(const std::string& json, |
170 std::string* error_response); | 172 std::string* error_response); |
171 | 173 |
172 DevToolsProtocol() {} | 174 DevToolsProtocol() {} |
173 ~DevToolsProtocol() {} | 175 ~DevToolsProtocol() {} |
174 }; | 176 }; |
175 | 177 |
176 } // namespace content | 178 } // namespace content |
177 | 179 |
178 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_PROTOCOL_H_ | 180 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_PROTOCOL_H_ |
OLD | NEW |