| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_SESSION_H_ | 5 #ifndef CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_SESSION_H_ |
| 6 #define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_SESSION_H_ | 6 #define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_SESSION_H_ |
| 7 | 7 |
| 8 #include "base/containers/flat_map.h" | 8 #include "base/containers/flat_map.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 // Only used by DevToolsAgentHostImpl. | 38 // Only used by DevToolsAgentHostImpl. |
| 39 DevToolsAgentHostClient* client() const { return client_; } | 39 DevToolsAgentHostClient* client() const { return client_; } |
| 40 void SendMessageToClient(const std::string& message); | 40 void SendMessageToClient(const std::string& message); |
| 41 | 41 |
| 42 template <typename Handler> | 42 template <typename Handler> |
| 43 static std::vector<Handler*> HandlersForAgentHost( | 43 static std::vector<Handler*> HandlersForAgentHost( |
| 44 DevToolsAgentHostImpl* agent_host, | 44 DevToolsAgentHostImpl* agent_host, |
| 45 const std::string& name) { | 45 const std::string& name) { |
| 46 std::vector<Handler*> result; | 46 std::vector<Handler*> result; |
| 47 if (agent_host->sessions_.empty()) | 47 if (agent_host->sessions().empty()) |
| 48 return result; | 48 return result; |
| 49 for (const auto& session : agent_host->sessions_) { | 49 for (auto& it_session : agent_host->sessions()) { |
| 50 auto it = session->handlers_.find(name); | 50 DevToolsSession* session = it_session.second; |
| 51 if (it != session->handlers_.end()) | 51 auto it_handler = session->handlers_.find(name); |
| 52 result.push_back(static_cast<Handler*>(it->second.get())); | 52 if (it_handler != session->handlers_.end()) |
| 53 result.push_back(static_cast<Handler*>(it_handler->second.get())); |
| 53 } | 54 } |
| 54 return result; | 55 return result; |
| 55 } | 56 } |
| 56 | 57 |
| 57 private: | 58 private: |
| 58 void sendResponse(std::unique_ptr<base::DictionaryValue> response); | 59 void sendResponse(std::unique_ptr<base::DictionaryValue> response); |
| 59 // protocol::FrontendChannel implementation. | 60 // protocol::FrontendChannel implementation. |
| 60 void sendProtocolResponse( | 61 void sendProtocolResponse( |
| 61 int call_id, | 62 int call_id, |
| 62 std::unique_ptr<protocol::Serializable> message) override; | 63 std::unique_ptr<protocol::Serializable> message) override; |
| 63 void sendProtocolNotification( | 64 void sendProtocolNotification( |
| 64 std::unique_ptr<protocol::Serializable> message) override; | 65 std::unique_ptr<protocol::Serializable> message) override; |
| 65 void flushProtocolNotifications() override; | 66 void flushProtocolNotifications() override; |
| 66 | 67 |
| 67 DevToolsAgentHostImpl* agent_host_; | 68 DevToolsAgentHostImpl* agent_host_; |
| 68 DevToolsAgentHostClient* client_; | 69 DevToolsAgentHostClient* client_; |
| 69 int session_id_; | 70 int session_id_; |
| 70 base::flat_map<std::string, std::unique_ptr<protocol::DevToolsDomainHandler>> | 71 base::flat_map<std::string, std::unique_ptr<protocol::DevToolsDomainHandler>> |
| 71 handlers_; | 72 handlers_; |
| 72 RenderFrameHostImpl* host_; | 73 RenderFrameHostImpl* host_; |
| 73 std::unique_ptr<protocol::UberDispatcher> dispatcher_; | 74 std::unique_ptr<protocol::UberDispatcher> dispatcher_; |
| 74 | 75 |
| 75 base::WeakPtrFactory<DevToolsSession> weak_factory_; | 76 base::WeakPtrFactory<DevToolsSession> weak_factory_; |
| 76 }; | 77 }; |
| 77 | 78 |
| 78 } // namespace content | 79 } // namespace content |
| 79 | 80 |
| 80 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_SESSION_H_ | 81 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_SESSION_H_ |
| OLD | NEW |