summaryrefslogtreecommitdiffstats
path: root/chrome/browser/debugger/debugger_remote_service.h
diff options
context:
space:
mode:
authorapavlov@chromium.org <apavlov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-10 08:42:52 +0000
committerapavlov@chromium.org <apavlov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-10 08:42:52 +0000
commitc0f5a32c2e025e3a2801a254cfeef5987c96199f (patch)
tree5342d84dfd056f4296fa4952f7677fe5039b0398 /chrome/browser/debugger/debugger_remote_service.h
parent609eeec226e06466acb6ccc0ea5d59d453e6623e (diff)
downloadchromium_src-c0f5a32c2e025e3a2801a254cfeef5987c96199f.zip
chromium_src-c0f5a32c2e025e3a2801a254cfeef5987c96199f.tar.gz
chromium_src-c0f5a32c2e025e3a2801a254cfeef5987c96199f.tar.bz2
Review URL: http://codereview.chromium.org/93119
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15736 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/debugger/debugger_remote_service.h')
-rw-r--r--chrome/browser/debugger/debugger_remote_service.h81
1 files changed, 60 insertions, 21 deletions
diff --git a/chrome/browser/debugger/debugger_remote_service.h b/chrome/browser/debugger/debugger_remote_service.h
index 7b2b683..67342f4 100644
--- a/chrome/browser/debugger/debugger_remote_service.h
+++ b/chrome/browser/debugger/debugger_remote_service.h
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// This file declares the DebuggerRemoteServiceCommand struct and the
+// DebuggerRemoteService class which handles commands directed to the
+// "V8Debugger" tool.
#ifndef CHROME_BROWSER_DEBUGGER_DEBUGGER_REMOTE_SERVICE_H_
#define CHROME_BROWSER_DEBUGGER_DEBUGGER_REMOTE_SERVICE_H_
@@ -9,7 +12,6 @@
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
-#include "chrome/browser/debugger/devtools_protocol_handler.h"
#include "chrome/browser/debugger/devtools_remote.h"
class DevToolsProtocolHandler;
@@ -19,7 +21,7 @@ class Value;
class TabContents;
// Contains constants for DebuggerRemoteService tool protocol commands
-// (only V8-related).
+// (V8-related only).
struct DebuggerRemoteServiceCommand {
static const std::string kAttach;
static const std::string kDetach;
@@ -32,43 +34,80 @@ struct DebuggerRemoteServiceCommand {
// and proxies JSON messages from V8 debugger to the remote debugger.
class DebuggerRemoteService : public DevToolsRemoteListener {
public:
+ // |delegate| (never NULL) is the protocol handler instance
+ // which dispatches messages to this service. The responses from the
+ // V8 VM debugger are routed back to |delegate|.
+ // The ownership of |delegate| is NOT transferred to this class.
explicit DebuggerRemoteService(DevToolsProtocolHandler* delegate);
virtual ~DebuggerRemoteService();
// Handles a JSON message from the tab_id-associated V8 debugger.
void DebuggerOutput(int32 tab_id, const std::string& message);
- // Expose to public so that we can detach from tab
- // on remote debugger connection loss. If |response| is not NULL,
- // the operation result will be written as the "result" field in |response|,
- // otherwise it will not be propagated back to the caller.
- void DetachTab(const std::string& destination,
- DictionaryValue* response);
+ // Detaches the remote debugger from the tab specified by |destination|.
+ // It is public so that we can detach from the tab on the remote debugger
+ // connection loss.
+ // If |response| is not NULL, the operation result will be written
+ // as the "result" field in |response|, otherwise the result
+ // will not be propagated back to the caller.
+ void DetachFromTab(const std::string& destination,
+ DictionaryValue* response);
- // DevToolsRemoteListener interface
+ // DevToolsRemoteListener interface.
+
+ // Processes |message| from the remote debugger, where the tool is
+ // "V8Debugger". Either sends the reply immediately or waits for an
+ // asynchronous response from the V8 debugger.
virtual void HandleMessage(const DevToolsRemoteMessage& message);
+
+ // Gets invoked on the remote debugger [socket] connection loss.
+ // Notifies the InspectableTabProxy of the remote debugger detachment.
virtual void OnConnectionLost();
+ // Specifies a tool name ("V8Debugger") handled by this class.
static const std::string kToolName;
private:
// Operation result returned in the "result" field.
- struct Result {
- static const int kOk = 0;
- static const int kIllegalTabState = 1;
- static const int kUnknownTab = 2;
- static const int kDebuggerError = 3;
- static const int kUnknownCommand = 4;
- };
-
- void AttachTab(const std::string& destination,
- DictionaryValue* response);
+ typedef enum {
+ RESULT_OK = 0,
+ RESULT_ILLEGAL_TAB_STATE,
+ RESULT_UNKNOWN_TAB,
+ RESULT_DEBUGGER_ERROR,
+ RESULT_UNKNOWN_COMMAND
+ } Result;
+
+ // Attaches a remote debugger to the tab specified by |destination|.
+ // Writes the attachment result (one of Result enum values) into |response|.
+ void AttachToTab(const std::string& destination,
+ DictionaryValue* response);
+
+ // Retrieves a WebContents instance for the specified |tab_uid|
+ // or NULL if no such tab is found or no WebContents instance
+ // corresponds to that tab.
TabContents* ToTabContents(int32 tab_uid);
+
+ // Sends a JSON message with the |response| to the remote debugger.
+ // |tool| and |destination| are used as the respective header values.
void SendResponse(const Value& response,
const std::string& tool,
const std::string& destination);
- static const std::wstring kDataWide;
- static const std::wstring kResultWide;
+
+ // Redirects a V8 debugger command from |content| to a V8 debugger associated
+ // with the |tab_uid| and writes the result into |response| if it becomes
+ // known immediately.
+ bool DispatchDebuggerCommand(int tab_uid,
+ DictionaryValue* content,
+ DictionaryValue* response);
+
+ // Redirects a Javascript evaluation command from |content| to
+ // a V8 debugger associated with the |tab_uid| and writes the result
+ // into |response| if it becomes known immediately.
+ bool DispatchEvaluateJavascript(int tab_uid,
+ DictionaryValue* content,
+ DictionaryValue* response);
+
+ // The delegate is used to get an InspectableTabProxy instance.
DevToolsProtocolHandler* delegate_;
DISALLOW_COPY_AND_ASSIGN(DebuggerRemoteService);
};