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

Side by Side Diff: content/browser/devtools/devtools_session.h

Issue 2874613003: [DevTools] Support multiple clients in DevToolsAgentHost (Closed)
Patch Set: Created 3 years, 7 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 unified diff | Download patch
OLDNEW
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
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_
OLDNEW
« no previous file with comments | « content/browser/devtools/devtools_agent_host_impl.cc ('k') | content/browser/devtools/forwarding_agent_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698