Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(780)

Unified Diff: services/ui/test_wm/test_wm.cc

Issue 2301353003: Changes ownership of WindowTreeClient (Closed)
Patch Set: fix navigation Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: services/ui/test_wm/test_wm.cc
diff --git a/services/ui/test_wm/test_wm.cc b/services/ui/test_wm/test_wm.cc
index 3c9d786f8bb2bf4e03a88b6700c3f812b14dd7c7..08777c1306285046a33c3fbbce47d1426ac45aa0 100644
--- a/services/ui/test_wm/test_wm.cc
+++ b/services/ui/test_wm/test_wm.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <memory>
#include <utility>
#include "mojo/public/cpp/bindings/binding.h"
@@ -23,12 +24,12 @@ class TestWM : public shell::Service,
public ui::WindowManagerDelegate {
public:
TestWM() {}
- ~TestWM() override { delete window_tree_client_; }
+ ~TestWM() override {}
private:
// shell::Service:
void OnStart(const shell::Identity& identity) override {
- window_tree_client_ = new ui::WindowTreeClient(this, this, nullptr);
+ window_tree_client_.reset(new ui::WindowTreeClient(this, this));
window_tree_client_->ConnectAsWindowManager(connector());
}
@@ -38,8 +39,13 @@ class TestWM : public shell::Service,
// OnEmbed().
NOTREACHED();
}
- void OnDidDestroyClient(ui::WindowTreeClient* client) override {
- window_tree_client_ = nullptr;
+ void OnLostConnection(WindowTreeClient* client) override {
+ window_tree_client_.reset();
+ }
+ void OnEmbedRootDestroyed(ui::Window* root) override {
+ // WindowTreeClients configured as the window manager should never get
+ // OnEmbedRootDestroyed().
+ NOTREACHED();
}
void OnPointerEventObserved(const ui::PointerEvent& event,
ui::Window* target) override {
@@ -93,8 +99,7 @@ class TestWM : public shell::Service,
ui::Window* root_ = nullptr;
ui::WindowManagerClient* window_manager_client_ = nullptr;
- // See WindowTreeClient for details on ownership.
- ui::WindowTreeClient* window_tree_client_ = nullptr;
+ std::unique_ptr<ui::WindowTreeClient> window_tree_client_;
DISALLOW_COPY_AND_ASSIGN(TestWM);
};
« no previous file with comments | « services/ui/public/cpp/window_tree_host_factory.cc ('k') | services/ui/ws/window_manager_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698