OLD | NEW |
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 DevToolsAgentHostImpl(const std::string& id); | 66 DevToolsAgentHostImpl(const std::string& id); |
67 ~DevToolsAgentHostImpl() override; | 67 ~DevToolsAgentHostImpl() override; |
68 | 68 |
69 static bool ShouldForceCreation(); | 69 static bool ShouldForceCreation(); |
70 | 70 |
71 virtual bool DispatchProtocolMessage(const std::string& message) = 0; | 71 virtual bool DispatchProtocolMessage(const std::string& message) = 0; |
72 virtual void InspectElement(int x, int y); | 72 virtual void InspectElement(int x, int y); |
73 | 73 |
74 void NotifyCreated(); | 74 void NotifyCreated(); |
75 void HostClosed(); | 75 void HostClosed(); |
76 devtools::DevToolsIOContext* GetIOContext() { return &io_context_; } | 76 DevToolsIOContext* GetIOContext() { return &io_context_; } |
77 | 77 |
78 DevToolsSession* session() { return session_.get(); } | 78 DevToolsSession* session() { return session_.get(); } |
79 | 79 |
80 private: | 80 private: |
81 friend class DevToolsAgentHost; // for static methods | 81 friend class DevToolsAgentHost; // for static methods |
82 bool InnerAttach(DevToolsAgentHostClient* client, bool force); | 82 bool InnerAttach(DevToolsAgentHostClient* client, bool force); |
83 void InnerDetach(); | 83 void InnerDetach(); |
84 void NotifyAttached(); | 84 void NotifyAttached(); |
85 void NotifyDetached(); | 85 void NotifyDetached(); |
86 void NotifyDestroyed(); | 86 void NotifyDestroyed(); |
87 | 87 |
88 const std::string id_; | 88 const std::string id_; |
89 int session_id_; | 89 int session_id_; |
90 int last_session_id_; | 90 int last_session_id_; |
91 std::unique_ptr<DevToolsSession> session_; | 91 std::unique_ptr<DevToolsSession> session_; |
92 DevToolsAgentHostClient* client_; | 92 DevToolsAgentHostClient* client_; |
93 devtools::DevToolsIOContext io_context_; | 93 DevToolsIOContext io_context_; |
94 static int s_attached_count_; | 94 static int s_attached_count_; |
95 static int s_force_creation_count_; | 95 static int s_force_creation_count_; |
96 }; | 96 }; |
97 | 97 |
98 class DevToolsMessageChunkProcessor { | 98 class DevToolsMessageChunkProcessor { |
99 public: | 99 public: |
100 using SendMessageCallback = base::Callback<void(int, const std::string&)>; | 100 using SendMessageCallback = base::Callback<void(int, const std::string&)>; |
101 explicit DevToolsMessageChunkProcessor(const SendMessageCallback& callback); | 101 explicit DevToolsMessageChunkProcessor(const SendMessageCallback& callback); |
102 ~DevToolsMessageChunkProcessor(); | 102 ~DevToolsMessageChunkProcessor(); |
103 | 103 |
104 std::string state_cookie() const { return state_cookie_; } | 104 std::string state_cookie() const { return state_cookie_; } |
105 void set_state_cookie(const std::string& cookie) { state_cookie_ = cookie; } | 105 void set_state_cookie(const std::string& cookie) { state_cookie_ = cookie; } |
106 int last_call_id() const { return last_call_id_; } | 106 int last_call_id() const { return last_call_id_; } |
107 bool ProcessChunkedMessageFromAgent(const DevToolsMessageChunk& chunk); | 107 bool ProcessChunkedMessageFromAgent(const DevToolsMessageChunk& chunk); |
108 | 108 |
109 private: | 109 private: |
110 SendMessageCallback callback_; | 110 SendMessageCallback callback_; |
111 std::string message_buffer_; | 111 std::string message_buffer_; |
112 uint32_t message_buffer_size_; | 112 uint32_t message_buffer_size_; |
113 std::string state_cookie_; | 113 std::string state_cookie_; |
114 int last_call_id_; | 114 int last_call_id_; |
115 }; | 115 }; |
116 | 116 |
117 } // namespace content | 117 } // namespace content |
118 | 118 |
119 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_AGENT_HOST_IMPL_H_ | 119 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_AGENT_HOST_IMPL_H_ |
OLD | NEW |