Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(557)

Side by Side Diff: content/browser/devtools/devtools_protocol.h

Issue 12218134: Introduce intercepting and handling devtools messages in the renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <string> 9 #include <string>
10
9 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/callback.h"
10 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
11 #include "base/values.h" 14 #include "base/values.h"
12 15
13 namespace content { 16 namespace content {
14 17
15 // Utility classes for processing DevTools remote debugging messages. 18 // Utility classes for processing DevTools remote debugging messages.
16 // https://developers.google.com/chrome-developer-tools/docs/debugger-protocol 19 // https://developers.google.com/chrome-developer-tools/docs/debugger-protocol
17 class DevToolsProtocol { 20 class DevToolsProtocol {
18 public: 21 public:
22 typedef base::Callback<void(const std::string& message)> Notifier;
23
19 // JSON RPC 2.0 spec: http://www.jsonrpc.org/specification#error_object 24 // JSON RPC 2.0 spec: http://www.jsonrpc.org/specification#error_object
20 enum Error { 25 enum Error {
21 kErrorParseError = -32700, 26 kErrorParseError = -32700,
22 kErrorInvalidRequest = -32600, 27 kErrorInvalidRequest = -32600,
23 kErrorNoSuchMethod = -32601, 28 kErrorNoSuchMethod = -32601,
24 kErrorInvalidParams = -32602, 29 kErrorInvalidParams = -32602,
25 kErrorInternalError = -32603 30 kErrorInternalError = -32603
26 }; 31 };
27 32
28 class Response; 33 class Response;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 93
89 std::string Serialize(); 94 std::string Serialize();
90 95
91 private: 96 private:
92 std::string method_; 97 std::string method_;
93 scoped_ptr<base::DictionaryValue> params_; 98 scoped_ptr<base::DictionaryValue> params_;
94 99
95 DISALLOW_COPY_AND_ASSIGN(Notification); 100 DISALLOW_COPY_AND_ASSIGN(Notification);
96 }; 101 };
97 102
103 class Handler {
104 public:
105 typedef base::Callback<scoped_ptr<DevToolsProtocol::Response>(
106 DevToolsProtocol::Command* command)> CommandHandler;
107
108 virtual ~Handler();
109
110 virtual scoped_ptr<DevToolsProtocol::Response> HandleCommand(
111 DevToolsProtocol::Command* command);
112
113 protected:
114 Handler(const Notifier& notifier);
115
116 void RegisterCommandHandler(const std::string& command,
117 const CommandHandler& handler);
118
119 // Sends notification to the client. Takes ownership of |params|.
120 void SendNotification(const std::string& method,
121 base::DictionaryValue* params);
122
123 private:
124 typedef std::map<std::string, CommandHandler> CommandHandlers;
125
126 Notifier notifier_;
127 CommandHandlers command_handlers_;
128
129 DISALLOW_COPY_AND_ASSIGN(Handler);
130 };
131
98 static Command* ParseCommand(const std::string& json, 132 static Command* ParseCommand(const std::string& json,
99 std::string* error_response); 133 std::string* error_response);
100 134
101 private: 135 private:
102 DevToolsProtocol() {} 136 DevToolsProtocol() {}
103 ~DevToolsProtocol() {} 137 ~DevToolsProtocol() {}
104 }; 138 };
105 139
106 } // namespace content 140 } // namespace content
107 141
108 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_PROTOCOL_H_ 142 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_PROTOCOL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698