summaryrefslogtreecommitdiffstats
path: root/content/browser/devtools/devtools_external_agent_proxy_impl.cc
blob: 0513dc238b10f3725d9b09215714abef67223dcd (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
61
62
63
64
65
66
67
68
69
70
71
72
73
// Copyright (c) 2013 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.

#include "content/browser/devtools/devtools_external_agent_proxy_impl.h"

#include "content/browser/devtools/devtools_agent_host_impl.h"
#include "content/browser/devtools/devtools_manager_impl.h"
#include "content/public/browser/devtools_external_agent_proxy_delegate.h"

namespace content {

class DevToolsExternalAgentProxyImpl::ForwardingAgentHost
    : public DevToolsAgentHostImpl {
 public:
  ForwardingAgentHost(DevToolsExternalAgentProxyDelegate* delegate)
      : delegate_(delegate) {
  }

  void ConnectionClosed() {
    NotifyCloseListener();
  }

 private:
  virtual ~ForwardingAgentHost() {
  }

  // DevToolsAgentHostImpl implementation.
  virtual void Attach() OVERRIDE {
    delegate_->Attach();
  };

  virtual void Detach() OVERRIDE {
    delegate_->Detach();
  };

  virtual void DispatchOnInspectorBackend(const std::string& message) OVERRIDE {
    delegate_->SendMessageToBackend(message);
  }

  DevToolsExternalAgentProxyDelegate* delegate_;
};

//static
DevToolsExternalAgentProxy* DevToolsExternalAgentProxy::Create(
    DevToolsExternalAgentProxyDelegate* delegate) {
  return new DevToolsExternalAgentProxyImpl(delegate);
}

DevToolsExternalAgentProxyImpl::DevToolsExternalAgentProxyImpl(
    DevToolsExternalAgentProxyDelegate* delegate)
    : agent_host_(new ForwardingAgentHost(delegate)) {
}

DevToolsExternalAgentProxyImpl::~DevToolsExternalAgentProxyImpl() {
}

scoped_refptr<DevToolsAgentHost> DevToolsExternalAgentProxyImpl::
    GetAgentHost() {
  return agent_host_;
}

void DevToolsExternalAgentProxyImpl::DispatchOnClientHost(
    const std::string& message) {
  DevToolsManagerImpl::GetInstance()->DispatchOnInspectorFrontend(
      agent_host_.get(), message);
}

void DevToolsExternalAgentProxyImpl::ConnectionClosed() {
  agent_host_->ConnectionClosed();
}

}  // content