Commit 35074422 authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

Renames WindowData to ClientWindow

In hopes of better describinging what this class is for.

BUG=none
TEST=none

Change-Id: I9611dfa0d74b3ef788381436e6f18cce167a41c9
Reviewed-on: https://chromium-review.googlesource.com/1050878
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: default avatarMichael Wasserman <msw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#557089}
parent bbdc8049
......@@ -10,32 +10,30 @@ import("//services/service_manager/public/service_manifest.gni")
import("//services/service_manager/public/tools/test/service_test.gni")
component("lib") {
public = [
"gpu_support.h",
"ids.h",
"window_service.h",
"window_service_client.h",
"window_service_client_binding.h",
"window_service_delegate.h",
"window_tree_factory.h",
]
sources = [
"client_change.cc",
"client_change.h",
"client_change_tracker.cc",
"client_change_tracker.h",
# TODO: client_root should be internal and moved to a different target.
"client_root.cc",
"client_root.h",
"gpu_support.h",
"ids.h",
# TODO: window_data should be internal and moved to a different target.
"window_data.cc",
"window_data.h",
"client_window.cc",
"client_window.h",
"window_host_frame_sink_client.cc",
"window_host_frame_sink_client.h",
"window_service.cc",
"window_service.h",
"window_service_client.cc",
"window_service_client.h",
"window_service_client_binding.cc",
"window_service_client_binding.h",
"window_service_delegate.h",
"window_tree_factory.cc",
"window_tree_factory.h",
]
public_deps = [
......
......@@ -6,7 +6,7 @@
#include "services/ui/ws2/client_change.h"
#include "services/ui/ws2/client_change_tracker.h"
#include "services/ui/ws2/window_data.h"
#include "services/ui/ws2/client_window.h"
#include "services/ui/ws2/window_service_client.h"
#include "ui/aura/mus/client_surface_embedder.h"
#include "ui/aura/window.h"
......@@ -21,7 +21,7 @@ ClientRoot::ClientRoot(WindowServiceClient* window_service_client,
: window_service_client_(window_service_client),
window_(window),
is_top_level_(is_top_level) {
WindowData::GetMayBeNull(window)->set_embedded_window_service_client(
ClientWindow::GetMayBeNull(window)->set_embedded_window_service_client(
window_service_client);
window_->AddObserver(this);
// TODO: wire up gfx::Insets() correctly below. See usage in
......@@ -36,14 +36,14 @@ ClientRoot::ClientRoot(WindowServiceClient* window_service_client,
}
ClientRoot::~ClientRoot() {
WindowData::GetMayBeNull(window_)->set_embedded_window_service_client(
ClientWindow::GetMayBeNull(window_)->set_embedded_window_service_client(
nullptr);
window_->RemoveObserver(this);
}
void ClientRoot::FrameSinkIdChanged() {
window_->SetEmbedFrameSinkId(
WindowData::GetMayBeNull(window_)->frame_sink_id());
ClientWindow::GetMayBeNull(window_)->frame_sink_id());
UpdatePrimarySurfaceId();
}
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "services/ui/ws2/window_data.h"
#include "services/ui/ws2/client_window.h"
#include "components/viz/host/host_frame_sink_manager.h"
#include "services/ui/ws2/window_host_frame_sink_client.h"
......@@ -10,35 +10,35 @@
#include "ui/aura/window.h"
#include "ui/compositor/compositor.h"
DEFINE_UI_CLASS_PROPERTY_TYPE(ui::ws2::WindowData*);
DEFINE_UI_CLASS_PROPERTY_TYPE(ui::ws2::ClientWindow*);
namespace ui {
namespace ws2 {
namespace {
DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(ui::ws2::WindowData,
kWindowDataKey,
DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(ui::ws2::ClientWindow,
kClientWindowKey,
nullptr);
} // namespace
WindowData::~WindowData() = default;
ClientWindow::~ClientWindow() = default;
// static
WindowData* WindowData::Create(aura::Window* window,
WindowServiceClient* client,
const viz::FrameSinkId& frame_sink_id) {
ClientWindow* ClientWindow::Create(aura::Window* window,
WindowServiceClient* client,
const viz::FrameSinkId& frame_sink_id) {
DCHECK(!GetMayBeNull(window));
// Owned by |window|.
WindowData* data = new WindowData(window, client, frame_sink_id);
window->SetProperty(kWindowDataKey, data);
return data;
ClientWindow* client_window = new ClientWindow(window, client, frame_sink_id);
window->SetProperty(kClientWindowKey, client_window);
return client_window;
}
// static
const WindowData* WindowData::GetMayBeNull(const aura::Window* window) {
return window->GetProperty(kWindowDataKey);
const ClientWindow* ClientWindow::GetMayBeNull(const aura::Window* window) {
return window->GetProperty(kClientWindowKey);
}
void WindowData::SetFrameSinkId(const viz::FrameSinkId& frame_sink_id) {
void ClientWindow::SetFrameSinkId(const viz::FrameSinkId& frame_sink_id) {
frame_sink_id_ = frame_sink_id;
viz::HostFrameSinkManager* host_frame_sink_manager =
aura::Env::GetInstance()
......@@ -61,7 +61,7 @@ void WindowData::SetFrameSinkId(const viz::FrameSinkId& frame_sink_id) {
window_host_frame_sink_client_->OnFrameSinkIdChanged();
}
void WindowData::AttachCompositorFrameSink(
void ClientWindow::AttachCompositorFrameSink(
viz::mojom::CompositorFrameSinkRequest compositor_frame_sink,
viz::mojom::CompositorFrameSinkClientPtr client) {
viz::HostFrameSinkManager* host_frame_sink_manager =
......@@ -72,9 +72,9 @@ void WindowData::AttachCompositorFrameSink(
frame_sink_id_, std::move(compositor_frame_sink), std::move(client));
}
WindowData::WindowData(aura::Window* window,
WindowServiceClient* client,
const viz::FrameSinkId& frame_sink_id)
ClientWindow::ClientWindow(aura::Window* window,
WindowServiceClient* client,
const viz::FrameSinkId& frame_sink_id)
: window_(window),
owning_window_service_client_(client),
frame_sink_id_(frame_sink_id) {}
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SERVICES_UI_WS2_WINDOW_DATA_H_
#define SERVICES_UI_WS2_WINDOW_DATA_H_
#ifndef SERVICES_UI_WS2_CLIENT_WINDOW_H_
#define SERVICES_UI_WS2_CLIENT_WINDOW_H_
#include "base/component_export.h"
#include "base/macros.h"
......@@ -22,24 +22,24 @@ class WindowHostFrameSinkClient;
class WindowServiceClient;
// Tracks any state associated with an aura::Window for the WindowService.
// WindowData is created for every window created at the request of a client,
// ClientWindow is created for every window created at the request of a client,
// including the root window of ClientRoots.
class COMPONENT_EXPORT(WINDOW_SERVICE) WindowData {
class COMPONENT_EXPORT(WINDOW_SERVICE) ClientWindow {
public:
~WindowData();
~ClientWindow();
// Creates a new WindowData. The lifetime of the WindowData is tied to that
// of the Window (the Window ends up owning the WindowData).
static WindowData* Create(aura::Window* window,
WindowServiceClient* client,
const viz::FrameSinkId& frame_sink_id);
// Creates a new ClientWindow. The lifetime of the ClientWindow is tied to
// that of the Window (the Window ends up owning the ClientWindow).
static ClientWindow* Create(aura::Window* window,
WindowServiceClient* client,
const viz::FrameSinkId& frame_sink_id);
// Returns the WindowData associated with a window, null if not created yet.
static WindowData* GetMayBeNull(aura::Window* window) {
return const_cast<WindowData*>(
// Returns the ClientWindow associated with a window, null if not created yet.
static ClientWindow* GetMayBeNull(aura::Window* window) {
return const_cast<ClientWindow*>(
GetMayBeNull(const_cast<const aura::Window*>(window)));
}
static const WindowData* GetMayBeNull(const aura::Window* window);
static const ClientWindow* GetMayBeNull(const aura::Window* window);
WindowServiceClient* owning_window_service_client() {
return owning_window_service_client_;
......@@ -66,9 +66,9 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) WindowData {
viz::mojom::CompositorFrameSinkClientPtr client);
private:
WindowData(aura::Window*,
WindowServiceClient* client,
const viz::FrameSinkId& frame_sink_id);
ClientWindow(aura::Window*,
WindowServiceClient* client,
const viz::FrameSinkId& frame_sink_id);
aura::Window* window_;
......@@ -99,10 +99,10 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) WindowData {
// window.
std::unique_ptr<WindowHostFrameSinkClient> window_host_frame_sink_client_;
DISALLOW_COPY_AND_ASSIGN(WindowData);
DISALLOW_COPY_AND_ASSIGN(ClientWindow);
};
} // namespace ws2
} // namespace ui
#endif // SERVICES_UI_WS2_WINDOW_DATA_H_
#endif // SERVICES_UI_WS2_CLIENT_WINDOW_H_
......@@ -5,7 +5,6 @@
#include "services/ui/ws2/window_host_frame_sink_client.h"
#include "base/logging.h"
#include "services/ui/ws2/window_data.h"
#include "ui/aura/mus/client_surface_embedder.h"
namespace ui {
......
......@@ -6,8 +6,8 @@
#include "base/bind.h"
#include "base/single_thread_task_runner.h"
#include "services/ui/ws2/client_window.h"
#include "services/ui/ws2/gpu_support.h"
#include "services/ui/ws2/window_data.h"
#include "services/ui/ws2/window_service_client.h"
#include "services/ui/ws2/window_service_delegate.h"
#include "services/ui/ws2/window_tree_factory.h"
......@@ -26,16 +26,16 @@ WindowService::WindowService(WindowServiceDelegate* delegate,
WindowService::~WindowService() {}
WindowData* WindowService::GetWindowDataForWindowCreateIfNecessary(
ClientWindow* WindowService::GetClientWindowForWindowCreateIfNecessary(
aura::Window* window) {
WindowData* data = WindowData::GetMayBeNull(window);
if (data)
return data;
ClientWindow* client_window = ClientWindow::GetMayBeNull(window);
if (client_window)
return client_window;
const viz::FrameSinkId frame_sink_id =
ClientWindowId(kWindowServerClientId, next_window_id_++);
CHECK_NE(0u, next_window_id_);
return WindowData::Create(window, nullptr, frame_sink_id);
return ClientWindow::Create(window, nullptr, frame_sink_id);
}
std::unique_ptr<WindowServiceClient> WindowService::CreateWindowServiceClient(
......
......@@ -29,8 +29,8 @@ class WindowTreeClient;
namespace ws2 {
class ClientWindow;
class GpuSupport;
class WindowData;
class WindowServiceClient;
class WindowServiceDelegate;
class WindowTreeFactory;
......@@ -47,8 +47,8 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) WindowService
std::unique_ptr<GpuSupport> gpu_support);
~WindowService() override;
// Gets the WindowData for |window|, creating if necessary.
WindowData* GetWindowDataForWindowCreateIfNecessary(aura::Window* window);
// Gets the ClientWindow for |window|, creating if necessary.
ClientWindow* GetClientWindowForWindowCreateIfNecessary(aura::Window* window);
// Creates a new WindowServiceClient, caller must call one of the Init()
// functions on the returned object.
......
......@@ -12,7 +12,7 @@
#include "services/ui/ws2/client_change.h"
#include "services/ui/ws2/client_change_tracker.h"
#include "services/ui/ws2/client_root.h"
#include "services/ui/ws2/window_data.h"
#include "services/ui/ws2/client_window.h"
#include "services/ui/ws2/window_service.h"
#include "services/ui/ws2/window_service_client_binding.h"
#include "services/ui/ws2/window_service_delegate.h"
......@@ -40,10 +40,10 @@ WindowServiceClient::WindowServiceClient(WindowService* window_service,
void WindowServiceClient::InitForEmbed(aura::Window* root,
mojom::WindowTreePtr window_tree_ptr) {
// Force WindowData to be created for |root|.
WindowData* window_data =
window_service_->GetWindowDataForWindowCreateIfNecessary(root);
const ClientWindowId client_window_id = window_data->frame_sink_id();
// Force ClientWindow to be created for |root|.
ClientWindow* client_window =
window_service_->GetClientWindowForWindowCreateIfNecessary(root);
const ClientWindowId client_window_id = client_window->frame_sink_id();
AddWindowToKnownWindows(root, client_window_id);
CreateClientRoot(root, std::move(window_tree_ptr));
......@@ -78,9 +78,9 @@ ClientRoot* WindowServiceClient::CreateClientRoot(
mojom::WindowTreePtr window_tree) {
OnWillBecomeClientRootWindow(window);
WindowData* window_data = WindowData::GetMayBeNull(window);
DCHECK(window_data);
const ClientWindowId client_window_id = window_data->frame_sink_id();
ClientWindow* client_window = ClientWindow::GetMayBeNull(window);
DCHECK(client_window);
const ClientWindowId client_window_id = client_window->frame_sink_id();
const bool for_embed = window_tree.is_bound();
......@@ -103,7 +103,7 @@ ClientRoot* WindowServiceClient::CreateClientRoot(
// Reset the frame sink id locally (after calling OnEmbed()). This is
// needed so that the id used by the client matches the id used locally.
window_data->SetFrameSinkId(ClientWindowId(client_id_, 0));
client_window->SetFrameSinkId(ClientWindowId(client_id_, 0));
}
// TODO(sky): centralize FrameSinkId management.
......@@ -114,7 +114,7 @@ ClientRoot* WindowServiceClient::CreateClientRoot(
// TODO(sky): centralize FrameSinkId management.
window_tree_client_->OnFrameSinkIdAllocated(
ClientWindowIdToTransportId(client_window_id),
window_data->frame_sink_id());
client_window->frame_sink_id());
}
return client_root;
......@@ -159,16 +159,16 @@ void WindowServiceClient::DeleteClientRoot(ClientRoot* client_root,
if (reason == DeleteClientRootReason::kUnembed) {
// Notify the owner of the window it no longer has a client embedded in it.
WindowData* window_data = WindowData::GetMayBeNull(window);
if (window_data->owning_window_service_client() &&
window_data->owning_window_service_client() != this) {
// ClientRoots always trigger creation of a WindowData, so |window_data|
// must exist at this point.
DCHECK(window_data);
window_data->owning_window_service_client()
ClientWindow* client_window = ClientWindow::GetMayBeNull(window);
if (client_window->owning_window_service_client() &&
client_window->owning_window_service_client() != this) {
// ClientRoots always trigger creation of a ClientWindow, so
// |client_window| must exist at this point.
DCHECK(client_window);
client_window->owning_window_service_client()
->window_tree_client_->OnEmbeddedAppDisconnected(
window_data->owning_window_service_client()->TransportIdForWindow(
window));
client_window->owning_window_service_client()
->TransportIdForWindow(window));
}
}
}
......@@ -215,10 +215,10 @@ bool WindowServiceClient::IsWindowKnown(aura::Window* window) const {
bool WindowServiceClient::IsWindowRootOfAnotherClient(
aura::Window* window) const {
WindowData* window_data = WindowData::GetMayBeNull(window);
return window_data &&
window_data->embedded_window_service_client() != nullptr &&
window_data->embedded_window_service_client() != this;
ClientWindow* client_window = ClientWindow::GetMayBeNull(window);
return client_window &&
client_window->embedded_window_service_client() != nullptr &&
client_window->embedded_window_service_client() != this;
}
aura::Window* WindowServiceClient::AddClientCreatedWindow(
......@@ -226,7 +226,7 @@ aura::Window* WindowServiceClient::AddClientCreatedWindow(
std::unique_ptr<aura::Window> window_ptr) {
aura::Window* window = window_ptr.get();
client_created_windows_.insert(std::move(window_ptr));
WindowData::Create(window, this, id);
ClientWindow::Create(window, this, id);
AddWindowToKnownWindows(window, id);
return window;
}
......@@ -320,31 +320,31 @@ mojom::WindowDataPtr WindowServiceClient::WindowToWindowData(
parent = nullptr;
if (!IsWindowKnown(transient_parent))
transient_parent = nullptr;
mojom::WindowDataPtr window_data(mojom::WindowData::New());
window_data->parent_id =
mojom::WindowDataPtr client_window(mojom::WindowData::New());
client_window->parent_id =
parent ? TransportIdForWindow(parent) : kInvalidTransportId;
window_data->window_id =
client_window->window_id =
window ? TransportIdForWindow(window) : kInvalidTransportId;
window_data->transient_parent_id =
client_window->transient_parent_id =
transient_parent ? TransportIdForWindow(transient_parent)
: kInvalidTransportId;
window_data->bounds = window->bounds();
client_window->bounds = window->bounds();
// TODO: use property mapping.
window_data->visible = window->TargetVisibility();
return window_data;
client_window->visible = window->TargetVisibility();
return client_window;
}
void WindowServiceClient::OnWillBecomeClientRootWindow(aura::Window* window) {
DCHECK(window);
// Only one client may be embedded in a window at a time.
WindowData* window_data =
window_service_->GetWindowDataForWindowCreateIfNecessary(window);
if (window_data->embedded_window_service_client()) {
window_data->embedded_window_service_client()->DeleteClientRootWithRoot(
ClientWindow* client_window =
window_service_->GetClientWindowForWindowCreateIfNecessary(window);
if (client_window->embedded_window_service_client()) {
client_window->embedded_window_service_client()->DeleteClientRootWithRoot(
window);
DCHECK(!window_data->embedded_window_service_client());
DCHECK(!client_window->embedded_window_service_client());
}
// Because a new client is being embedded all existing children are removed.
......@@ -670,7 +670,7 @@ void WindowServiceClient::NewTopLevelWindow(
top_level_ptr->set_owned_by_parent(false);
aura::Window* top_level =
AddClientCreatedWindow(client_window_id, std::move(top_level_ptr));
WindowData::GetMayBeNull(top_level)->SetFrameSinkId(client_window_id);
ClientWindow::GetMayBeNull(top_level)->SetFrameSinkId(client_window_id);
const int64_t display_id =
display::Screen::GetScreen()->GetDisplayNearestWindow(top_level).id();
// This passes null for the mojom::WindowTreePtr because the client has
......@@ -775,19 +775,20 @@ void WindowServiceClient::AttachCompositorFrameSink(
DVLOG(1) << "AttachCompositorFrameSink failed (invalid window id)";
return;
}
WindowData* window_data = WindowData::GetMayBeNull(window);
ClientWindow* client_window = ClientWindow::GetMayBeNull(window);
// If this isn't called on the root, then only allow it if there is not
// another client embedded in the window.
const bool allow = IsClientRootWindow(window) ||
(IsClientCreatedWindow(window) &&
window_data->embedded_window_service_client() == nullptr);
const bool allow =
IsClientRootWindow(window) ||
(IsClientCreatedWindow(window) &&
client_window->embedded_window_service_client() == nullptr);
if (!allow) {
DVLOG(1) << "AttachCompositorFrameSink failed (policy disallowed)";
return;
}
window_data->AttachCompositorFrameSink(std::move(compositor_frame_sink),
std::move(client));
client_window->AttachCompositorFrameSink(std::move(compositor_frame_sink),
std::move(client));
}
void WindowServiceClient::AddWindow(uint32_t change_id,
......
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