Commit 13fc02ff authored by Sean Gilhuly's avatar Sean Gilhuly Committed by Commit Bot

Setup for connecting the Viz DevTools server

Watch for a server socket when the frame sink manager is created, and
run the viz devtools server on the compositor thread if it is present.

The server socket is not passed in through mojo yet, so the devtools
server will not be created.

Bug: 816802
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel
Change-Id: Ic02853a2e1f845df365716c29e4f974ffd7482dc
Reviewed-on: https://chromium-review.googlesource.com/c/1285078Reviewed-by: default avatarRamin Halavati <rhalavati@chromium.org>
Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarkylechar <kylechar@chromium.org>
Commit-Queue: Sean Gilhuly <sgilhuly@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604571}
parent 5fa61755
...@@ -94,10 +94,11 @@ void ChromeBrowserMainExtraPartsViews::PreCreateThreads() { ...@@ -94,10 +94,11 @@ void ChromeBrowserMainExtraPartsViews::PreCreateThreads() {
void ChromeBrowserMainExtraPartsViews::PreProfileInit() { void ChromeBrowserMainExtraPartsViews::PreProfileInit() {
#if defined(USE_AURA) #if defined(USE_AURA)
// Start devtools server // Start devtools server
constexpr int kUiDevToolsDefaultPort = 9223;
network::mojom::NetworkContext* network_context = network::mojom::NetworkContext* network_context =
g_browser_process->system_network_context_manager()->GetContext(); g_browser_process->system_network_context_manager()->GetContext();
devtools_server_ = ui_devtools::UiDevToolsServer::Create( devtools_server_ = ui_devtools::UiDevToolsServer::CreateForViews(
network_context, switches::kEnableUiDevTools, 9223); network_context, switches::kEnableUiDevTools, kUiDevToolsDefaultPort);
if (devtools_server_) { if (devtools_server_) {
auto dom_backend = std::make_unique<ui_devtools::DOMAgentAura>(); auto dom_backend = std::make_unique<ui_devtools::DOMAgentAura>();
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
......
# 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.
declare_args() {
# Indicates if the Viz Devtools server is enabled. This is disabled on
# official Android and iOS builds to reduce binary size.
use_viz_devtools = !((is_android || is_ios) && is_official_build)
}
...@@ -32,19 +32,11 @@ bool IsDevToolsEnabled(const char* enable_devtools_flag) { ...@@ -32,19 +32,11 @@ bool IsDevToolsEnabled(const char* enable_devtools_flag) {
enable_devtools_flag); enable_devtools_flag);
} }
int GetUiDevToolsPort(const char* enable_devtools_flag, int default_port) { } // namespace
DCHECK(IsDevToolsEnabled(enable_devtools_flag));
// This value is duplicated in the chrome://flags description. UiDevToolsServer* UiDevToolsServer::devtools_server_ = nullptr;
int port;
if (!base::StringToInt(
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
enable_devtools_flag),
&port))
port = default_port;
return port;
}
constexpr net::NetworkTrafficAnnotationTag kUIDevtoolsServer = const net::NetworkTrafficAnnotationTag UiDevToolsServer::kUIDevtoolsServerTag =
net::DefineNetworkTrafficAnnotation("ui_devtools_server", R"( net::DefineNetworkTrafficAnnotation("ui_devtools_server", R"(
semantics { semantics {
sender: "UI Devtools Server" sender: "UI Devtools Server"
...@@ -65,14 +57,30 @@ constexpr net::NetworkTrafficAnnotationTag kUIDevtoolsServer = ...@@ -65,14 +57,30 @@ constexpr net::NetworkTrafficAnnotationTag kUIDevtoolsServer =
"Not implemented, only used in Devtools and is behind a switch." "Not implemented, only used in Devtools and is behind a switch."
})"); })");
} // namespace const net::NetworkTrafficAnnotationTag UiDevToolsServer::kVizDevtoolsServerTag =
net::DefineNetworkTrafficAnnotation("viz_devtools_server", R"(
UiDevToolsServer* UiDevToolsServer::devtools_server_ = nullptr; semantics {
sender: "Viz Devtools Server"
description:
"Backend for Viz DevTools, to inspect FrameSink hierarchies."
trigger:
"Run with '--enable-viz-devtools' switch."
data: "Debugging data, including any data on the active frame sinks."
destination: OTHER
destination_other: "The data can be sent to any destination."
}
policy {
cookies_allowed: NO
setting:
"This request cannot be disabled in settings. However it will never "
"be made if user does not run with '--enable-viz-devtools' switch."
policy_exception_justification:
"Not implemented, only used in Devtools and is behind a switch."
})");
UiDevToolsServer::UiDevToolsServer(const char* enable_devtools_flag, UiDevToolsServer::UiDevToolsServer(int port,
int default_port) net::NetworkTrafficAnnotationTag tag)
: port_(GetUiDevToolsPort(enable_devtools_flag, default_port)), : port_(port), tag_(tag), weak_ptr_factory_(this) {
weak_ptr_factory_(this) {
DCHECK(!devtools_server_); DCHECK(!devtools_server_);
devtools_server_ = this; devtools_server_ = this;
} }
...@@ -82,19 +90,51 @@ UiDevToolsServer::~UiDevToolsServer() { ...@@ -82,19 +90,51 @@ UiDevToolsServer::~UiDevToolsServer() {
} }
// static // static
std::unique_ptr<UiDevToolsServer> UiDevToolsServer::Create( std::unique_ptr<UiDevToolsServer> UiDevToolsServer::CreateForViews(
network::mojom::NetworkContext* network_context, network::mojom::NetworkContext* network_context,
const char* enable_devtools_flag, const char* enable_devtools_flag,
int default_port) { int default_port) {
std::unique_ptr<UiDevToolsServer> server; std::unique_ptr<UiDevToolsServer> server;
if (IsDevToolsEnabled(enable_devtools_flag) && !devtools_server_) { if (IsDevToolsEnabled(enable_devtools_flag) && !devtools_server_) {
// TODO(mhashmi): Change port if more than one inspectable clients // TODO(mhashmi): Change port if more than one inspectable clients
server.reset(new UiDevToolsServer(enable_devtools_flag, default_port)); int port = GetUiDevToolsPort(enable_devtools_flag, default_port);
server->Start(network_context, "0.0.0.0"); server = base::WrapUnique(new UiDevToolsServer(port, kUIDevtoolsServerTag));
network::mojom::TCPServerSocketPtr server_socket;
CreateTCPServerSocket(mojo::MakeRequest(&server_socket), network_context,
port, kUIDevtoolsServerTag,
base::BindOnce(&UiDevToolsServer::MakeServer,
server->weak_ptr_factory_.GetWeakPtr(),
std::move(server_socket)));
} }
return server; return server;
} }
// static
std::unique_ptr<UiDevToolsServer> UiDevToolsServer::CreateForViz(
network::mojom::TCPServerSocketPtr server_socket,
int port) {
auto server =
base::WrapUnique(new UiDevToolsServer(port, kVizDevtoolsServerTag));
server->MakeServer(std::move(server_socket), net::OK, base::nullopt);
return server;
}
// static
void UiDevToolsServer::CreateTCPServerSocket(
network::mojom::TCPServerSocketRequest server_socket_request,
network::mojom::NetworkContext* network_context,
int port,
net::NetworkTrafficAnnotationTag tag,
network::mojom::NetworkContext::CreateTCPServerSocketCallback callback) {
// Create the socket using the address 0.0.0.0 to listen on all interfaces.
net::IPAddress address(0, 0, 0, 0);
constexpr int kBacklog = 1;
network_context->CreateTCPServerSocket(
net::IPEndPoint(address, port), kBacklog,
net::MutableNetworkTrafficAnnotationTag(tag),
std::move(server_socket_request), std::move(callback));
}
// static // static
std::vector<UiDevToolsServer::NameUrlPair> std::vector<UiDevToolsServer::NameUrlPair>
UiDevToolsServer::GetClientNamesAndUrls() { UiDevToolsServer::GetClientNamesAndUrls() {
...@@ -113,6 +153,19 @@ UiDevToolsServer::GetClientNamesAndUrls() { ...@@ -113,6 +153,19 @@ UiDevToolsServer::GetClientNamesAndUrls() {
return pairs; return pairs;
} }
// static
int UiDevToolsServer::GetUiDevToolsPort(const char* enable_devtools_flag,
int default_port) {
DCHECK(IsDevToolsEnabled(enable_devtools_flag));
std::string switch_value =
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
enable_devtools_flag);
int port;
if (!base::StringToInt(switch_value, &port))
return default_port;
return port;
}
void UiDevToolsServer::AttachClient(std::unique_ptr<UiDevToolsClient> client) { void UiDevToolsServer::AttachClient(std::unique_ptr<UiDevToolsClient> client) {
DCHECK_CALLED_ON_VALID_SEQUENCE(devtools_server_sequence_); DCHECK_CALLED_ON_VALID_SEQUENCE(devtools_server_sequence_);
clients_.push_back(std::move(client)); clients_.push_back(std::move(client));
...@@ -121,28 +174,7 @@ void UiDevToolsServer::AttachClient(std::unique_ptr<UiDevToolsClient> client) { ...@@ -121,28 +174,7 @@ void UiDevToolsServer::AttachClient(std::unique_ptr<UiDevToolsClient> client) {
void UiDevToolsServer::SendOverWebSocket(int connection_id, void UiDevToolsServer::SendOverWebSocket(int connection_id,
const String& message) { const String& message) {
DCHECK_CALLED_ON_VALID_SEQUENCE(devtools_server_sequence_); DCHECK_CALLED_ON_VALID_SEQUENCE(devtools_server_sequence_);
server_->SendOverWebSocket(connection_id, message, kUIDevtoolsServer); server_->SendOverWebSocket(connection_id, message, tag_);
}
void UiDevToolsServer::Start(network::mojom::NetworkContext* network_context,
const std::string& address_string) {
DCHECK_CALLED_ON_VALID_SEQUENCE(devtools_server_sequence_);
DCHECK(!server_);
network::mojom::TCPServerSocketPtr server_socket;
net::IPAddress address;
if (!address.AssignFromIPLiteral(address_string))
return;
constexpr int kBacklog = 1;
auto request = mojo::MakeRequest(&server_socket);
network_context->CreateTCPServerSocket(
net::IPEndPoint(address, port_), kBacklog,
net::MutableNetworkTrafficAnnotationTag(kUIDevtoolsServer),
std::move(request),
base::BindOnce(&UiDevToolsServer::MakeServer,
weak_ptr_factory_.GetWeakPtr(), std::move(server_socket)));
} }
void UiDevToolsServer::MakeServer( void UiDevToolsServer::MakeServer(
...@@ -183,7 +215,7 @@ void UiDevToolsServer::OnWebSocketRequest( ...@@ -183,7 +215,7 @@ void UiDevToolsServer::OnWebSocketRequest(
return; return;
client->set_connection_id(connection_id); client->set_connection_id(connection_id);
connections_[connection_id] = client; connections_[connection_id] = client;
server_->AcceptWebSocket(connection_id, info, kUIDevtoolsServer); server_->AcceptWebSocket(connection_id, info, tag_);
} }
void UiDevToolsServer::OnWebSocketMessage(int connection_id, void UiDevToolsServer::OnWebSocketMessage(int connection_id,
......
...@@ -24,30 +24,50 @@ namespace ui_devtools { ...@@ -24,30 +24,50 @@ namespace ui_devtools {
class UI_DEVTOOLS_EXPORT UiDevToolsServer class UI_DEVTOOLS_EXPORT UiDevToolsServer
: public network::server::HttpServer::Delegate { : public network::server::HttpServer::Delegate {
public: public:
// Network tags to be used for the UI and the Viz devtools servers.
static const net::NetworkTrafficAnnotationTag kUIDevtoolsServerTag;
static const net::NetworkTrafficAnnotationTag kVizDevtoolsServerTag;
~UiDevToolsServer() override; ~UiDevToolsServer() override;
// Returns an empty unique_ptr if ui devtools flag isn't enabled or if a // Returns an empty unique_ptr if ui devtools flag isn't enabled or if a
// server instance has already been created. Server doesn't know anything // server instance has already been created.
// about the caller, so both UI and Viz pass their corresponding params. static std::unique_ptr<UiDevToolsServer> CreateForViews(
static std::unique_ptr<UiDevToolsServer> Create(
network::mojom::NetworkContext* network_context, network::mojom::NetworkContext* network_context,
const char* enable_devtools_flag, const char* enable_devtools_flag,
int default_port); int default_port);
// Assumes that the devtools flag is enabled, and was checked when the socket
// was created.
static std::unique_ptr<UiDevToolsServer> CreateForViz(
network::mojom::TCPServerSocketPtr server_socket,
int port);
// Creates a TCPServerSocket to be used by a UiDevToolsServer.
static void CreateTCPServerSocket(
network::mojom::TCPServerSocketRequest server_socket_request,
network::mojom::NetworkContext* network_context,
int port,
net::NetworkTrafficAnnotationTag tag,
network::mojom::NetworkContext::CreateTCPServerSocketCallback callback);
// Returns a list of attached UiDevToolsClient name + URL // Returns a list of attached UiDevToolsClient name + URL
using NameUrlPair = std::pair<std::string, std::string>; using NameUrlPair = std::pair<std::string, std::string>;
static std::vector<NameUrlPair> GetClientNamesAndUrls(); static std::vector<NameUrlPair> GetClientNamesAndUrls();
// Returns the port number specified by a command line flag. If a number is
// not specified as a command line argument, returns the |default_port|.
static int GetUiDevToolsPort(const char* enable_devtools_flag,
int default_port);
void AttachClient(std::unique_ptr<UiDevToolsClient> client); void AttachClient(std::unique_ptr<UiDevToolsClient> client);
void SendOverWebSocket(int connection_id, const String& message); void SendOverWebSocket(int connection_id, const String& message);
int port() const { return port_; } int port() const { return port_; }
private: private:
UiDevToolsServer(const char* enable_devtools_flag, int default_port); UiDevToolsServer(int port, const net::NetworkTrafficAnnotationTag tag);
void Start(network::mojom::NetworkContext* network_context,
const std::string& address_string);
void MakeServer(network::mojom::TCPServerSocketPtr server_socket, void MakeServer(network::mojom::TCPServerSocketPtr server_socket,
int result, int result,
const base::Optional<net::IPEndPoint>& local_addr); const base::Optional<net::IPEndPoint>& local_addr);
...@@ -73,6 +93,8 @@ class UI_DEVTOOLS_EXPORT UiDevToolsServer ...@@ -73,6 +93,8 @@ class UI_DEVTOOLS_EXPORT UiDevToolsServer
// The port the devtools server listens on // The port the devtools server listens on
const int port_; const int port_;
const net::NetworkTrafficAnnotationTag tag_;
// The server (owned by ash for now) // The server (owned by ash for now)
static UiDevToolsServer* devtools_server_; static UiDevToolsServer* devtools_server_;
......
...@@ -28,6 +28,11 @@ SurfaceElement::SurfaceElement(const viz::SurfaceId& surface_id, ...@@ -28,6 +28,11 @@ SurfaceElement::SurfaceElement(const viz::SurfaceId& surface_id,
SurfaceElement::~SurfaceElement() = default; SurfaceElement::~SurfaceElement() = default;
std::vector<std::pair<std::string, std::string>>
SurfaceElement::GetCustomProperties() const {
return {};
}
void SurfaceElement::GetBounds(gfx::Rect* bounds) const { void SurfaceElement::GetBounds(gfx::Rect* bounds) const {
// We cannot really know real bounds on the surface unless we do // We cannot really know real bounds on the surface unless we do
// aggregation. Here we just return size of the surface. // aggregation. Here we just return size of the surface.
...@@ -68,4 +73,4 @@ const viz::SurfaceId& SurfaceElement::From(const UIElement* element) { ...@@ -68,4 +73,4 @@ const viz::SurfaceId& SurfaceElement::From(const UIElement* element) {
return static_cast<const SurfaceElement*>(element)->surface_id_; return static_cast<const SurfaceElement*>(element)->surface_id_;
} }
} // namespace ui_devtools } // namespace ui_devtools
\ No newline at end of file
...@@ -48,4 +48,4 @@ class SurfaceElement : public UIElement { ...@@ -48,4 +48,4 @@ class SurfaceElement : public UIElement {
} // namespace ui_devtools } // namespace ui_devtools
#endif // COMPONENTS_UI_DEVTOOLS_VIZ_VIEWS_SURFACE_ELEMENT_H_ #endif // COMPONENTS_UI_DEVTOOLS_VIZ_VIEWS_SURFACE_ELEMENT_H_
\ No newline at end of file
...@@ -149,8 +149,6 @@ viz_component("service") { ...@@ -149,8 +149,6 @@ viz_component("service") {
"hit_test/hit_test_aggregator_delegate.h", "hit_test/hit_test_aggregator_delegate.h",
"hit_test/hit_test_manager.cc", "hit_test/hit_test_manager.cc",
"hit_test/hit_test_manager.h", "hit_test/hit_test_manager.h",
"main/viz_compositor_thread_runner.cc",
"main/viz_compositor_thread_runner.h",
"surfaces/latest_local_surface_id_lookup_delegate.h", "surfaces/latest_local_surface_id_lookup_delegate.h",
"surfaces/referenced_surface_tracker.cc", "surfaces/referenced_surface_tracker.cc",
"surfaces/referenced_surface_tracker.h", "surfaces/referenced_surface_tracker.h",
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
# found in the LICENSE file. # found in the LICENSE file.
import("//build/config/ui.gni") import("//build/config/ui.gni")
import("//components/ui_devtools/devtools.gni")
import("//media/gpu/args.gni") import("//media/gpu/args.gni")
import("//services/catalog/public/tools/catalog.gni") import("//services/catalog/public/tools/catalog.gni")
import("//services/service_manager/public/service_manifest.gni") import("//services/service_manager/public/service_manifest.gni")
...@@ -11,7 +12,11 @@ import("//testing/test.gni") ...@@ -11,7 +12,11 @@ import("//testing/test.gni")
source_set("main") { source_set("main") {
output_name = "viz_main_impl" output_name = "viz_main_impl"
defines = []
sources = [ sources = [
"viz_compositor_thread_runner.cc",
"viz_compositor_thread_runner.h",
"viz_main_impl.cc", "viz_main_impl.cc",
"viz_main_impl.h", "viz_main_impl.h",
] ]
...@@ -20,6 +25,8 @@ source_set("main") { ...@@ -20,6 +25,8 @@ source_set("main") {
"//cc", "//cc",
"//components/discardable_memory/client", "//components/discardable_memory/client",
"//components/discardable_memory/public/interfaces", "//components/discardable_memory/public/interfaces",
"//components/ui_devtools",
"//components/ui_devtools/viz_views",
"//components/viz/service", "//components/viz/service",
"//gpu/ipc:gl_in_process_context", "//gpu/ipc:gl_in_process_context",
"//gpu/ipc/common", "//gpu/ipc/common",
...@@ -35,6 +42,10 @@ source_set("main") { ...@@ -35,6 +42,10 @@ source_set("main") {
"//ui/gl/init", "//ui/gl/init",
] ]
public_deps = [
"//services/network/public/mojom",
]
if (use_ozone) { if (use_ozone) {
deps += [ "//ui/ozone:ozone" ] deps += [ "//ui/ozone:ozone" ]
} }
...@@ -46,4 +57,8 @@ source_set("main") { ...@@ -46,4 +57,8 @@ source_set("main") {
if (use_vaapi) { if (use_vaapi) {
deps += [ "//media/gpu/vaapi" ] deps += [ "//media/gpu/vaapi" ]
} }
if (use_viz_devtools) {
defines += [ "USE_VIZ_DEVTOOLS" ]
}
} }
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
include_rules = [ include_rules = [
"+components/discardable_memory/client", "+components/discardable_memory/client",
"+components/ui_devtools",
"+components/viz/common/switches.h", "+components/viz/common/switches.h",
"+components/viz/service", "+components/viz/service",
"+gpu/command_buffer", "+gpu/command_buffer",
...@@ -12,6 +13,7 @@ include_rules = [ ...@@ -12,6 +13,7 @@ include_rules = [
"+media/gpu", "+media/gpu",
"+mojo/public/cpp", "+mojo/public/cpp",
"+services/metrics/public", "+services/metrics/public",
"+services/network/public/mojom",
"+services/service_manager/public/cpp", "+services/service_manager/public/cpp",
"+services/viz/privileged/interfaces", "+services/viz/privileged/interfaces",
] ]
...@@ -22,6 +22,13 @@ ...@@ -22,6 +22,13 @@
#include "gpu/ipc/service/gpu_memory_buffer_factory.h" #include "gpu/ipc/service/gpu_memory_buffer_factory.h"
#include "ui/gfx/switches.h" #include "ui/gfx/switches.h"
#if defined(USE_VIZ_DEVTOOLS)
#include "components/ui_devtools/css_agent.h"
#include "components/ui_devtools/devtools_server.h"
#include "components/ui_devtools/viz_views/dom_agent_viz.h"
#include "components/ui_devtools/viz_views/overlay_agent_viz.h"
#endif
namespace viz { namespace viz {
namespace { namespace {
...@@ -146,8 +153,37 @@ void VizCompositorThreadRunner::CreateFrameSinkManagerOnCompositorThread( ...@@ -146,8 +153,37 @@ void VizCompositorThreadRunner::CreateFrameSinkManagerOnCompositorThread(
std::move(params->frame_sink_manager), nullptr, std::move(params->frame_sink_manager), nullptr,
mojom::FrameSinkManagerClientPtr( mojom::FrameSinkManagerClientPtr(
std::move(params->frame_sink_manager_client))); std::move(params->frame_sink_manager_client)));
#if defined(USE_VIZ_DEVTOOLS)
if (params->devtools_server_socket) {
InitVizDevToolsOnCompositorThread(
network::mojom::TCPServerSocketPtr(
std::move(params->devtools_server_socket)),
params->server_port);
}
#endif
} }
#if defined(USE_VIZ_DEVTOOLS)
void VizCompositorThreadRunner::InitVizDevToolsOnCompositorThread(
network::mojom::TCPServerSocketPtr server_socket,
int port) {
devtools_server_ = ui_devtools::UiDevToolsServer::CreateForViz(
std::move(server_socket), port);
auto dom_agent =
std::make_unique<ui_devtools::DOMAgentViz>(frame_sink_manager_.get());
auto css_agent = std::make_unique<ui_devtools::CSSAgent>(dom_agent.get());
auto overlay_agent =
std::make_unique<ui_devtools::OverlayAgentViz>(dom_agent.get());
auto devtools_client = std::make_unique<ui_devtools::UiDevToolsClient>(
"VizDevToolsClient", devtools_server_.get());
devtools_client->AddAgent(std::move(dom_agent));
devtools_client->AddAgent(std::move(css_agent));
devtools_client->AddAgent(std::move(overlay_agent));
devtools_server_->AttachClient(std::move(devtools_client));
}
#endif
void VizCompositorThreadRunner::CleanupForShutdownOnCompositorThread() { void VizCompositorThreadRunner::CleanupForShutdownOnCompositorThread() {
DCHECK(task_runner_->BelongsToCurrentThread()); DCHECK(task_runner_->BelongsToCurrentThread());
...@@ -163,6 +199,9 @@ void VizCompositorThreadRunner::TearDownOnCompositorThread() { ...@@ -163,6 +199,9 @@ void VizCompositorThreadRunner::TearDownOnCompositorThread() {
server_shared_bitmap_manager_.get()); server_shared_bitmap_manager_.get());
} }
#if defined(USE_VIZ_DEVTOOLS)
devtools_server_.reset();
#endif
frame_sink_manager_.reset(); frame_sink_manager_.reset();
display_provider_.reset(); display_provider_.reset();
server_shared_bitmap_manager_.reset(); server_shared_bitmap_manager_.reset();
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/scoped_refptr.h" #include "base/memory/scoped_refptr.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/viz/service/viz_service_export.h" #include "services/network/public/mojom/tcp_socket.mojom.h"
#include "services/viz/privileged/interfaces/viz_main.mojom.h" #include "services/viz/privileged/interfaces/viz_main.mojom.h"
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
...@@ -28,6 +28,10 @@ class GpuChannelManager; ...@@ -28,6 +28,10 @@ class GpuChannelManager;
class ImageFactory; class ImageFactory;
} // namespace gpu } // namespace gpu
namespace ui_devtools {
class UiDevToolsServer;
} // namespace ui_devtools
namespace viz { namespace viz {
class DisplayProvider; class DisplayProvider;
class FrameSinkManagerImpl; class FrameSinkManagerImpl;
...@@ -44,7 +48,7 @@ using VizCompositorThreadType = base::Thread; ...@@ -44,7 +48,7 @@ using VizCompositorThreadType = base::Thread;
// object is constructed. Objects on the thread will be initialized after // object is constructed. Objects on the thread will be initialized after
// calling CreateFrameSinkManager(). Destructor will teardown objects on thread // calling CreateFrameSinkManager(). Destructor will teardown objects on thread
// and then stop the thread. // and then stop the thread.
class VIZ_SERVICE_EXPORT VizCompositorThreadRunner { class VizCompositorThreadRunner {
public: public:
VizCompositorThreadRunner(); VizCompositorThreadRunner();
// Performs teardown on thread and then stops thread. // Performs teardown on thread and then stops thread.
...@@ -81,6 +85,11 @@ class VIZ_SERVICE_EXPORT VizCompositorThreadRunner { ...@@ -81,6 +85,11 @@ class VIZ_SERVICE_EXPORT VizCompositorThreadRunner {
GpuServiceImpl* gpu_service, GpuServiceImpl* gpu_service,
gpu::ImageFactory* image_factory, gpu::ImageFactory* image_factory,
gpu::GpuChannelManager* gpu_channel_manager); gpu::GpuChannelManager* gpu_channel_manager);
#if defined(USE_VIZ_DEVTOOLS)
void InitVizDevToolsOnCompositorThread(
network::mojom::TCPServerSocketPtr server_socket,
int port);
#endif
void CleanupForShutdownOnCompositorThread(); void CleanupForShutdownOnCompositorThread();
void TearDownOnCompositorThread(); void TearDownOnCompositorThread();
...@@ -88,6 +97,9 @@ class VIZ_SERVICE_EXPORT VizCompositorThreadRunner { ...@@ -88,6 +97,9 @@ class VIZ_SERVICE_EXPORT VizCompositorThreadRunner {
std::unique_ptr<ServerSharedBitmapManager> server_shared_bitmap_manager_; std::unique_ptr<ServerSharedBitmapManager> server_shared_bitmap_manager_;
std::unique_ptr<DisplayProvider> display_provider_; std::unique_ptr<DisplayProvider> display_provider_;
std::unique_ptr<FrameSinkManagerImpl> frame_sink_manager_; std::unique_ptr<FrameSinkManagerImpl> frame_sink_manager_;
#if defined(USE_VIZ_DEVTOOLS)
std::unique_ptr<ui_devtools::UiDevToolsServer> devtools_server_;
#endif
// End variables to be accessed only on |task_runner_|. // End variables to be accessed only on |task_runner_|.
std::unique_ptr<VizCompositorThreadType> thread_; std::unique_ptr<VizCompositorThreadType> thread_;
......
...@@ -66,6 +66,7 @@ jumbo_source_set("browser") { ...@@ -66,6 +66,7 @@ jumbo_source_set("browser") {
"//components/viz/common", "//components/viz/common",
"//components/viz/host", "//components/viz/host",
"//components/viz/service", "//components/viz/service",
"//components/viz/service/main",
"//content:resources", "//content:resources",
"//content/app/resources", "//content/app/resources",
"//content/app/strings", "//content/app/strings",
......
...@@ -29,11 +29,14 @@ source_set("lib") { ...@@ -29,11 +29,14 @@ source_set("lib") {
deps = [ deps = [
"//base", "//base",
"//components/viz/service", "//components/viz/service",
"//components/viz/service/main",
"//mojo/public/cpp/system", "//mojo/public/cpp/system",
"//services/service_manager/public/cpp", "//services/service_manager/public/cpp",
"//services/viz/privileged/interfaces", "//services/viz/privileged/interfaces",
] ]
public_deps = [
"//components/viz/service/main",
]
} }
service_manifest("manifest") { service_manifest("manifest") {
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
import("//components/ui_devtools/devtools.gni")
import("//mojo/public/tools/bindings/mojom.gni") import("//mojo/public/tools/bindings/mojom.gni")
mojom("interfaces") { mojom("interfaces") {
...@@ -11,11 +12,17 @@ mojom("interfaces") { ...@@ -11,11 +12,17 @@ mojom("interfaces") {
public_deps = [ public_deps = [
"//components/discardable_memory/public/interfaces", "//components/discardable_memory/public/interfaces",
"//services/network/public/mojom",
"//services/viz/privileged/interfaces/compositing", "//services/viz/privileged/interfaces/compositing",
"//services/viz/privileged/interfaces/gl", "//services/viz/privileged/interfaces/gl",
"//services/viz/public/interfaces", "//services/viz/public/interfaces",
"//ui/gfx/mojo", "//ui/gfx/mojo",
] ]
enabled_features = []
if (use_viz_devtools) {
enabled_features += [ "use_viz_devtools" ]
}
} }
source_set("unit_tests") { source_set("unit_tests") {
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
module viz.mojom; module viz.mojom;
import "components/discardable_memory/public/interfaces/discardable_shared_memory_manager.mojom"; import "components/discardable_memory/public/interfaces/discardable_shared_memory_manager.mojom";
import "services/network/public/mojom/tcp_socket.mojom";
import "services/viz/public/interfaces/compositing/compositing_mode_watcher.mojom"; import "services/viz/public/interfaces/compositing/compositing_mode_watcher.mojom";
import "services/viz/privileged/interfaces/compositing/frame_sink_manager.mojom"; import "services/viz/privileged/interfaces/compositing/frame_sink_manager.mojom";
import "services/viz/privileged/interfaces/gl/gpu_host.mojom"; import "services/viz/privileged/interfaces/gl/gpu_host.mojom";
...@@ -27,6 +28,17 @@ struct FrameSinkManagerParams { ...@@ -27,6 +28,17 @@ struct FrameSinkManagerParams {
// Viz to host interface. // Viz to host interface.
FrameSinkManagerClient frame_sink_manager_client; FrameSinkManagerClient frame_sink_manager_client;
// Optional socket for viz devtools server, which is used to observe the
// FrameSinkManager in the viz compositor. This will be null unless the flag
// --enable-viz-devtools is used. If present, the server will be created on
// the viz process using this socket.
[EnableIf=use_viz_devtools]
network.mojom.TCPServerSocket? devtools_server_socket;
// Port the devtools server socket is bound to.
[EnableIf=use_viz_devtools]
uint16 server_port;
}; };
// This is the primordial interface used to (re)start the viz services. // This is the primordial interface used to (re)start the viz services.
......
...@@ -271,6 +271,7 @@ Refer to README.md for content description and update process. ...@@ -271,6 +271,7 @@ Refer to README.md for content description and update process.
<item id="url_fetcher_downloader" hash_code="113231892" type="0" content_hash_code="61085066" os_list="linux,windows" file_path="components/update_client/url_fetcher_downloader.cc"/> <item id="url_fetcher_downloader" hash_code="113231892" type="0" content_hash_code="61085066" os_list="linux,windows" file_path="components/update_client/url_fetcher_downloader.cc"/>
<item id="url_prevision_fetcher" hash_code="118389509" type="0" content_hash_code="66145513" os_list="linux,windows" file_path="content/browser/media/url_provision_fetcher.cc"/> <item id="url_prevision_fetcher" hash_code="118389509" type="0" content_hash_code="66145513" os_list="linux,windows" file_path="content/browser/media/url_provision_fetcher.cc"/>
<item id="user_info_fetcher" hash_code="22265491" type="0" content_hash_code="72016232" os_list="linux,windows" file_path="components/policy/core/common/cloud/user_info_fetcher.cc"/> <item id="user_info_fetcher" hash_code="22265491" type="0" content_hash_code="72016232" os_list="linux,windows" file_path="components/policy/core/common/cloud/user_info_fetcher.cc"/>
<item id="viz_devtools_server" hash_code="16292315" type="0" content_hash_code="70061664" os_list="linux,windows" file_path="components/ui_devtools/devtools_server.cc"/>
<item id="web_history_counter" hash_code="137457845" type="1" second_id="110307337" content_hash_code="49663381" os_list="linux,windows" semantics_fields="2,3,4" policy_fields="4" file_path="components/browsing_data/core/counters/history_counter.cc"/> <item id="web_history_counter" hash_code="137457845" type="1" second_id="110307337" content_hash_code="49663381" os_list="linux,windows" semantics_fields="2,3,4" policy_fields="4" file_path="components/browsing_data/core/counters/history_counter.cc"/>
<item id="web_history_expire" hash_code="60946824" type="1" second_id="110307337" content_hash_code="92626030" os_list="linux,windows" semantics_fields="2,3,4" policy_fields="4" file_path="components/history/core/browser/browsing_history_service.cc"/> <item id="web_history_expire" hash_code="60946824" type="1" second_id="110307337" content_hash_code="92626030" os_list="linux,windows" semantics_fields="2,3,4" policy_fields="4" file_path="components/history/core/browser/browsing_history_service.cc"/>
<item id="web_history_expire_between_dates" hash_code="126122632" type="1" second_id="110307337" content_hash_code="34304787" os_list="linux,windows" semantics_fields="2,3,4" policy_fields="4" file_path="components/history/core/browser/history_service.cc"/> <item id="web_history_expire_between_dates" hash_code="126122632" type="1" second_id="110307337" content_hash_code="34304787" os_list="linux,windows" semantics_fields="2,3,4" policy_fields="4" file_path="components/history/core/browser/history_service.cc"/>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment