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 20 matching lines...) Expand all Loading... |
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. | 37 // Opens the inspector for this host. |
38 bool Inspect(BrowserContext* browser_context); | 38 bool Inspect(BrowserContext* browser_context); |
39 | 39 |
40 // DevToolsAgentHost implementation. | 40 // DevToolsAgentHost implementation. |
41 void AttachClient(DevToolsAgentHostClient* client) override; | 41 bool AttachClient(DevToolsAgentHostClient* client) override; |
42 void DetachClient() override; | 42 void ForceAttachClient(DevToolsAgentHostClient* client) override; |
| 43 bool DetachClient(DevToolsAgentHostClient* client) override; |
| 44 bool DispatchProtocolMessage(DevToolsAgentHostClient* client, |
| 45 const std::string& message) override; |
| 46 |
43 bool IsAttached() override; | 47 bool IsAttached() override; |
44 void InspectElement(int x, int y) override; | 48 void InspectElement(int x, int y) override; |
45 std::string GetId() override; | 49 std::string GetId() override; |
46 BrowserContext* GetBrowserContext() override; | 50 BrowserContext* GetBrowserContext() override; |
47 WebContents* GetWebContents() override; | 51 WebContents* GetWebContents() override; |
48 void DisconnectWebContents() override; | 52 void DisconnectWebContents() override; |
49 void ConnectWebContents(WebContents* wc) override; | 53 void ConnectWebContents(WebContents* wc) override; |
50 | 54 |
51 // DevToolsProtocolDelegate implementation. | 55 // DevToolsProtocolDelegate implementation. |
52 void SendProtocolResponse(int session_id, | 56 void SendProtocolResponse(int session_id, |
53 const std::string& message) override; | 57 const std::string& message) override; |
54 void SendProtocolNotification(const std::string& message) override; | 58 void SendProtocolNotification(const std::string& message) override; |
55 | 59 |
56 protected: | 60 protected: |
57 DevToolsAgentHostImpl(); | 61 DevToolsAgentHostImpl(); |
58 ~DevToolsAgentHostImpl() override; | 62 ~DevToolsAgentHostImpl() override; |
59 | 63 |
| 64 virtual bool DispatchProtocolMessage(const std::string& message) = 0; |
| 65 |
60 void HostClosed(); | 66 void HostClosed(); |
61 void SendMessageToClient(int session_id, const std::string& message); | 67 void SendMessageToClient(int session_id, const std::string& message); |
62 devtools::DevToolsIOContext* GetIOContext() { return &io_context_; } | 68 devtools::DevToolsIOContext* GetIOContext() { return &io_context_; } |
63 | 69 |
64 int session_id() { DCHECK(client_); return session_id_; } | 70 int session_id() { DCHECK(client_); return session_id_; } |
65 | 71 |
66 static void NotifyCallbacks(DevToolsAgentHostImpl* agent_host, bool attached); | 72 static void NotifyCallbacks(DevToolsAgentHostImpl* agent_host, bool attached); |
67 | 73 |
68 private: | 74 private: |
69 friend class DevToolsAgentHost; // for static methods | 75 friend class DevToolsAgentHost; // for static methods |
| 76 bool InnerAttach(DevToolsAgentHostClient* client, bool force); |
70 void InnerDetach(); | 77 void InnerDetach(); |
71 | 78 |
72 const std::string id_; | 79 const std::string id_; |
73 int session_id_; | 80 int session_id_; |
74 DevToolsAgentHostClient* client_; | 81 DevToolsAgentHostClient* client_; |
75 devtools::DevToolsIOContext io_context_; | 82 devtools::DevToolsIOContext io_context_; |
76 }; | 83 }; |
77 | 84 |
78 class DevToolsMessageChunkProcessor { | 85 class DevToolsMessageChunkProcessor { |
79 public: | 86 public: |
(...skipping 10 matching lines...) Expand all Loading... |
90 SendMessageCallback callback_; | 97 SendMessageCallback callback_; |
91 std::string message_buffer_; | 98 std::string message_buffer_; |
92 uint32_t message_buffer_size_; | 99 uint32_t message_buffer_size_; |
93 std::string state_cookie_; | 100 std::string state_cookie_; |
94 int last_call_id_; | 101 int last_call_id_; |
95 }; | 102 }; |
96 | 103 |
97 } // namespace content | 104 } // namespace content |
98 | 105 |
99 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_AGENT_HOST_IMPL_H_ | 106 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_AGENT_HOST_IMPL_H_ |
OLD | NEW |