Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1018)

Unified Diff: components/devtools_service/devtools_registry_impl.cc

Issue 1164383002: Mandoline DevTools service: remote debugging protocol over HTTP/WebSocket. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698