OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // This file declares the DebuggerRemoteServiceCommand struct and the | 5 // This file declares the DebuggerRemoteServiceCommand struct and the |
6 // DebuggerRemoteService class which handles commands directed to the | 6 // DebuggerRemoteService class which handles commands directed to the |
7 // "V8Debugger" tool. | 7 // "V8Debugger" tool. |
8 #ifndef CONTENT_BROWSER_DEBUGGER_DEBUGGER_REMOTE_SERVICE_H_ | 8 #ifndef CONTENT_BROWSER_DEBUGGER_DEBUGGER_REMOTE_SERVICE_H_ |
9 #define CONTENT_BROWSER_DEBUGGER_DEBUGGER_REMOTE_SERVICE_H_ | 9 #define CONTENT_BROWSER_DEBUGGER_DEBUGGER_REMOTE_SERVICE_H_ |
10 #pragma once | 10 #pragma once |
11 | 11 |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
15 #include "content/browser/debugger/devtools_remote.h" | 15 #include "content/browser/debugger/devtools_remote.h" |
16 | 16 |
17 class DevToolsProtocolHandler; | 17 class DevToolsProtocolHandler; |
18 class DevToolsRemoteMessage; | 18 class DevToolsRemoteMessage; |
| 19 class TabContents; |
| 20 |
| 21 namespace base { |
19 class DictionaryValue; | 22 class DictionaryValue; |
20 class Value; | 23 class Value; |
21 class TabContents; | 24 } |
22 | 25 |
23 // Contains constants for DebuggerRemoteService tool protocol commands | 26 // Contains constants for DebuggerRemoteService tool protocol commands |
24 // (V8-related only). | 27 // (V8-related only). |
25 struct DebuggerRemoteServiceCommand { | 28 struct DebuggerRemoteServiceCommand { |
26 static const std::string kAttach; | 29 static const std::string kAttach; |
27 static const std::string kDetach; | 30 static const std::string kDetach; |
28 static const std::string kDebuggerCommand; | 31 static const std::string kDebuggerCommand; |
29 static const std::string kEvaluateJavascript; | 32 static const std::string kEvaluateJavascript; |
30 static const std::string kFrameNavigate; // navigation event | 33 static const std::string kFrameNavigate; // navigation event |
31 static const std::string kTabClosed; // tab closing event | 34 static const std::string kTabClosed; // tab closing event |
(...skipping 19 matching lines...) Expand all Loading... |
51 // Handles a tab closing event. | 54 // Handles a tab closing event. |
52 void TabClosed(int32 tab_uid); | 55 void TabClosed(int32 tab_uid); |
53 | 56 |
54 // Detaches the remote debugger from the tab specified by |destination|. | 57 // Detaches the remote debugger from the tab specified by |destination|. |
55 // It is public so that we can detach from the tab on the remote debugger | 58 // It is public so that we can detach from the tab on the remote debugger |
56 // connection loss. | 59 // connection loss. |
57 // If |response| is not NULL, the operation result will be written | 60 // If |response| is not NULL, the operation result will be written |
58 // as the "result" field in |response|, otherwise the result | 61 // as the "result" field in |response|, otherwise the result |
59 // will not be propagated back to the caller. | 62 // will not be propagated back to the caller. |
60 void DetachFromTab(const std::string& destination, | 63 void DetachFromTab(const std::string& destination, |
61 DictionaryValue* response); | 64 base::DictionaryValue* response); |
62 | 65 |
63 // DevToolsRemoteListener interface. | 66 // DevToolsRemoteListener interface. |
64 | 67 |
65 // Processes |message| from the remote debugger, where the tool is | 68 // Processes |message| from the remote debugger, where the tool is |
66 // "V8Debugger". Either sends the reply immediately or waits for an | 69 // "V8Debugger". Either sends the reply immediately or waits for an |
67 // asynchronous response from the V8 debugger. | 70 // asynchronous response from the V8 debugger. |
68 virtual void HandleMessage(const DevToolsRemoteMessage& message); | 71 virtual void HandleMessage(const DevToolsRemoteMessage& message); |
69 | 72 |
70 // Gets invoked on the remote debugger [socket] connection loss. | 73 // Gets invoked on the remote debugger [socket] connection loss. |
71 // Notifies the InspectableTabProxy of the remote debugger detachment. | 74 // Notifies the InspectableTabProxy of the remote debugger detachment. |
(...skipping 10 matching lines...) Expand all Loading... |
82 RESULT_UNKNOWN_TAB, | 85 RESULT_UNKNOWN_TAB, |
83 RESULT_DEBUGGER_ERROR, | 86 RESULT_DEBUGGER_ERROR, |
84 RESULT_UNKNOWN_COMMAND | 87 RESULT_UNKNOWN_COMMAND |
85 } Result; | 88 } Result; |
86 | 89 |
87 virtual ~DebuggerRemoteService(); | 90 virtual ~DebuggerRemoteService(); |
88 | 91 |
89 // Attaches a remote debugger to the tab specified by |destination|. | 92 // Attaches a remote debugger to the tab specified by |destination|. |
90 // Writes the attachment result (one of Result enum values) into |response|. | 93 // Writes the attachment result (one of Result enum values) into |response|. |
91 void AttachToTab(const std::string& destination, | 94 void AttachToTab(const std::string& destination, |
92 DictionaryValue* response); | 95 base::DictionaryValue* response); |
93 | 96 |
94 // Retrieves a WebContents instance for the specified |tab_uid| | 97 // Retrieves a WebContents instance for the specified |tab_uid| |
95 // or NULL if no such tab is found or no WebContents instance | 98 // or NULL if no such tab is found or no WebContents instance |
96 // corresponds to that tab. | 99 // corresponds to that tab. |
97 TabContents* ToTabContents(int32 tab_uid); | 100 TabContents* ToTabContents(int32 tab_uid); |
98 | 101 |
99 // Sends a JSON message with the |response| to the remote debugger. | 102 // Sends a JSON message with the |response| to the remote debugger. |
100 // |tool| and |destination| are used as the respective header values. | 103 // |tool| and |destination| are used as the respective header values. |
101 void SendResponse(const Value& response, | 104 void SendResponse(const base::Value& response, |
102 const std::string& tool, | 105 const std::string& tool, |
103 const std::string& destination); | 106 const std::string& destination); |
104 | 107 |
105 // Redirects a V8 debugger command from |content| to a V8 debugger associated | 108 // Redirects a V8 debugger command from |content| to a V8 debugger associated |
106 // with the |tab_uid| and writes the result into |response| if it becomes | 109 // with the |tab_uid| and writes the result into |response| if it becomes |
107 // known immediately. | 110 // known immediately. |
108 bool DispatchDebuggerCommand(int tab_uid, | 111 bool DispatchDebuggerCommand(int tab_uid, |
109 DictionaryValue* content, | 112 base::DictionaryValue* content, |
110 DictionaryValue* response); | 113 base::DictionaryValue* response); |
111 | 114 |
112 // Redirects a Javascript evaluation command from |content| to | 115 // Redirects a Javascript evaluation command from |content| to |
113 // a V8 debugger associated with the |tab_uid| and writes the result | 116 // a V8 debugger associated with the |tab_uid| and writes the result |
114 // into |response| if it becomes known immediately. | 117 // into |response| if it becomes known immediately. |
115 bool DispatchEvaluateJavascript(int tab_uid, | 118 bool DispatchEvaluateJavascript(int tab_uid, |
116 DictionaryValue* content, | 119 base::DictionaryValue* content, |
117 DictionaryValue* response); | 120 base::DictionaryValue* response); |
118 | 121 |
119 // The delegate is used to get an InspectableTabProxy instance. | 122 // The delegate is used to get an InspectableTabProxy instance. |
120 DevToolsProtocolHandler* delegate_; | 123 DevToolsProtocolHandler* delegate_; |
121 DISALLOW_COPY_AND_ASSIGN(DebuggerRemoteService); | 124 DISALLOW_COPY_AND_ASSIGN(DebuggerRemoteService); |
122 }; | 125 }; |
123 | 126 |
124 #endif // CONTENT_BROWSER_DEBUGGER_DEBUGGER_REMOTE_SERVICE_H_ | 127 #endif // CONTENT_BROWSER_DEBUGGER_DEBUGGER_REMOTE_SERVICE_H_ |
OLD | NEW |