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

Unified Diff: ui/views/mus/window_manager_connection.cc

Issue 2026623002: views/mus: Have explicit ownership of views::WindowManagerConnection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tot-merge Created 4 years, 6 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
« no previous file with comments | « ui/views/mus/window_manager_connection.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/mus/window_manager_connection.cc
diff --git a/ui/views/mus/window_manager_connection.cc b/ui/views/mus/window_manager_connection.cc
index f17c0aa96379af0e4f4211482041711d4505c760..5f07c6c645aec947d935cac673cb6c14de548090 100644
--- a/ui/views/mus/window_manager_connection.cc
+++ b/ui/views/mus/window_manager_connection.cc
@@ -35,10 +35,14 @@ base::LazyInstance<WindowManagerConnectionPtr>::Leaky lazy_tls_ptr =
} // namespace
// static
-void WindowManagerConnection::Create(shell::Connector* connector,
- const shell::Identity& identity) {
+std::unique_ptr<WindowManagerConnection> WindowManagerConnection::Create(
+ shell::Connector* connector,
+ const shell::Identity& identity) {
DCHECK(!lazy_tls_ptr.Pointer()->Get());
- lazy_tls_ptr.Pointer()->Set(new WindowManagerConnection(connector, identity));
+ WindowManagerConnection* connection =
+ new WindowManagerConnection(connector, identity);
+ DCHECK(lazy_tls_ptr.Pointer()->Get());
+ return base::WrapUnique(connection);
}
// static
@@ -53,12 +57,6 @@ bool WindowManagerConnection::Exists() {
return !!lazy_tls_ptr.Pointer()->Get();
}
-// static
-void WindowManagerConnection::Reset() {
- delete Get();
- lazy_tls_ptr.Pointer()->Set(nullptr);
-}
-
mus::Window* WindowManagerConnection::NewWindow(
const std::map<std::string, std::vector<uint8_t>>& properties) {
return client_->NewTopLevelWindow(&properties);
@@ -108,6 +106,7 @@ WindowManagerConnection::WindowManagerConnection(
: connector_(connector),
identity_(identity),
created_device_data_manager_(false) {
+ lazy_tls_ptr.Pointer()->Set(this);
client_.reset(new mus::WindowTreeClient(this, nullptr, nullptr));
client_->ConnectViaWindowTreeFactory(connector_);
@@ -134,6 +133,7 @@ WindowManagerConnection::~WindowManagerConnection() {
client_.reset();
if (created_device_data_manager_)
ui::DeviceDataManager::DeleteInstance();
+ lazy_tls_ptr.Pointer()->Set(nullptr);
if (ViewsDelegate::GetInstance()) {
ViewsDelegate::GetInstance()->set_native_widget_factory(
« no previous file with comments | « ui/views/mus/window_manager_connection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698