| 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 16 matching lines...) Expand all Loading... |
| 27 // Describes interface for managing devtools agents from the browser process. | 27 // Describes interface for managing devtools agents from the browser process. |
| 28 class CONTENT_EXPORT DevToolsAgentHostImpl : public DevToolsAgentHost, | 28 class CONTENT_EXPORT DevToolsAgentHostImpl : public DevToolsAgentHost, |
| 29 public DevToolsProtocolDelegate { | 29 public DevToolsProtocolDelegate { |
| 30 public: | 30 public: |
| 31 // Informs the hosted agent that a client host has attached. | 31 // Informs the hosted agent that a client host has attached. |
| 32 virtual void Attach() = 0; | 32 virtual void Attach() = 0; |
| 33 | 33 |
| 34 // Informs the hosted agent that a client host has detached. | 34 // Informs the hosted agent that a client host has detached. |
| 35 virtual void Detach() = 0; | 35 virtual void Detach() = 0; |
| 36 | 36 |
| 37 // Opens the inspector for this host. | |
| 38 bool Inspect(BrowserContext* browser_context); | |
| 39 | |
| 40 // DevToolsAgentHost implementation. | 37 // DevToolsAgentHost implementation. |
| 41 bool AttachClient(DevToolsAgentHostClient* client) override; | 38 bool AttachClient(DevToolsAgentHostClient* client) override; |
| 42 void ForceAttachClient(DevToolsAgentHostClient* client) override; | 39 void ForceAttachClient(DevToolsAgentHostClient* client) override; |
| 43 bool DetachClient(DevToolsAgentHostClient* client) override; | 40 bool DetachClient(DevToolsAgentHostClient* client) override; |
| 44 bool DispatchProtocolMessage(DevToolsAgentHostClient* client, | 41 bool DispatchProtocolMessage(DevToolsAgentHostClient* client, |
| 45 const std::string& message) override; | 42 const std::string& message) override; |
| 46 | |
| 47 bool IsAttached() override; | 43 bool IsAttached() override; |
| 48 void InspectElement(DevToolsAgentHostClient* client, int x, int y) override; | 44 void InspectElement(DevToolsAgentHostClient* client, int x, int y) override; |
| 49 std::string GetId() override; | 45 std::string GetId() override; |
| 46 std::string GetParentId() override; |
| 47 std::string GetDescription() override; |
| 48 void SetDescriptionOverride(const std::string& description) override; |
| 49 GURL GetFaviconURL() override; |
| 50 base::TimeTicks GetLastActivityTime() override; |
| 50 BrowserContext* GetBrowserContext() override; | 51 BrowserContext* GetBrowserContext() override; |
| 51 WebContents* GetWebContents() override; | 52 WebContents* GetWebContents() override; |
| 52 void DisconnectWebContents() override; | 53 void DisconnectWebContents() override; |
| 53 void ConnectWebContents(WebContents* wc) override; | 54 void ConnectWebContents(WebContents* wc) override; |
| 55 bool Inspect() override; |
| 54 | 56 |
| 55 // DevToolsProtocolDelegate implementation. | 57 // DevToolsProtocolDelegate implementation. |
| 56 void SendProtocolResponse(int session_id, | 58 void SendProtocolResponse(int session_id, |
| 57 const std::string& message) override; | 59 const std::string& message) override; |
| 58 void SendProtocolNotification(const std::string& message) override; | 60 void SendProtocolNotification(const std::string& message) override; |
| 59 | 61 |
| 60 protected: | 62 protected: |
| 61 DevToolsAgentHostImpl(); | 63 DevToolsAgentHostImpl(); |
| 62 ~DevToolsAgentHostImpl() override; | 64 ~DevToolsAgentHostImpl() override; |
| 63 | 65 |
| 64 virtual bool DispatchProtocolMessage(const std::string& message) = 0; | 66 virtual bool DispatchProtocolMessage(const std::string& message) = 0; |
| 65 virtual void InspectElement(int x, int y); | 67 virtual void InspectElement(int x, int y); |
| 66 | 68 |
| 67 void HostClosed(); | 69 void HostClosed(); |
| 68 void SendMessageToClient(int session_id, const std::string& message); | 70 void SendMessageToClient(int session_id, const std::string& message); |
| 69 devtools::DevToolsIOContext* GetIOContext() { return &io_context_; } | 71 devtools::DevToolsIOContext* GetIOContext() { return &io_context_; } |
| 70 | 72 |
| 71 int session_id() { DCHECK(client_); return session_id_; } | 73 int session_id() { DCHECK(client_); return session_id_; } |
| 72 | 74 |
| 73 static void NotifyCallbacks(DevToolsAgentHostImpl* agent_host, bool attached); | 75 static void NotifyCallbacks(DevToolsAgentHostImpl* agent_host, bool attached); |
| 74 | 76 |
| 75 private: | 77 private: |
| 76 friend class DevToolsAgentHost; // for static methods | 78 friend class DevToolsAgentHost; // for static methods |
| 77 bool InnerAttach(DevToolsAgentHostClient* client, bool force); | 79 bool InnerAttach(DevToolsAgentHostClient* client, bool force); |
| 78 void InnerDetach(); | 80 void InnerDetach(); |
| 79 | 81 |
| 80 const std::string id_; | 82 const std::string id_; |
| 81 int session_id_; | 83 int session_id_; |
| 84 std::string description_; |
| 82 DevToolsAgentHostClient* client_; | 85 DevToolsAgentHostClient* client_; |
| 83 devtools::DevToolsIOContext io_context_; | 86 devtools::DevToolsIOContext io_context_; |
| 84 }; | 87 }; |
| 85 | 88 |
| 86 class DevToolsMessageChunkProcessor { | 89 class DevToolsMessageChunkProcessor { |
| 87 public: | 90 public: |
| 88 using SendMessageCallback = base::Callback<void(int, const std::string&)>; | 91 using SendMessageCallback = base::Callback<void(int, const std::string&)>; |
| 89 explicit DevToolsMessageChunkProcessor(const SendMessageCallback& callback); | 92 explicit DevToolsMessageChunkProcessor(const SendMessageCallback& callback); |
| 90 ~DevToolsMessageChunkProcessor(); | 93 ~DevToolsMessageChunkProcessor(); |
| 91 | 94 |
| 92 std::string state_cookie() const { return state_cookie_; } | 95 std::string state_cookie() const { return state_cookie_; } |
| 93 void set_state_cookie(const std::string& cookie) { state_cookie_ = cookie; } | 96 void set_state_cookie(const std::string& cookie) { state_cookie_ = cookie; } |
| 94 int last_call_id() const { return last_call_id_; } | 97 int last_call_id() const { return last_call_id_; } |
| 95 bool ProcessChunkedMessageFromAgent(const DevToolsMessageChunk& chunk); | 98 bool ProcessChunkedMessageFromAgent(const DevToolsMessageChunk& chunk); |
| 96 | 99 |
| 97 private: | 100 private: |
| 98 SendMessageCallback callback_; | 101 SendMessageCallback callback_; |
| 99 std::string message_buffer_; | 102 std::string message_buffer_; |
| 100 uint32_t message_buffer_size_; | 103 uint32_t message_buffer_size_; |
| 101 std::string state_cookie_; | 104 std::string state_cookie_; |
| 102 int last_call_id_; | 105 int last_call_id_; |
| 103 }; | 106 }; |
| 104 | 107 |
| 105 } // namespace content | 108 } // namespace content |
| 106 | 109 |
| 107 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_AGENT_HOST_IMPL_H_ | 110 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_AGENT_HOST_IMPL_H_ |
| OLD | NEW |