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"
8 #include "base/logging.h"
10 namespace devtools_service
{
12 DevToolsAgentHost::DevToolsAgentHost(DevToolsAgentPtr agent
)
13 : id_(base::GenerateGUID()),
17 agent_
.set_error_handler(this);
20 DevToolsAgentHost::~DevToolsAgentHost() {
22 delegate_
->OnAgentHostClosed(this);
25 void DevToolsAgentHost::SetDelegate(Delegate
* delegate
) {
28 if (binding_
.is_bound())
31 DevToolsAgentClientPtr client
;
32 binding_
.Bind(&client
);
33 agent_
->SetClient(client
.Pass(), id_
);
35 if (!binding_
.is_bound())
42 void DevToolsAgentHost::SendProtocolMessageToAgent(const std::string
& message
) {
43 agent_
->DispatchProtocolMessage(message
);
46 void DevToolsAgentHost::DispatchProtocolMessage(const mojo::String
& message
) {
47 delegate_
->DispatchProtocolMessage(this, message
);
50 void DevToolsAgentHost::OnConnectionError() {
51 agent_connection_error_handler_
.Run();
54 } // namespace devtools_service