summaryrefslogtreecommitdiffstats
path: root/components/html_viewer/devtools_agent_impl.h
diff options
context:
space:
mode:
Diffstat (limited to 'components/html_viewer/devtools_agent_impl.h')
-rw-r--r--components/html_viewer/devtools_agent_impl.h37
1 files changed, 23 insertions, 14 deletions
diff --git a/components/html_viewer/devtools_agent_impl.h b/components/html_viewer/devtools_agent_impl.h
index 1998928..f062b31d 100644
--- a/components/html_viewer/devtools_agent_impl.h
+++ b/components/html_viewer/devtools_agent_impl.h
@@ -5,6 +5,9 @@
#ifndef COMPONENTS_HTML_VIEWER_DEVTOOLS_AGENT_IMPL_H_
#define COMPONENTS_HTML_VIEWER_DEVTOOLS_AGENT_IMPL_H_
+#include <string>
+#include <vector>
+
#include "base/macros.h"
#include "components/devtools_service/public/interfaces/devtools_service.mojom.h"
#include "third_party/WebKit/public/web/WebDevToolsAgentClient.h"
@@ -14,30 +17,24 @@ namespace blink {
class WebLocalFrame;
}
-namespace mojo {
-class Shell;
-}
-
namespace html_viewer {
class DevToolsAgentImpl : public devtools_service::DevToolsAgent,
public blink::WebDevToolsAgentClient {
public:
// |frame| must outlive this object.
- DevToolsAgentImpl(blink::WebLocalFrame* frame, mojo::Shell* shell);
+ // This agent should restore its internal state using |state| if it is not
+ // null.
+ DevToolsAgentImpl(blink::WebLocalFrame* frame,
+ const std::string& id,
+ const std::string* state);
~DevToolsAgentImpl() override;
- blink::WebLocalFrame* frame() const { return frame_; }
-
- // Returns whether a "Page.navigate" command is being handled.
- bool handling_page_navigate_request() const {
- return handling_page_navigate_request_;
- }
+ void BindToRequest(mojo::InterfaceRequest<DevToolsAgent> request);
private:
// devtools_service::DevToolsAgent implementation.
- void SetClient(devtools_service::DevToolsAgentClientPtr client,
- const mojo::String& client_id) override;
+ void SetClient(devtools_service::DevToolsAgentClientPtr client) override;
void DispatchProtocolMessage(const mojo::String& message) override;
// blink::WebDevToolsAgentClient implementation.
@@ -48,10 +45,22 @@ class DevToolsAgentImpl : public devtools_service::DevToolsAgent,
void OnConnectionError();
blink::WebLocalFrame* const frame_;
+ const std::string id_;
+
mojo::Binding<DevToolsAgent> binding_;
devtools_service::DevToolsAgentClientPtr client_;
- bool handling_page_navigate_request_;
+ // If we restore the agent's internal state using serialized state data from a
+ // previous agent, the agent may generate messages before |client_| is set.
+ // In that case, we need to cache messages for the client.
+ bool cache_until_client_ready_;
+
+ struct CachedClientMessage {
+ int call_id;
+ mojo::String response;
+ mojo::String state;
+ };
+ std::vector<CachedClientMessage> cached_client_messages_;
DISALLOW_COPY_AND_ASSIGN(DevToolsAgentImpl);
};