1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/devtools_service/devtools_agent_host.h"
7 namespace devtools_service
{
9 DevToolsAgentHost::DevToolsAgentHost(const std::string
& id
,
10 DevToolsAgentPtr agent
)
11 : id_(id
), agent_(agent
.Pass()), binding_(this), delegate_(nullptr) {}
13 DevToolsAgentHost::~DevToolsAgentHost() {
15 delegate_
->OnAgentHostClosed(this);
18 void DevToolsAgentHost::SetDelegate(Delegate
* delegate
) {
21 if (binding_
.is_bound())
24 DevToolsAgentClientPtr client
;
25 binding_
.Bind(&client
);
26 agent_
->SetClient(client
.Pass());
28 if (!binding_
.is_bound())
35 void DevToolsAgentHost::SendProtocolMessageToAgent(const std::string
& message
) {
36 agent_
->DispatchProtocolMessage(message
);
39 void DevToolsAgentHost::DispatchProtocolMessage(int32_t call_id
,
40 const mojo::String
& message
,
41 const mojo::String
& state
) {
42 delegate_
->DispatchProtocolMessage(this, message
);
45 } // namespace devtools_service