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

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

Issue 511873002: DevTools: use explicit IPC messages for enabling/disabling tracing instead of intercepting protocol… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 3 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
« no previous file with comments | « no previous file | content/browser/devtools/devtools_protocol.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <map>
9 #include <string> 9 #include <string>
10 10
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 Notification(const std::string& method, 120 Notification(const std::string& method,
121 base::DictionaryValue* params); 121 base::DictionaryValue* params);
122 122
123 DISALLOW_COPY_AND_ASSIGN(Notification); 123 DISALLOW_COPY_AND_ASSIGN(Notification);
124 }; 124 };
125 125
126 class CONTENT_EXPORT Handler { 126 class CONTENT_EXPORT Handler {
127 public: 127 public:
128 typedef base::Callback<scoped_refptr<DevToolsProtocol::Response>( 128 typedef base::Callback<scoped_refptr<DevToolsProtocol::Response>(
129 scoped_refptr<DevToolsProtocol::Command> command)> CommandHandler; 129 scoped_refptr<DevToolsProtocol::Command> command)> CommandHandler;
130 typedef base::Callback<void(
131 scoped_refptr<DevToolsProtocol::Notification> notification)>
132 NotificationHandler;
133 130
134 virtual ~Handler(); 131 virtual ~Handler();
135 132
136 virtual scoped_refptr<DevToolsProtocol::Response> HandleCommand( 133 virtual scoped_refptr<DevToolsProtocol::Response> HandleCommand(
137 scoped_refptr<DevToolsProtocol::Command> command); 134 scoped_refptr<DevToolsProtocol::Command> command);
138 135
139 virtual void HandleNotification(
140 scoped_refptr<DevToolsProtocol::Notification> notification);
141
142 void SetNotifier(const Notifier& notifier); 136 void SetNotifier(const Notifier& notifier);
143 137
144 protected: 138 protected:
145 Handler(); 139 Handler();
146 140
147 void RegisterCommandHandler(const std::string& command, 141 void RegisterCommandHandler(const std::string& command,
148 const CommandHandler& handler); 142 const CommandHandler& handler);
149 143
150 void RegisterNotificationHandler(const std::string& notification,
151 const NotificationHandler& handler);
152
153 // Sends notification to the client. Takes ownership of |params|. 144 // Sends notification to the client. Takes ownership of |params|.
154 void SendNotification(const std::string& method, 145 void SendNotification(const std::string& method,
155 base::DictionaryValue* params); 146 base::DictionaryValue* params);
156 147
157 void SendAsyncResponse(scoped_refptr<DevToolsProtocol::Response> response); 148 void SendAsyncResponse(scoped_refptr<DevToolsProtocol::Response> response);
158 149
159 // Sends message to client, the caller is presumed to properly 150 // Sends message to client, the caller is presumed to properly
160 // format the message. 151 // format the message.
161 void SendRawMessage(const std::string& message); 152 void SendRawMessage(const std::string& message);
162 153
163 private: 154 private:
164 typedef std::map<std::string, CommandHandler> CommandHandlers; 155 typedef std::map<std::string, CommandHandler> CommandHandlers;
165 typedef std::map<std::string, NotificationHandler> NotificationHandlers;
166 156
167 Notifier notifier_; 157 Notifier notifier_;
168 CommandHandlers command_handlers_; 158 CommandHandlers command_handlers_;
169 NotificationHandlers notification_handlers_;
170 159
171 DISALLOW_COPY_AND_ASSIGN(Handler); 160 DISALLOW_COPY_AND_ASSIGN(Handler);
172 }; 161 };
173 162
174 CONTENT_EXPORT static base::DictionaryValue* ParseMessage( 163 CONTENT_EXPORT static base::DictionaryValue* ParseMessage(
175 const std::string& json, 164 const std::string& json,
176 std::string* error_response); 165 std::string* error_response);
177 166
178 CONTENT_EXPORT static scoped_refptr<Command> ParseCommand( 167 CONTENT_EXPORT static scoped_refptr<Command> ParseCommand(
179 const std::string& json, 168 const std::string& json,
(...skipping 17 matching lines...) Expand all
197 static scoped_refptr<Notification> CreateNotification( 186 static scoped_refptr<Notification> CreateNotification(
198 const std::string& method, base::DictionaryValue* params); 187 const std::string& method, base::DictionaryValue* params);
199 188
200 DevToolsProtocol() {} 189 DevToolsProtocol() {}
201 ~DevToolsProtocol() {} 190 ~DevToolsProtocol() {}
202 }; 191 };
203 192
204 } // namespace content 193 } // namespace content
205 194
206 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_PROTOCOL_H_ 195 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_PROTOCOL_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/devtools/devtools_protocol.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698