| Index: components/devtools_service/devtools_registry_impl.cc
|
| diff --git a/components/devtools_service/devtools_registry_impl.cc b/components/devtools_service/devtools_registry_impl.cc
|
| index 130f20f6f9d2d9d261cc942586dc7f3c004a8fe5..3fc7e0d3a6d37ad02f5fe23eab6463b14d4673aa 100644
|
| --- a/components/devtools_service/devtools_registry_impl.cc
|
| +++ b/components/devtools_service/devtools_registry_impl.cc
|
| @@ -5,9 +5,17 @@
|
| #include "components/devtools_service/devtools_registry_impl.h"
|
|
|
| #include "base/logging.h"
|
| +#include "components/devtools_service/devtools_agent_host.h"
|
|
|
| namespace devtools_service {
|
|
|
| +DevToolsRegistryImpl::Iterator::Iterator(DevToolsRegistryImpl* registry)
|
| + : registry_(registry), iter_(registry->agents_.begin()) {
|
| +}
|
| +
|
| +DevToolsRegistryImpl::Iterator::~Iterator() {
|
| +}
|
| +
|
| DevToolsRegistryImpl::DevToolsRegistryImpl(DevToolsService* service)
|
| : service_(service) {
|
| }
|
| @@ -20,9 +28,26 @@ void DevToolsRegistryImpl::BindToRegistryRequest(
|
| bindings_.AddBinding(this, request.Pass());
|
| }
|
|
|
| +DevToolsAgentHost* DevToolsRegistryImpl::GetAgentById(const std::string& id) {
|
| + auto iter = agents_.find(id);
|
| + if (iter == agents_.end())
|
| + return nullptr;
|
| +
|
| + return iter->second.get();
|
| +}
|
| +
|
| void DevToolsRegistryImpl::RegisterAgent(DevToolsAgentPtr agent) {
|
| - // TODO(yzshen): Implement it.
|
| - NOTIMPLEMENTED();
|
| + linked_ptr<DevToolsAgentHost> agent_host(new DevToolsAgentHost(agent.Pass()));
|
| + std::string id = agent_host->id();
|
| + agent_host->set_agent_connection_error_handler(
|
| + [this, id]() { OnAgentConnectionError(id); });
|
| +
|
| + agents_[agent_host->id()] = agent_host;
|
| +}
|
| +
|
| +void DevToolsRegistryImpl::OnAgentConnectionError(const std::string& id) {
|
| + DCHECK(agents_.find(id) != agents_.end());
|
| + agents_.erase(id);
|
| }
|
|
|
| } // namespace devtools_service
|
|
|