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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_AGENT_HOST_IMPL_H_
6 #define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_AGENT_HOST_IMPL_H_
10 #include "base/compiler_specific.h"
11 #include "content/common/content_export.h"
12 #include "content/common/devtools_messages.h"
13 #include "content/public/browser/devtools_agent_host.h"
23 // Describes interface for managing devtools agents from the browser process.
24 class CONTENT_EXPORT DevToolsAgentHostImpl
: public DevToolsAgentHost
{
26 // Informs the hosted agent that a client host has attached.
27 virtual void Attach() = 0;
29 // Informs the hosted agent that a client host has detached.
30 virtual void Detach() = 0;
32 // Opens the inspector for this host.
33 void Inspect(BrowserContext
* browser_context
);
35 // DevToolsAgentHost implementation.
36 void AttachClient(DevToolsAgentHostClient
* client
) override
;
37 void DetachClient() override
;
38 bool IsAttached() override
;
39 void InspectElement(int x
, int y
) override
;
40 std::string
GetId() override
;
41 BrowserContext
* GetBrowserContext() override
;
42 WebContents
* GetWebContents() override
;
43 void DisconnectWebContents() override
;
44 void ConnectWebContents(WebContents
* wc
) override
;
47 DevToolsAgentHostImpl();
48 ~DevToolsAgentHostImpl() override
;
51 void SendMessageToClient(const std::string
& message
);
52 static void NotifyCallbacks(DevToolsAgentHostImpl
* agent_host
, bool attached
);
55 friend class DevToolsAgentHost
; // for static methods
57 const std::string id_
;
58 DevToolsAgentHostClient
* client_
;
61 class DevToolsMessageChunkProcessor
{
63 using SendMessageCallback
= base::Callback
<void(const std::string
&)>;
64 explicit DevToolsMessageChunkProcessor(const SendMessageCallback
& callback
);
65 ~DevToolsMessageChunkProcessor();
67 std::string
state_cookie() const { return state_cookie_
; }
68 void set_state_cookie(const std::string
& cookie
) { state_cookie_
= cookie
; }
69 int last_call_id() const { return last_call_id_
; }
70 void ProcessChunkedMessageFromAgent(const DevToolsMessageChunk
& chunk
);
73 SendMessageCallback callback_
;
74 std::string message_buffer_
;
75 uint32 message_buffer_size_
;
76 std::string state_cookie_
;
80 } // namespace content
82 #endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_AGENT_HOST_IMPL_H_