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

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

Issue 2408133004: [DevTools] Implement Target.setDiscoverTargets method. (Closed)
Patch Set: force creation Created 4 years, 2 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 (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>
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 // DevToolsProtocolDelegate implementation. 58 // DevToolsProtocolDelegate implementation.
59 void SendProtocolResponse(int session_id, 59 void SendProtocolResponse(int session_id,
60 const std::string& message) override; 60 const std::string& message) override;
61 void SendProtocolNotification(const std::string& message) override; 61 void SendProtocolNotification(const std::string& message) override;
62 62
63 protected: 63 protected:
64 DevToolsAgentHostImpl(const std::string& id); 64 DevToolsAgentHostImpl(const std::string& id);
65 ~DevToolsAgentHostImpl() override; 65 ~DevToolsAgentHostImpl() override;
66 66
67 static bool ShouldForceCreation();
68
67 virtual bool DispatchProtocolMessage(const std::string& message) = 0; 69 virtual bool DispatchProtocolMessage(const std::string& message) = 0;
68 virtual void InspectElement(int x, int y); 70 virtual void InspectElement(int x, int y);
69 71
72 void NotifyCreated();
70 void HostClosed(); 73 void HostClosed();
71 void SendMessageToClient(int session_id, const std::string& message); 74 void SendMessageToClient(int session_id, const std::string& message);
72 devtools::DevToolsIOContext* GetIOContext() { return &io_context_; } 75 devtools::DevToolsIOContext* GetIOContext() { return &io_context_; }
73 76
74 int session_id() { DCHECK(client_); return session_id_; } 77 int session_id() { DCHECK(client_); return session_id_; }
75 78
76 private: 79 private:
77 friend class DevToolsAgentHost; // for static methods 80 friend class DevToolsAgentHost; // for static methods
78 bool InnerAttach(DevToolsAgentHostClient* client, bool force); 81 bool InnerAttach(DevToolsAgentHostClient* client, bool force);
79 void InnerDetach(); 82 void InnerDetach();
80 void NotifyAttached(); 83 void NotifyAttached();
81 void NotifyDetached(); 84 void NotifyDetached();
85 void NotifyDestroyed();
82 86
83 const std::string id_; 87 const std::string id_;
84 int session_id_; 88 int session_id_;
85 DevToolsAgentHostClient* client_; 89 DevToolsAgentHostClient* client_;
86 devtools::DevToolsIOContext io_context_; 90 devtools::DevToolsIOContext io_context_;
87 static int s_attached_count_; 91 static int s_attached_count_;
92 static int s_force_creation_count_;
88 }; 93 };
89 94
90 class DevToolsMessageChunkProcessor { 95 class DevToolsMessageChunkProcessor {
91 public: 96 public:
92 using SendMessageCallback = base::Callback<void(int, const std::string&)>; 97 using SendMessageCallback = base::Callback<void(int, const std::string&)>;
93 explicit DevToolsMessageChunkProcessor(const SendMessageCallback& callback); 98 explicit DevToolsMessageChunkProcessor(const SendMessageCallback& callback);
94 ~DevToolsMessageChunkProcessor(); 99 ~DevToolsMessageChunkProcessor();
95 100
96 std::string state_cookie() const { return state_cookie_; } 101 std::string state_cookie() const { return state_cookie_; }
97 void set_state_cookie(const std::string& cookie) { state_cookie_ = cookie; } 102 void set_state_cookie(const std::string& cookie) { state_cookie_ = cookie; }
98 int last_call_id() const { return last_call_id_; } 103 int last_call_id() const { return last_call_id_; }
99 bool ProcessChunkedMessageFromAgent(const DevToolsMessageChunk& chunk); 104 bool ProcessChunkedMessageFromAgent(const DevToolsMessageChunk& chunk);
100 105
101 private: 106 private:
102 SendMessageCallback callback_; 107 SendMessageCallback callback_;
103 std::string message_buffer_; 108 std::string message_buffer_;
104 uint32_t message_buffer_size_; 109 uint32_t message_buffer_size_;
105 std::string state_cookie_; 110 std::string state_cookie_;
106 int last_call_id_; 111 int last_call_id_;
107 }; 112 };
108 113
109 } // namespace content 114 } // namespace content
110 115
111 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_AGENT_HOST_IMPL_H_ 116 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_AGENT_HOST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698