summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/debug_message_handler.h
blob: d7724d0f8e483bd1684bdc280ead08c8f88de916 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// MessageFilter object to handle messages aimed at the debugger, and to
// dispatch them from the main thread rather than the render thread.
// Also owns the reference to the Debugger object and handles callbacks from it.

#ifndef CHROME_RENDERER_DEBUG_MESSAGE_HANDLER_H_
#define CHROME_RENDERER_DEBUG_MESSAGE_HANDLER_H_

#include "chrome/common/ipc_channel_proxy.h"
#include "webkit/glue/debugger.h"

class RenderView;

class DebugMessageHandler : public IPC::ChannelProxy::MessageFilter,
                            public Debugger::Delegate {
 public:
  DebugMessageHandler(RenderView* view);
  virtual ~DebugMessageHandler();

 private:
  // evaluate javascript URL in the renderer
  void EvaluateScriptUrl(const std::wstring& url);

  // Debugger::Delegate callback method to handle debugger output.
  void DebuggerOutput(const std::wstring& out);

  // Schedule a debugger break.
  void OnBreak(bool force);

  // Sends a command to the debugger.
  void OnCommand(const std::wstring& cmd);

  // Sends an attach event to the debugger front-end.
  void OnAttach();

  // Unregister with V8 and notify the RenderView.
  void OnDetach();

  virtual void OnFilterAdded(IPC::Channel* channel);
  virtual void OnFilterRemoved();

  // Returns true to indicate that the message was handled, or false to let
  // the message be handled in the default way.
  virtual bool OnMessageReceived(const IPC::Message& message);

  scoped_refptr<Debugger> debugger_;

  // Don't ever dereference view_ directly from another thread as it's not
  // threadsafe, instead proxy locally via its MessageLoop.
  RenderView* view_;
  MessageLoop* view_loop_;

  int32 view_routing_id_;
  IPC::Channel* channel_;
};

#endif // CHROME_RENDERER_DEBUG_MESSAGE_HANDLER_H_