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

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

Issue 2194003002: services/ui: Have an explicit lifetime/ownership of ui::GpuService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tot merge Created 4 years, 4 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 23 matching lines...) Expand all
34 base::LazyInstance<WindowManagerConnectionPtr>::Leaky lazy_tls_ptr = 34 base::LazyInstance<WindowManagerConnectionPtr>::Leaky lazy_tls_ptr =
35 LAZY_INSTANCE_INITIALIZER; 35 LAZY_INSTANCE_INITIALIZER;
36 36
37 } // namespace 37 } // namespace
38 38
39 WindowManagerConnection::~WindowManagerConnection() { 39 WindowManagerConnection::~WindowManagerConnection() {
40 // ~WindowTreeClient calls back to us (we're its delegate), destroy it while 40 // ~WindowTreeClient calls back to us (we're its delegate), destroy it while
41 // we are still valid. 41 // we are still valid.
42 client_.reset(); 42 client_.reset();
43 ui::Clipboard::DestroyClipboardForCurrentThread(); 43 ui::Clipboard::DestroyClipboardForCurrentThread();
44 ui::GpuService::Terminate(); 44 gpu_service_.reset();
45 lazy_tls_ptr.Pointer()->Set(nullptr); 45 lazy_tls_ptr.Pointer()->Set(nullptr);
46 46
47 if (ViewsDelegate::GetInstance()) { 47 if (ViewsDelegate::GetInstance()) {
48 ViewsDelegate::GetInstance()->set_native_widget_factory( 48 ViewsDelegate::GetInstance()->set_native_widget_factory(
49 ViewsDelegate::NativeWidgetFactory()); 49 ViewsDelegate::NativeWidgetFactory());
50 } 50 }
51 } 51 }
52 52
53 // static 53 // static
54 std::unique_ptr<WindowManagerConnection> WindowManagerConnection::Create( 54 std::unique_ptr<WindowManagerConnection> WindowManagerConnection::Create(
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 const std::set<ui::Window*>& WindowManagerConnection::GetRoots() const { 143 const std::set<ui::Window*>& WindowManagerConnection::GetRoots() const {
144 return client_->GetRoots(); 144 return client_->GetRoots();
145 } 145 }
146 146
147 WindowManagerConnection::WindowManagerConnection( 147 WindowManagerConnection::WindowManagerConnection(
148 shell::Connector* connector, 148 shell::Connector* connector,
149 const shell::Identity& identity) 149 const shell::Identity& identity)
150 : connector_(connector), identity_(identity) { 150 : connector_(connector), identity_(identity) {
151 lazy_tls_ptr.Pointer()->Set(this); 151 lazy_tls_ptr.Pointer()->Set(this);
152 152
153 ui::GpuService::Initialize(connector); 153 gpu_service_ = ui::GpuService::Initialize(connector);
154
155 client_.reset(new ui::WindowTreeClient(this, nullptr, nullptr)); 154 client_.reset(new ui::WindowTreeClient(this, nullptr, nullptr));
156 client_->ConnectViaWindowTreeFactory(connector_); 155 client_->ConnectViaWindowTreeFactory(connector_);
157 156
158 screen_.reset(new ScreenMus(this)); 157 screen_.reset(new ScreenMus(this));
159 screen_->Init(connector); 158 screen_->Init(connector);
160 159
161 std::unique_ptr<ClipboardMus> clipboard(new ClipboardMus); 160 std::unique_ptr<ClipboardMus> clipboard(new ClipboardMus);
162 clipboard->Init(connector); 161 clipboard->Init(connector);
163 ui::Clipboard::SetClipboardForCurrentThread(std::move(clipboard)); 162 ui::Clipboard::SetClipboardForCurrentThread(std::move(clipboard));
164 163
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 void WindowManagerConnection::OnWindowManagerFrameValuesChanged() { 230 void WindowManagerConnection::OnWindowManagerFrameValuesChanged() {
232 if (client_) 231 if (client_)
233 NativeWidgetMus::NotifyFrameChanged(client_.get()); 232 NativeWidgetMus::NotifyFrameChanged(client_.get());
234 } 233 }
235 234
236 gfx::Point WindowManagerConnection::GetCursorScreenPoint() { 235 gfx::Point WindowManagerConnection::GetCursorScreenPoint() {
237 return client_->GetCursorScreenPoint(); 236 return client_->GetCursorScreenPoint();
238 } 237 }
239 238
240 } // namespace views 239 } // 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