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

Side by Side Diff: ui/aura/mus/window_tree_client.cc

Issue 2741063002: Setup DiscardableMemory in the ash process (Closed)
Patch Set: Rebase Created 3 years, 9 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/aura/mus/window_tree_client.h ('k') | ui/views/mus/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/aura/mus/window_tree_client.h" 5 #include "ui/aura/mus/window_tree_client.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/auto_reset.h" 13 #include "base/auto_reset.h"
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
16 #include "base/threading/thread.h"
17 #include "components/discardable_memory/client/client_discardable_shared_memory_ manager.h"
16 #include "mojo/public/cpp/bindings/map.h" 18 #include "mojo/public/cpp/bindings/map.h"
17 #include "services/service_manager/public/cpp/connector.h" 19 #include "services/service_manager/public/cpp/connector.h"
18 #include "services/ui/common/accelerator_util.h" 20 #include "services/ui/common/accelerator_util.h"
19 #include "services/ui/public/cpp/gpu/gpu.h" 21 #include "services/ui/public/cpp/gpu/gpu.h"
20 #include "services/ui/public/cpp/property_type_converters.h" 22 #include "services/ui/public/cpp/property_type_converters.h"
21 #include "services/ui/public/interfaces/constants.mojom.h" 23 #include "services/ui/public/interfaces/constants.mojom.h"
22 #include "services/ui/public/interfaces/window_manager.mojom.h" 24 #include "services/ui/public/interfaces/window_manager.mojom.h"
23 #include "services/ui/public/interfaces/window_manager_window_tree_factory.mojom .h" 25 #include "services/ui/public/interfaces/window_manager_window_tree_factory.mojom .h"
24 #include "ui/aura/client/aura_constants.h" 26 #include "ui/aura/client/aura_constants.h"
25 #include "ui/aura/client/drag_drop_client.h" 27 #include "ui/aura/client/drag_drop_client.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 GetWindowTreeHostMus(target)->SendEventToProcessor(event); 168 GetWindowTreeHostMus(target)->SendEventToProcessor(event);
167 } 169 }
168 170
169 } // namespace 171 } // namespace
170 172
171 WindowTreeClient::WindowTreeClient( 173 WindowTreeClient::WindowTreeClient(
172 service_manager::Connector* connector, 174 service_manager::Connector* connector,
173 WindowTreeClientDelegate* delegate, 175 WindowTreeClientDelegate* delegate,
174 WindowManagerDelegate* window_manager_delegate, 176 WindowManagerDelegate* window_manager_delegate,
175 mojo::InterfaceRequest<ui::mojom::WindowTreeClient> request, 177 mojo::InterfaceRequest<ui::mojom::WindowTreeClient> request,
176 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) 178 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
179 bool create_discardable_memory)
177 : connector_(connector), 180 : connector_(connector),
178 client_id_(0), 181 client_id_(0),
179 next_window_id_(1), 182 next_window_id_(1),
180 next_change_id_(1), 183 next_change_id_(1),
181 delegate_(delegate), 184 delegate_(delegate),
182 window_manager_delegate_(window_manager_delegate), 185 window_manager_delegate_(window_manager_delegate),
183 binding_(this), 186 binding_(this),
184 tree_(nullptr), 187 tree_(nullptr),
185 in_destructor_(false), 188 in_destructor_(false),
186 weak_factory_(this) { 189 weak_factory_(this) {
187 DCHECK(delegate_); 190 DCHECK(delegate_);
188 // Allow for a null request in tests. 191 // Allow for a null request in tests.
189 if (request.is_pending()) 192 if (request.is_pending())
190 binding_.Bind(std::move(request)); 193 binding_.Bind(std::move(request));
191 client::GetTransientWindowClient()->AddObserver(this); 194 client::GetTransientWindowClient()->AddObserver(this);
192 if (window_manager_delegate) 195 if (window_manager_delegate)
193 window_manager_delegate->SetWindowManagerClient(this); 196 window_manager_delegate->SetWindowManagerClient(this);
194 if (connector) { // |connector| can be null in tests. 197 if (connector) { // |connector| can be null in tests.
195 gpu_ = ui::Gpu::Create(connector, std::move(io_task_runner)); 198 if (!io_task_runner) {
199 // |io_task_runner| is null in most case. But for the browser process,
200 // the |io_task_runner| is the browser's IO thread.
201 io_thread_ = base::MakeUnique<base::Thread>("IOThread");
202 base::Thread::Options thread_options(base::MessageLoop::TYPE_IO, 0);
203 thread_options.priority = base::ThreadPriority::NORMAL;
204 CHECK(io_thread_->StartWithOptions(thread_options));
205 io_task_runner = io_thread_->task_runner();
206 }
207
208 gpu_ = ui::Gpu::Create(connector, io_task_runner);
196 compositor_context_factory_ = 209 compositor_context_factory_ =
197 base::MakeUnique<MusContextFactory>(gpu_.get()); 210 base::MakeUnique<MusContextFactory>(gpu_.get());
198 initial_context_factory_ = Env::GetInstance()->context_factory(); 211 initial_context_factory_ = Env::GetInstance()->context_factory();
199 Env::GetInstance()->set_context_factory(compositor_context_factory_.get()); 212 Env::GetInstance()->set_context_factory(compositor_context_factory_.get());
213
214 // WindowServerTest will create more than one WindowTreeClient. We will not
215 // create the discardable memory manager for those tests.
216 if (create_discardable_memory) {
217 discardable_memory::mojom::DiscardableSharedMemoryManagerPtr manager_ptr;
218 connector->BindInterface(ui::mojom::kServiceName, &manager_ptr);
219 discardable_shared_memory_manager_ = base::MakeUnique<
220 discardable_memory::ClientDiscardableSharedMemoryManager>(
221 std::move(manager_ptr), std::move(io_task_runner));
222 base::DiscardableMemoryAllocator::SetInstance(
223 discardable_shared_memory_manager_.get());
224 }
200 } 225 }
201 } 226 }
202 227
203 WindowTreeClient::~WindowTreeClient() { 228 WindowTreeClient::~WindowTreeClient() {
204 in_destructor_ = true; 229 in_destructor_ = true;
205 230
231 if (discardable_shared_memory_manager_)
232 base::DiscardableMemoryAllocator::SetInstance(nullptr);
233
206 for (WindowTreeClientObserver& observer : observers_) 234 for (WindowTreeClientObserver& observer : observers_)
207 observer.OnWillDestroyClient(this); 235 observer.OnWillDestroyClient(this);
208 236
209 // Clients should properly delete all of their windows before shutdown. 237 // Clients should properly delete all of their windows before shutdown.
210 CHECK(windows_.empty()); 238 CHECK(windows_.empty());
211 239
212 capture_synchronizer_.reset(); 240 capture_synchronizer_.reset();
213 241
214 client::GetTransientWindowClient()->RemoveObserver(this); 242 client::GetTransientWindowClient()->RemoveObserver(this);
215 243
(...skipping 1605 matching lines...) Expand 10 before | Expand all | Expand 10 after
1821 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( 1849 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>(
1822 this, capture_synchronizer_.get(), window)); 1850 this, capture_synchronizer_.get(), window));
1823 } 1851 }
1824 1852
1825 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { 1853 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) {
1826 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( 1854 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>(
1827 this, focus_synchronizer_.get(), window)); 1855 this, focus_synchronizer_.get(), window));
1828 } 1856 }
1829 1857
1830 } // namespace aura 1858 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/mus/window_tree_client.h ('k') | ui/views/mus/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698