| Index: content/browser/devtools/devtools_session.h
|
| diff --git a/content/browser/devtools/devtools_session.h b/content/browser/devtools/devtools_session.h
|
| index ea5456a4d3576b2b09a524491ee4c3747e20b44b..24909914ef6d85da6de94b6494cfd3af3dc23198 100644
|
| --- a/content/browser/devtools/devtools_session.h
|
| +++ b/content/browser/devtools/devtools_session.h
|
| @@ -2,14 +2,18 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#ifndef CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_SESSION_H_
|
| +#define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_SESSION_H_
|
| +
|
| +#include "base/containers/flat_map.h"
|
| #include "base/memory/weak_ptr.h"
|
| #include "base/values.h"
|
| +#include "content/browser/devtools/devtools_agent_host_impl.h"
|
| #include "content/browser/devtools/protocol/devtools_domain_handler.h"
|
| #include "content/browser/devtools/protocol/protocol.h"
|
|
|
| namespace content {
|
|
|
| -class DevToolsAgentHostImpl;
|
| class DevToolsAgentHostClient;
|
| class RenderFrameHostImpl;
|
|
|
| @@ -24,7 +28,6 @@ class DevToolsSession : public protocol::FrontendChannel {
|
| void AddHandler(std::unique_ptr<protocol::DevToolsDomainHandler> handler);
|
| void SetRenderFrameHost(RenderFrameHostImpl* host);
|
| void SetFallThroughForNotFound(bool value);
|
| - protocol::DevToolsDomainHandler* GetHandlerByName(const std::string& name);
|
|
|
| protocol::Response::Status Dispatch(
|
| const std::string& message,
|
| @@ -34,6 +37,21 @@ class DevToolsSession : public protocol::FrontendChannel {
|
| // Only used by DevToolsAgentHostImpl.
|
| DevToolsAgentHostClient* client() const { return client_; }
|
|
|
| + template <typename Handler>
|
| + static std::vector<Handler*> HandlersForAgentHost(
|
| + DevToolsAgentHostImpl* agent_host,
|
| + const std::string& name) {
|
| + std::vector<Handler*> result;
|
| + if (agent_host->sessions_.empty())
|
| + return result;
|
| + for (const auto& session : agent_host->sessions_) {
|
| + auto it = session->handlers_.find(name);
|
| + if (it != session->handlers_.end())
|
| + result.push_back(static_cast<Handler*>(it->second.get()));
|
| + }
|
| + return result;
|
| + }
|
| +
|
| private:
|
| void sendResponse(std::unique_ptr<base::DictionaryValue> response);
|
| // protocol::FrontendChannel implementation.
|
| @@ -47,8 +65,8 @@ class DevToolsSession : public protocol::FrontendChannel {
|
| DevToolsAgentHostImpl* agent_host_;
|
| DevToolsAgentHostClient* client_;
|
| int session_id_;
|
| - std::unordered_map<std::string,
|
| - std::unique_ptr<protocol::DevToolsDomainHandler>> handlers_;
|
| + base::flat_map<std::string, std::unique_ptr<protocol::DevToolsDomainHandler>>
|
| + handlers_;
|
| RenderFrameHostImpl* host_;
|
| std::unique_ptr<protocol::UberDispatcher> dispatcher_;
|
|
|
| @@ -56,3 +74,5 @@ class DevToolsSession : public protocol::FrontendChannel {
|
| };
|
|
|
| } // namespace content
|
| +
|
| +#endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_SESSION_H_
|
|
|