[DevTools] Introduce DevToolsRendererChannel
This entity manages the blink::mojom::DevToolsAgent pointer exposed
by the renderer, it's process id and frame host for different
DevToolsAgentHostImpl subclasses.
Putting it into a single entity simplifies the lifetime management,
and will also aid with blink::mojom::DevToolsAgentHost
when we'll add one.
Bug: 775132
Change-Id: Ifc8e55995bff2eac813bb694ddc55ed7d0c9400c
Reviewed-on: https://chromium-review.googlesource.com/1247702
Commit-Queue: Dmitry Gozman <[email protected]>
Reviewed-by: Andrey Kosyakov <[email protected]>
Cr-Commit-Position: refs/heads/master@{#595562}
diff --git a/content/browser/devtools/devtools_renderer_channel.h b/content/browser/devtools/devtools_renderer_channel.h
new file mode 100644
index 0000000..ecfbf9f7f
--- /dev/null
+++ b/content/browser/devtools/devtools_renderer_channel.h
@@ -0,0 +1,49 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_RENDERER_CHANNEL_H_
+#define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_RENDERER_CHANNEL_H_
+
+#include "base/macros.h"
+#include "content/common/content_export.h"
+#include "third_party/blink/public/web/devtools_agent.mojom.h"
+
+namespace gfx {
+class Point;
+}
+
+namespace content {
+
+class DevToolsAgentHostImpl;
+class DevToolsSession;
+class RenderFrameHostImpl;
+
+// This class encapsulates a connection to blink::mojom::DevToolsAgent
+// in the renderer.
+// When the renderer changes, different DevToolsAgentHostImpl subclasses
+// retrieve a new blink::mojom::DevToolsAgent pointer, and this channel
+// starts using it for all existing and future sessions.
+class CONTENT_EXPORT DevToolsRendererChannel {
+ public:
+ explicit DevToolsRendererChannel(DevToolsAgentHostImpl* owner);
+ ~DevToolsRendererChannel();
+
+ void SetRenderer(blink::mojom::DevToolsAgentAssociatedPtr agent_ptr,
+ int process_id,
+ RenderFrameHostImpl* frame_host);
+ void AttachSession(DevToolsSession* session);
+ void InspectElement(const gfx::Point& point);
+
+ private:
+ DevToolsAgentHostImpl* owner_;
+ blink::mojom::DevToolsAgentAssociatedPtr agent_ptr_;
+ int process_id_;
+ RenderFrameHostImpl* frame_host_ = nullptr;
+
+ DISALLOW_COPY_AND_ASSIGN(DevToolsRendererChannel);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_RENDERER_CHANNEL_H_