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

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

Issue 2741063002: Setup DiscardableMemory in the ash process (Closed)
Patch Set: WIP 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 in_destructor_(false), 189 in_destructor_(false),
188 weak_factory_(this) { 190 weak_factory_(this) {
189 DCHECK(delegate_); 191 DCHECK(delegate_);
190 // Allow for a null request in tests. 192 // Allow for a null request in tests.
191 if (request.is_pending()) 193 if (request.is_pending())
192 binding_.Bind(std::move(request)); 194 binding_.Bind(std::move(request));
193 client::GetTransientWindowClient()->AddObserver(this); 195 client::GetTransientWindowClient()->AddObserver(this);
194 if (window_manager_delegate) 196 if (window_manager_delegate)
195 window_manager_delegate->SetWindowManagerClient(this); 197 window_manager_delegate->SetWindowManagerClient(this);
196 if (connector) { // |connector| can be null in tests. 198 if (connector) { // |connector| can be null in tests.
197 gpu_ = ui::Gpu::Create(connector, std::move(io_task_runner)); 199 if (!io_task_runner) {
James Cook 2017/03/13 21:17:15 nit: Maybe document when io_task_runner can be nul
Peng 2017/03/14 15:03:14 Done
200 io_thread_ = base::MakeUnique<base::Thread>("IOThread");
201 base::Thread::Options thread_options(base::MessageLoop::TYPE_IO, 0);
202 thread_options.priority = base::ThreadPriority::NORMAL;
203 CHECK(io_thread_->StartWithOptions(thread_options));
204 io_task_runner = io_thread_->task_runner();
205 }
206
207 gpu_ = ui::Gpu::Create(connector, io_task_runner);
198 compositor_context_factory_ = 208 compositor_context_factory_ =
199 base::MakeUnique<MusContextFactory>(gpu_.get()); 209 base::MakeUnique<MusContextFactory>(gpu_.get());
200 initial_context_factory_ = Env::GetInstance()->context_factory(); 210 initial_context_factory_ = Env::GetInstance()->context_factory();
201 Env::GetInstance()->set_context_factory(compositor_context_factory_.get()); 211 Env::GetInstance()->set_context_factory(compositor_context_factory_.get());
212
213 discardable_memory::mojom::DiscardableSharedMemoryManagerPtr manager_ptr;
214 connector->BindInterface(ui::mojom::kServiceName, &manager_ptr);
215 discardable_shared_memory_manager_ = base::MakeUnique<
216 discardable_memory::ClientDiscardableSharedMemoryManager>(
217 std::move(manager_ptr), std::move(io_task_runner));
218 base::DiscardableMemoryAllocator::SetInstance(
219 discardable_shared_memory_manager_.get());
202 } 220 }
203 } 221 }
204 222
205 WindowTreeClient::~WindowTreeClient() { 223 WindowTreeClient::~WindowTreeClient() {
206 in_destructor_ = true; 224 in_destructor_ = true;
207 225
226 base::DiscardableMemoryAllocator::SetInstance(nullptr);
227
208 for (WindowTreeClientObserver& observer : observers_) 228 for (WindowTreeClientObserver& observer : observers_)
209 observer.OnWillDestroyClient(this); 229 observer.OnWillDestroyClient(this);
210 230
211 // Clients should properly delete all of their windows before shutdown. 231 // Clients should properly delete all of their windows before shutdown.
212 CHECK(windows_.empty()); 232 CHECK(windows_.empty());
213 233
214 capture_synchronizer_.reset(); 234 capture_synchronizer_.reset();
215 235
216 client::GetTransientWindowClient()->RemoveObserver(this); 236 client::GetTransientWindowClient()->RemoveObserver(this);
217 237
(...skipping 1605 matching lines...) Expand 10 before | Expand all | Expand 10 after
1823 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( 1843 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>(
1824 this, capture_synchronizer_.get(), window)); 1844 this, capture_synchronizer_.get(), window));
1825 } 1845 }
1826 1846
1827 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { 1847 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) {
1828 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( 1848 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>(
1829 this, focus_synchronizer_.get(), window)); 1849 this, focus_synchronizer_.get(), window));
1830 } 1850 }
1831 1851
1832 } // namespace aura 1852 } // 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