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

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

Issue 2863623003: [DevTools] Support multiple sessions in content/ domain handlers (Closed)
Patch Set: addressed review comments 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
« no previous file with comments | « no previous file | content/browser/devtools/devtools_agent_host_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_AGENT_HOST_IMPL_H_ 5 #ifndef CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_AGENT_HOST_IMPL_H_
6 #define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_AGENT_HOST_IMPL_H_ 6 #define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_AGENT_HOST_IMPL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/containers/flat_set.h"
13 #include "content/browser/devtools/devtools_io_context.h" 14 #include "content/browser/devtools/devtools_io_context.h"
14 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
15 #include "content/common/devtools_messages.h" 16 #include "content/common/devtools_messages.h"
16 #include "content/public/browser/devtools_agent_host.h" 17 #include "content/public/browser/devtools_agent_host.h"
17 18
18 namespace content { 19 namespace content {
19 20
20 class BrowserContext; 21 class BrowserContext;
21 class DevToolsSession; 22 class DevToolsSession;
22 23
23 namespace protocol {
24 class DevToolsDomainHandler;
25 }
26
27 // Describes interface for managing devtools agents from the browser process. 24 // Describes interface for managing devtools agents from the browser process.
28 class CONTENT_EXPORT DevToolsAgentHostImpl : public DevToolsAgentHost { 25 class CONTENT_EXPORT DevToolsAgentHostImpl : public DevToolsAgentHost {
29 public: 26 public:
30 // DevToolsAgentHost implementation. 27 // DevToolsAgentHost implementation.
31 bool AttachClient(DevToolsAgentHostClient* client) override; 28 bool AttachClient(DevToolsAgentHostClient* client) override;
32 void ForceAttachClient(DevToolsAgentHostClient* client) override; 29 void ForceAttachClient(DevToolsAgentHostClient* client) override;
33 bool DetachClient(DevToolsAgentHostClient* client) override; 30 bool DetachClient(DevToolsAgentHostClient* client) override;
34 bool DispatchProtocolMessage(DevToolsAgentHostClient* client, 31 bool DispatchProtocolMessage(DevToolsAgentHostClient* client,
35 const std::string& message) override; 32 const std::string& message) override;
36 bool IsAttached() override; 33 bool IsAttached() override;
(...skipping 23 matching lines...) Expand all
60 virtual bool DispatchProtocolMessage( 57 virtual bool DispatchProtocolMessage(
61 DevToolsSession* session, 58 DevToolsSession* session,
62 const std::string& message) = 0; 59 const std::string& message) = 0;
63 virtual void InspectElement(DevToolsSession* session, int x, int y); 60 virtual void InspectElement(DevToolsSession* session, int x, int y);
64 61
65 void NotifyCreated(); 62 void NotifyCreated();
66 void ForceDetach(bool replaced); 63 void ForceDetach(bool replaced);
67 DevToolsIOContext* GetIOContext() { return &io_context_; } 64 DevToolsIOContext* GetIOContext() { return &io_context_; }
68 65
69 // TODO(dgozman): remove this accessor. 66 // TODO(dgozman): remove this accessor.
70 DevToolsSession* session() { return session_.get(); } 67 DevToolsSession* session() { return session_; }
71 68
72 private: 69 private:
73 friend class DevToolsAgentHost; // for static methods 70 friend class DevToolsAgentHost; // for static methods
74 friend class protocol::DevToolsDomainHandler; 71 friend class DevToolsSession;
75 bool InnerAttachClient(DevToolsAgentHostClient* client, bool force); 72 bool InnerAttachClient(DevToolsAgentHostClient* client, bool force);
76 void InnerDetachClient(); 73 void InnerDetachClient();
77 void NotifyAttached(); 74 void NotifyAttached();
78 void NotifyDetached(); 75 void NotifyDetached();
79 void NotifyDestroyed(); 76 void NotifyDestroyed();
80 77
81 const std::string id_; 78 const std::string id_;
82 int last_session_id_; 79 int last_session_id_;
83 std::unique_ptr<DevToolsSession> session_; 80 // TODO(dgozman): remove this together with accessor above.
81 DevToolsSession* session_;
82 base::flat_set<std::unique_ptr<DevToolsSession>> sessions_;
84 DevToolsIOContext io_context_; 83 DevToolsIOContext io_context_;
85 static int s_attached_count_; 84 static int s_attached_count_;
86 static int s_force_creation_count_; 85 static int s_force_creation_count_;
87 }; 86 };
88 87
89 class DevToolsMessageChunkProcessor { 88 class DevToolsMessageChunkProcessor {
90 public: 89 public:
91 using SendMessageCallback = base::Callback<void(int, const std::string&)>; 90 using SendMessageCallback = base::Callback<void(int, const std::string&)>;
92 explicit DevToolsMessageChunkProcessor(const SendMessageCallback& callback); 91 explicit DevToolsMessageChunkProcessor(const SendMessageCallback& callback);
93 ~DevToolsMessageChunkProcessor(); 92 ~DevToolsMessageChunkProcessor();
94 93
95 std::string state_cookie() const { return state_cookie_; } 94 std::string state_cookie() const { return state_cookie_; }
96 void set_state_cookie(const std::string& cookie) { state_cookie_ = cookie; } 95 void set_state_cookie(const std::string& cookie) { state_cookie_ = cookie; }
97 int last_call_id() const { return last_call_id_; } 96 int last_call_id() const { return last_call_id_; }
98 bool ProcessChunkedMessageFromAgent(const DevToolsMessageChunk& chunk); 97 bool ProcessChunkedMessageFromAgent(const DevToolsMessageChunk& chunk);
99 98
100 private: 99 private:
101 SendMessageCallback callback_; 100 SendMessageCallback callback_;
102 std::string message_buffer_; 101 std::string message_buffer_;
103 uint32_t message_buffer_size_; 102 uint32_t message_buffer_size_;
104 std::string state_cookie_; 103 std::string state_cookie_;
105 int last_call_id_; 104 int last_call_id_;
106 }; 105 };
107 106
108 } // namespace content 107 } // namespace content
109 108
110 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_AGENT_HOST_IMPL_H_ 109 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_AGENT_HOST_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/devtools/devtools_agent_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698