Chromium Code Reviews| Index: ui/aura/mus/window_tree_client.cc |
| diff --git a/ui/aura/mus/window_tree_client.cc b/ui/aura/mus/window_tree_client.cc |
| index 82f54f0d6d4d97dc79c56cebfb063cc8c2b5661e..9c59dbbc1a4e5db966e0ecfd7dbaa5215d7031fe 100644 |
| --- a/ui/aura/mus/window_tree_client.cc |
| +++ b/ui/aura/mus/window_tree_client.cc |
| @@ -13,6 +13,8 @@ |
| #include "base/auto_reset.h" |
| #include "base/bind.h" |
| #include "base/memory/ptr_util.h" |
| +#include "base/threading/thread.h" |
| +#include "components/discardable_memory/client/client_discardable_shared_memory_manager.h" |
| #include "mojo/public/cpp/bindings/map.h" |
| #include "services/service_manager/public/cpp/connector.h" |
| #include "services/ui/common/accelerator_util.h" |
| @@ -194,17 +196,35 @@ WindowTreeClient::WindowTreeClient( |
| if (window_manager_delegate) |
| window_manager_delegate->SetWindowManagerClient(this); |
| if (connector) { // |connector| can be null in tests. |
| - gpu_ = ui::Gpu::Create(connector, std::move(io_task_runner)); |
| + 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
|
| + io_thread_ = base::MakeUnique<base::Thread>("IOThread"); |
| + base::Thread::Options thread_options(base::MessageLoop::TYPE_IO, 0); |
| + thread_options.priority = base::ThreadPriority::NORMAL; |
| + CHECK(io_thread_->StartWithOptions(thread_options)); |
| + io_task_runner = io_thread_->task_runner(); |
| + } |
| + |
| + gpu_ = ui::Gpu::Create(connector, io_task_runner); |
| compositor_context_factory_ = |
| base::MakeUnique<MusContextFactory>(gpu_.get()); |
| initial_context_factory_ = Env::GetInstance()->context_factory(); |
| Env::GetInstance()->set_context_factory(compositor_context_factory_.get()); |
| + |
| + discardable_memory::mojom::DiscardableSharedMemoryManagerPtr manager_ptr; |
| + connector->BindInterface(ui::mojom::kServiceName, &manager_ptr); |
| + discardable_shared_memory_manager_ = base::MakeUnique< |
| + discardable_memory::ClientDiscardableSharedMemoryManager>( |
| + std::move(manager_ptr), std::move(io_task_runner)); |
| + base::DiscardableMemoryAllocator::SetInstance( |
| + discardable_shared_memory_manager_.get()); |
| } |
| } |
| WindowTreeClient::~WindowTreeClient() { |
| in_destructor_ = true; |
| + base::DiscardableMemoryAllocator::SetInstance(nullptr); |
| + |
| for (WindowTreeClientObserver& observer : observers_) |
| observer.OnWillDestroyClient(this); |