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

Side by Side Diff: ui/views/mus/window_manager_connection.cc

Issue 2023863003: views/mus: Destroy DeviceDataManager only if WindowManagerConnection owns it. (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 unified diff | Download patch
« no previous file with comments | « ui/views/mus/window_manager_connection.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/mus/window_manager_connection.h" 5 #include "ui/views/mus/window_manager_connection.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/threading/thread_local.h" 10 #include "base/threading/thread_local.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // Last PointerWatcher removed, stop the event observer. 95 // Last PointerWatcher removed, stop the event observer.
96 client_->SetEventObserver(nullptr); 96 client_->SetEventObserver(nullptr);
97 } 97 }
98 } 98 }
99 99
100 WindowManagerConnection::WindowManagerConnection( 100 WindowManagerConnection::WindowManagerConnection(
101 shell::Connector* connector, 101 shell::Connector* connector,
102 const shell::Identity& identity) 102 const shell::Identity& identity)
103 : connector_(connector), 103 : connector_(connector),
104 identity_(identity), 104 identity_(identity),
105 client_(nullptr) { 105 created_device_data_manager_(false) {
106 client_.reset(new mus::WindowTreeClient(this, nullptr, nullptr)); 106 client_.reset(new mus::WindowTreeClient(this, nullptr, nullptr));
107 client_->ConnectViaWindowTreeFactory(connector_); 107 client_->ConnectViaWindowTreeFactory(connector_);
108 108
109 screen_.reset(new ScreenMus(this)); 109 screen_.reset(new ScreenMus(this));
110 screen_->Init(connector); 110 screen_->Init(connector);
111 111
112 // TODO(sad): We should have a DeviceDataManager implementation that talks to 112 if (!ui::DeviceDataManager::HasInstance()) {
113 // a mojo service to learn about the input-devices on the system. 113 // TODO(sad): We should have a DeviceDataManager implementation that talks
114 // http://crbug.com/601981 114 // to a mojo service to learn about the input-devices on the system.
115 ui::DeviceDataManager::CreateInstance(); 115 // http://crbug.com/601981
116 ui::DeviceDataManager::CreateInstance();
117 created_device_data_manager_ = true;
118 }
116 119
117 ViewsDelegate::GetInstance()->set_native_widget_factory(base::Bind( 120 ViewsDelegate::GetInstance()->set_native_widget_factory(base::Bind(
118 &WindowManagerConnection::CreateNativeWidgetMus, 121 &WindowManagerConnection::CreateNativeWidgetMus,
119 base::Unretained(this), 122 base::Unretained(this),
120 std::map<std::string, std::vector<uint8_t>>())); 123 std::map<std::string, std::vector<uint8_t>>()));
121 } 124 }
122 125
123 WindowManagerConnection::~WindowManagerConnection() { 126 WindowManagerConnection::~WindowManagerConnection() {
124 // ~WindowTreeClient calls back to us (we're its delegate), destroy it while 127 // ~WindowTreeClient calls back to us (we're its delegate), destroy it while
125 // we are still valid. 128 // we are still valid.
126 client_.reset(); 129 client_.reset();
127 130 if (created_device_data_manager_)
128 ui::DeviceDataManager::DeleteInstance(); 131 ui::DeviceDataManager::DeleteInstance();
129 } 132 }
130 133
131 bool WindowManagerConnection::HasPointerWatcher() { 134 bool WindowManagerConnection::HasPointerWatcher() {
132 // Check to see if we really have any observers left. This doesn't use 135 // Check to see if we really have any observers left. This doesn't use
133 // base::ObserverList<>::might_have_observers() because that returns true 136 // base::ObserverList<>::might_have_observers() because that returns true
134 // during iteration over the list even when the last observer is removed. 137 // during iteration over the list even when the last observer is removed.
135 base::ObserverList<PointerWatcher>::Iterator iterator(&pointer_watchers_); 138 base::ObserverList<PointerWatcher>::Iterator iterator(&pointer_watchers_);
136 return !!iterator.GetNext(); 139 return !!iterator.GetNext();
137 } 140 }
138 141
(...skipping 30 matching lines...) Expand all
169 void WindowManagerConnection::OnWindowManagerFrameValuesChanged() { 172 void WindowManagerConnection::OnWindowManagerFrameValuesChanged() {
170 if (client_) 173 if (client_)
171 NativeWidgetMus::NotifyFrameChanged(client_.get()); 174 NativeWidgetMus::NotifyFrameChanged(client_.get());
172 } 175 }
173 176
174 gfx::Point WindowManagerConnection::GetCursorScreenPoint() { 177 gfx::Point WindowManagerConnection::GetCursorScreenPoint() {
175 return client_->GetCursorScreenPoint(); 178 return client_->GetCursorScreenPoint();
176 } 179 }
177 180
178 } // namespace views 181 } // namespace views
OLDNEW
« 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