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

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

Issue 2548423002: Hosting the discardable memory service in the mus process (Closed)
Patch Set: Update Created 4 years 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
« services/ui/service.cc ('K') | « ui/views/mus/mus_client.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 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_service.h" 13 #include "services/ui/public/cpp/gpu/gpu_service.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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 void MusClient::RemoveObserver(MusClientObserver* observer) { 170 void MusClient::RemoveObserver(MusClientObserver* observer) {
168 observer_list_.RemoveObserver(observer); 171 observer_list_.RemoveObserver(observer);
169 } 172 }
170 173
171 MusClient::MusClient(service_manager::Connector* connector, 174 MusClient::MusClient(service_manager::Connector* connector,
172 const service_manager::Identity& identity, 175 const service_manager::Identity& identity,
173 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) 176 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner)
174 : identity_(identity) { 177 : identity_(identity) {
175 DCHECK(!instance_); 178 DCHECK(!instance_);
176 instance_ = this; 179 instance_ = this;
180
181 if (!io_task_runner) {
dcheng 2016/12/16 09:13:01 Random thought: I looked through all the callsites
Peng 2016/12/16 15:03:10 Good suggestion. I will make a separate CL for it.
182 io_thread_ = base::MakeUnique<base::Thread>("IOThread");
183 base::Thread::Options thread_options(base::MessageLoop::TYPE_IO, 0);
184 thread_options.priority = base::ThreadPriority::NORMAL;
185 CHECK(io_thread_->StartWithOptions(thread_options));
186 io_task_runner = io_thread_->task_runner();
187 }
188
177 // TODO(msw): Avoid this... use some default value? Allow clients to extend? 189 // TODO(msw): Avoid this... use some default value? Allow clients to extend?
178 property_converter_ = base::MakeUnique<aura::PropertyConverter>(); 190 property_converter_ = base::MakeUnique<aura::PropertyConverter>();
179 191
180 wm_state_ = base::MakeUnique<wm::WMState>(); 192 wm_state_ = base::MakeUnique<wm::WMState>();
181 193
194 discardable_memory::mojom::DiscardableSharedMemoryManagerPtr manager_ptr;
195 connector->ConnectToInterface(ui::mojom::kServiceName, &manager_ptr);
196
197 discardable_shared_memory_manager_ = base::MakeUnique<
198 discardable_memory::ClientDiscardableSharedMemoryManager>(
199 std::move(manager_ptr), io_task_runner);
200 base::DiscardableMemoryAllocator::SetInstance(
201 discardable_shared_memory_manager_.get());
202
182 gpu_service_ = ui::GpuService::Create(connector, std::move(io_task_runner)); 203 gpu_service_ = ui::GpuService::Create(connector, std::move(io_task_runner));
183 compositor_context_factory_ = 204 compositor_context_factory_ =
184 base::MakeUnique<aura::MusContextFactory>(gpu_service_.get()); 205 base::MakeUnique<aura::MusContextFactory>(gpu_service_.get());
185 aura::Env::GetInstance()->set_context_factory( 206 aura::Env::GetInstance()->set_context_factory(
186 compositor_context_factory_.get()); 207 compositor_context_factory_.get());
187 window_tree_client_ = 208 window_tree_client_ =
188 base::MakeUnique<aura::WindowTreeClient>(connector, this); 209 base::MakeUnique<aura::WindowTreeClient>(connector, this);
189 aura::Env::GetInstance()->SetWindowTreeClient(window_tree_client_.get()); 210 aura::Env::GetInstance()->SetWindowTreeClient(window_tree_client_.get());
190 window_tree_client_->ConnectViaWindowTreeFactory(); 211 window_tree_client_->ConnectViaWindowTreeFactory();
191 212
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 return root->GetTopWindowContainingPoint(relative_point); 273 return root->GetTopWindowContainingPoint(relative_point);
253 } 274 }
254 return nullptr; 275 return nullptr;
255 } 276 }
256 277
257 std::unique_ptr<OSExchangeData::Provider> MusClient::BuildProvider() { 278 std::unique_ptr<OSExchangeData::Provider> MusClient::BuildProvider() {
258 return base::MakeUnique<aura::OSExchangeDataProviderMus>(); 279 return base::MakeUnique<aura::OSExchangeDataProviderMus>();
259 } 280 }
260 281
261 } // namespace views 282 } // namespace views
OLDNEW
« services/ui/service.cc ('K') | « ui/views/mus/mus_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698