OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/mus_client.h" | 5 #include "ui/views/mus/mus_client.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/threading/thread.h" |
| 10 #include "components/discardable_memory/client/client_discardable_shared_memory_
manager.h" |
9 #include "services/service_manager/public/cpp/connection.h" | 11 #include "services/service_manager/public/cpp/connection.h" |
10 #include "services/service_manager/public/cpp/connector.h" | 12 #include "services/service_manager/public/cpp/connector.h" |
11 #include "services/ui/public/cpp/gpu/gpu.h" | 13 #include "services/ui/public/cpp/gpu/gpu.h" |
12 #include "services/ui/public/cpp/property_type_converters.h" | 14 #include "services/ui/public/cpp/property_type_converters.h" |
| 15 #include "services/ui/public/interfaces/constants.mojom.h" |
13 #include "services/ui/public/interfaces/event_matcher.mojom.h" | 16 #include "services/ui/public/interfaces/event_matcher.mojom.h" |
14 #include "services/ui/public/interfaces/window_manager.mojom.h" | 17 #include "services/ui/public/interfaces/window_manager.mojom.h" |
15 #include "ui/aura/env.h" | 18 #include "ui/aura/env.h" |
16 #include "ui/aura/mus/mus_context_factory.h" | 19 #include "ui/aura/mus/mus_context_factory.h" |
17 #include "ui/aura/mus/os_exchange_data_provider_mus.h" | 20 #include "ui/aura/mus/os_exchange_data_provider_mus.h" |
18 #include "ui/aura/mus/property_converter.h" | 21 #include "ui/aura/mus/property_converter.h" |
19 #include "ui/aura/mus/window_tree_client.h" | 22 #include "ui/aura/mus/window_tree_client.h" |
20 #include "ui/aura/mus/window_tree_host_mus.h" | 23 #include "ui/aura/mus/window_tree_host_mus.h" |
21 #include "ui/aura/window.h" | 24 #include "ui/aura/window.h" |
22 #include "ui/aura/window_tree_host.h" | 25 #include "ui/aura/window_tree_host.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 // static | 58 // static |
56 MusClient* MusClient::instance_ = nullptr; | 59 MusClient* MusClient::instance_ = nullptr; |
57 | 60 |
58 MusClient::MusClient(service_manager::Connector* connector, | 61 MusClient::MusClient(service_manager::Connector* connector, |
59 const service_manager::Identity& identity, | 62 const service_manager::Identity& identity, |
60 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, | 63 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, |
61 bool create_wm_state) | 64 bool create_wm_state) |
62 : identity_(identity) { | 65 : identity_(identity) { |
63 DCHECK(!instance_); | 66 DCHECK(!instance_); |
64 instance_ = this; | 67 instance_ = this; |
| 68 |
| 69 if (!io_task_runner) { |
| 70 io_thread_ = base::MakeUnique<base::Thread>("IOThread"); |
| 71 base::Thread::Options thread_options(base::MessageLoop::TYPE_IO, 0); |
| 72 thread_options.priority = base::ThreadPriority::NORMAL; |
| 73 CHECK(io_thread_->StartWithOptions(thread_options)); |
| 74 io_task_runner = io_thread_->task_runner(); |
| 75 } |
| 76 |
65 // TODO(msw): Avoid this... use some default value? Allow clients to extend? | 77 // TODO(msw): Avoid this... use some default value? Allow clients to extend? |
66 property_converter_ = base::MakeUnique<aura::PropertyConverter>(); | 78 property_converter_ = base::MakeUnique<aura::PropertyConverter>(); |
67 | 79 |
68 if (create_wm_state) | 80 if (create_wm_state) |
69 wm_state_ = base::MakeUnique<wm::WMState>(); | 81 wm_state_ = base::MakeUnique<wm::WMState>(); |
70 | 82 |
| 83 discardable_memory::mojom::DiscardableSharedMemoryManagerPtr manager_ptr; |
| 84 connector->ConnectToInterface(ui::mojom::kServiceName, &manager_ptr); |
| 85 |
| 86 discardable_shared_memory_manager_ = base::MakeUnique< |
| 87 discardable_memory::ClientDiscardableSharedMemoryManager>( |
| 88 std::move(manager_ptr), io_task_runner); |
| 89 base::DiscardableMemoryAllocator::SetInstance( |
| 90 discardable_shared_memory_manager_.get()); |
| 91 |
71 gpu_ = ui::Gpu::Create(connector, std::move(io_task_runner)); | 92 gpu_ = ui::Gpu::Create(connector, std::move(io_task_runner)); |
72 compositor_context_factory_ = | 93 compositor_context_factory_ = |
73 base::MakeUnique<aura::MusContextFactory>(gpu_.get()); | 94 base::MakeUnique<aura::MusContextFactory>(gpu_.get()); |
74 aura::Env::GetInstance()->set_context_factory( | 95 aura::Env::GetInstance()->set_context_factory( |
75 compositor_context_factory_.get()); | 96 compositor_context_factory_.get()); |
76 window_tree_client_ = | 97 window_tree_client_ = |
77 base::MakeUnique<aura::WindowTreeClient>(connector, this); | 98 base::MakeUnique<aura::WindowTreeClient>(connector, this); |
78 aura::Env::GetInstance()->SetWindowTreeClient(window_tree_client_.get()); | 99 aura::Env::GetInstance()->SetWindowTreeClient(window_tree_client_.get()); |
79 window_tree_client_->ConnectViaWindowTreeFactory(); | 100 window_tree_client_->ConnectViaWindowTreeFactory(); |
80 | 101 |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 return root->GetTopWindowContainingPoint(relative_point); | 275 return root->GetTopWindowContainingPoint(relative_point); |
255 } | 276 } |
256 return nullptr; | 277 return nullptr; |
257 } | 278 } |
258 | 279 |
259 std::unique_ptr<OSExchangeData::Provider> MusClient::BuildProvider() { | 280 std::unique_ptr<OSExchangeData::Provider> MusClient::BuildProvider() { |
260 return base::MakeUnique<aura::OSExchangeDataProviderMus>(); | 281 return base::MakeUnique<aura::OSExchangeDataProviderMus>(); |
261 } | 282 } |
262 | 283 |
263 } // namespace views | 284 } // namespace views |
OLD | NEW |