Commit 6d3311b8 authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

chromeos: provides client-id to clients

The id is necessary for single-process-mash so that the browser process can
know it's id and lookup windows (everything runs in the same process in
single-process-mash). Outside of single-process-mash the id is really only
useful for debugging.

BUG=756085
TEST=covered by tests

Change-Id: I3819c5492fe2bfeeb243c44c36cc948168824ab6
Reviewed-on: https://chromium-review.googlesource.com/c/1318447Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605867}
parent 3cb04205
...@@ -188,6 +188,8 @@ void RendererWindowTreeClient::DestroyFrame(uint32_t frame_routing_id) { ...@@ -188,6 +188,8 @@ void RendererWindowTreeClient::DestroyFrame(uint32_t frame_routing_id) {
pending_frames_.erase(frame_routing_id); pending_frames_.erase(frame_routing_id);
} }
void RendererWindowTreeClient::OnClientId(uint32_t client_id) {}
void RendererWindowTreeClient::OnEmbed( void RendererWindowTreeClient::OnEmbed(
ws::mojom::WindowDataPtr root, ws::mojom::WindowDataPtr root,
ws::mojom::WindowTreePtr tree, ws::mojom::WindowTreePtr tree,
......
...@@ -110,6 +110,7 @@ class RendererWindowTreeClient : public ws::mojom::WindowTreeClient, ...@@ -110,6 +110,7 @@ class RendererWindowTreeClient : public ws::mojom::WindowTreeClient,
// these will remain unimplemented in the long-term. Some of the // these will remain unimplemented in the long-term. Some of the
// implementations would require some amount of refactoring out of // implementations would require some amount of refactoring out of
// RenderWidget and related classes (e.g. resize, input, ime etc.). // RenderWidget and related classes (e.g. resize, input, ime etc.).
void OnClientId(uint32_t client_id) override;
void OnEmbed( void OnEmbed(
ws::mojom::WindowDataPtr root, ws::mojom::WindowDataPtr root,
ws::mojom::WindowTreePtr tree, ws::mojom::WindowTreePtr tree,
......
...@@ -418,6 +418,11 @@ interface WindowTree { ...@@ -418,6 +418,11 @@ interface WindowTree {
// calling SetWindowBounds(), connection 1 does not receive // calling SetWindowBounds(), connection 1 does not receive
// OnWindowBoundsChanged(). // OnWindowBoundsChanged().
interface WindowTreeClient { interface WindowTreeClient {
// Sent when clients establishes a connection to the WindowService.
// |client_id| gives the unique id for the client. This value is generally
// only useful for debugging.
OnClientId(uint32 client_id);
// Invoked when the client application has been embedded at |root|. // Invoked when the client application has been embedded at |root|.
// See Embed() on WindowTree for more details. |tree| will be a handle back to // See Embed() on WindowTree for more details. |tree| will be a handle back to
// the window manager service, unless the connection is to the root connection // the window manager service, unless the connection is to the root connection
......
...@@ -64,6 +64,8 @@ bool TestWindowTreeClient::AckFirstEvent(WindowTree* tree, ...@@ -64,6 +64,8 @@ bool TestWindowTreeClient::AckFirstEvent(WindowTree* tree,
void TestWindowTreeClient::OnChangeAdded() {} void TestWindowTreeClient::OnChangeAdded() {}
void TestWindowTreeClient::OnClientId(uint32_t client_id) {}
void TestWindowTreeClient::OnEmbed( void TestWindowTreeClient::OnEmbed(
mojom::WindowDataPtr root, mojom::WindowDataPtr root,
mojom::WindowTreePtr tree, mojom::WindowTreePtr tree,
......
...@@ -83,6 +83,7 @@ class TestWindowTreeClient : public mojom::WindowTreeClient, ...@@ -83,6 +83,7 @@ class TestWindowTreeClient : public mojom::WindowTreeClient,
void OnChangeAdded() override; void OnChangeAdded() override;
// mojom::WindowTreeClient: // mojom::WindowTreeClient:
void OnClientId(uint32_t client_id) override;
void OnEmbed( void OnEmbed(
mojom::WindowDataPtr root, mojom::WindowDataPtr root,
mojom::WindowTreePtr tree, mojom::WindowTreePtr tree,
......
...@@ -62,6 +62,7 @@ void WindowTreeBinding::CreateBinding( ...@@ -62,6 +62,7 @@ void WindowTreeBinding::CreateBinding(
binding_ = std::make_unique<mojo::Binding<mojom::WindowTree>>( binding_ = std::make_unique<mojo::Binding<mojom::WindowTree>>(
window_tree_.get(), std::move(window_tree_request)); window_tree_.get(), std::move(window_tree_request));
binding_->set_connection_error_handler(std::move(connection_lost_callback)); binding_->set_connection_error_handler(std::move(connection_lost_callback));
window_tree_client_->OnClientId(window_tree_->client_id());
window_tree_client_->GetScreenProviderObserver( window_tree_client_->GetScreenProviderObserver(
MakeRequest(&screen_provider_observer_)); MakeRequest(&screen_provider_observer_));
window_service_->screen_provider()->AddObserver( window_service_->screen_provider()->AddObserver(
......
...@@ -162,6 +162,8 @@ class TestWindowTreeClient2 : public TestWindowTreeClient { ...@@ -162,6 +162,8 @@ class TestWindowTreeClient2 : public TestWindowTreeClient {
binding_.Bind(std::move(request)); binding_.Bind(std::move(request));
} }
ClientSpecificId client_id() const { return client_id_; }
// Runs a nested MessageLoop until |count| changes (calls to // Runs a nested MessageLoop until |count| changes (calls to
// WindowTreeClient functions) have been received. // WindowTreeClient functions) have been received.
void WaitForChangeCount(size_t count) { void WaitForChangeCount(size_t count) {
...@@ -277,6 +279,7 @@ class TestWindowTreeClient2 : public TestWindowTreeClient { ...@@ -277,6 +279,7 @@ class TestWindowTreeClient2 : public TestWindowTreeClient {
}; };
// TestWindowTreeClient: // TestWindowTreeClient:
void OnClientId(ClientSpecificId id) override { client_id_ = id; }
void OnChangeAdded() override { void OnChangeAdded() override {
if (wait_state_.get() && if (wait_state_.get() &&
tracker_.changes()->size() >= wait_state_->change_count) { tracker_.changes()->size() >= wait_state_->change_count) {
...@@ -438,6 +441,7 @@ class TestWindowTreeClient2 : public TestWindowTreeClient { ...@@ -438,6 +441,7 @@ class TestWindowTreeClient2 : public TestWindowTreeClient {
uint32_t waiting_change_id_; uint32_t waiting_change_id_;
bool on_change_completed_result_; bool on_change_completed_result_;
std::unique_ptr<base::RunLoop> change_completed_run_loop_; std::unique_ptr<base::RunLoop> change_completed_run_loop_;
ClientSpecificId client_id_ = 0u;
DISALLOW_COPY_AND_ASSIGN(TestWindowTreeClient2); DISALLOW_COPY_AND_ASSIGN(TestWindowTreeClient2);
}; };
...@@ -635,6 +639,10 @@ class WindowTreeClientTest : public WindowServerServiceTestBase { ...@@ -635,6 +639,10 @@ class WindowTreeClientTest : public WindowServerServiceTestBase {
DISALLOW_COPY_AND_ASSIGN(WindowTreeClientTest); DISALLOW_COPY_AND_ASSIGN(WindowTreeClientTest);
}; };
TEST_F(WindowTreeClientTest, GotClientId) {
EXPECT_NE(0u, wt_client1_->client_id());
}
// Verifies two clients get different ids. // Verifies two clients get different ids.
TEST_F(WindowTreeClientTest, TwoClientsGetDifferentClientIds) { TEST_F(WindowTreeClientTest, TwoClientsGetDifferentClientIds) {
ASSERT_NO_FATAL_FAILURE(EstablishSecondClient(true)); ASSERT_NO_FATAL_FAILURE(EstablishSecondClient(true));
......
...@@ -963,6 +963,10 @@ void WindowTreeClient::SetEventTargetingPolicy( ...@@ -963,6 +963,10 @@ void WindowTreeClient::SetEventTargetingPolicy(
tree_->SetEventTargetingPolicy(window->server_id(), policy); tree_->SetEventTargetingPolicy(window->server_id(), policy);
} }
void WindowTreeClient::OnClientId(uint32_t client_id) {
id_ = client_id;
}
void WindowTreeClient::OnEmbed( void WindowTreeClient::OnEmbed(
ws::mojom::WindowDataPtr root_data, ws::mojom::WindowDataPtr root_data,
ws::mojom::WindowTreePtr tree, ws::mojom::WindowTreePtr tree,
......
...@@ -126,6 +126,8 @@ class AURA_EXPORT WindowTreeClient ...@@ -126,6 +126,8 @@ class AURA_EXPORT WindowTreeClient
// Blocks until the initial screen configuration is received. // Blocks until the initial screen configuration is received.
bool WaitForDisplays(); bool WaitForDisplays();
const base::Optional<uint32_t>& id() const { return id_; }
void SetCanFocus(Window* window, bool can_focus); void SetCanFocus(Window* window, bool can_focus);
void SetCanAcceptDrops(WindowMus* window, bool can_accept_drops); void SetCanAcceptDrops(WindowMus* window, bool can_accept_drops);
void SetEventTargetingPolicy(WindowMus* window, void SetEventTargetingPolicy(WindowMus* window,
...@@ -363,6 +365,7 @@ class AURA_EXPORT WindowTreeClient ...@@ -363,6 +365,7 @@ class AURA_EXPORT WindowTreeClient
std::unique_ptr<ui::PropertyData> data); std::unique_ptr<ui::PropertyData> data);
// Overridden from WindowTreeClient: // Overridden from WindowTreeClient:
void OnClientId(uint32_t client_id) override;
void OnEmbed( void OnEmbed(
ws::mojom::WindowDataPtr root, ws::mojom::WindowDataPtr root,
ws::mojom::WindowTreePtr tree, ws::mojom::WindowTreePtr tree,
...@@ -589,6 +592,9 @@ class AURA_EXPORT WindowTreeClient ...@@ -589,6 +592,9 @@ class AURA_EXPORT WindowTreeClient
mojo::AssociatedBinding<ws::mojom::ScreenProviderObserver> mojo::AssociatedBinding<ws::mojom::ScreenProviderObserver>
screen_provider_observer_binding_{this}; screen_provider_observer_binding_{this};
// Id for this connection. The server provides this value in OnClientId().
base::Optional<uint32_t> id_;
base::WeakPtrFactory<WindowTreeClient> weak_factory_; base::WeakPtrFactory<WindowTreeClient> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(WindowTreeClient); DISALLOW_COPY_AND_ASSIGN(WindowTreeClient);
......
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