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

Side by Side Diff: services/ui/public/cpp/gpu_service.cc

Issue 2503063003: Add service name constant for UI service. (Closed)
Patch Set: . Created 4 years, 1 month 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
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 "services/ui/public/cpp/gpu_service.h" 5 #include "services/ui/public/cpp/gpu_service.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/singleton.h" 8 #include "base/memory/singleton.h"
9 #include "base/threading/thread_task_runner_handle.h" 9 #include "base/threading/thread_task_runner_handle.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "mojo/public/cpp/bindings/sync_call_restrictions.h" 11 #include "mojo/public/cpp/bindings/sync_call_restrictions.h"
12 #include "mojo/public/cpp/system/platform_handle.h" 12 #include "mojo/public/cpp/system/platform_handle.h"
13 #include "services/service_manager/public/cpp/connector.h" 13 #include "services/service_manager/public/cpp/connector.h"
14 #include "services/ui/common/switches.h" 14 #include "services/ui/common/switches.h"
15 #include "services/ui/public/cpp/mojo_gpu_memory_buffer_manager.h" 15 #include "services/ui/public/cpp/mojo_gpu_memory_buffer_manager.h"
16 #include "services/ui/public/interfaces/constants.mojom.h"
16 #include "services/ui/public/interfaces/gpu_service.mojom.h" 17 #include "services/ui/public/interfaces/gpu_service.mojom.h"
17 18
18 namespace ui { 19 namespace ui {
19 20
20 GpuService::GpuService(service_manager::Connector* connector, 21 GpuService::GpuService(service_manager::Connector* connector,
21 scoped_refptr<base::SingleThreadTaskRunner> task_runner) 22 scoped_refptr<base::SingleThreadTaskRunner> task_runner)
22 : main_task_runner_(base::ThreadTaskRunnerHandle::Get()), 23 : main_task_runner_(base::ThreadTaskRunnerHandle::Get()),
23 io_task_runner_(std::move(task_runner)), 24 io_task_runner_(std::move(task_runner)),
24 connector_(connector), 25 connector_(connector),
25 shutdown_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC, 26 shutdown_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 scoped_refptr<gpu::GpuChannelHost> channel = GetGpuChannel(); 59 scoped_refptr<gpu::GpuChannelHost> channel = GetGpuChannel();
59 if (channel) { 60 if (channel) {
60 main_task_runner_->PostTask(FROM_HERE, 61 main_task_runner_->PostTask(FROM_HERE,
61 base::Bind(callback, std::move(channel))); 62 base::Bind(callback, std::move(channel)));
62 return; 63 return;
63 } 64 }
64 establish_callbacks_.push_back(callback); 65 establish_callbacks_.push_back(callback);
65 if (gpu_service_) 66 if (gpu_service_)
66 return; 67 return;
67 68
68 connector_->ConnectToInterface("ui", &gpu_service_); 69 connector_->ConnectToInterface(ui::mojom::kServiceName, &gpu_service_);
69 gpu_service_->EstablishGpuChannel( 70 gpu_service_->EstablishGpuChannel(
70 base::Bind(&GpuService::OnEstablishedGpuChannel, base::Unretained(this))); 71 base::Bind(&GpuService::OnEstablishedGpuChannel, base::Unretained(this)));
71 } 72 }
72 73
73 scoped_refptr<gpu::GpuChannelHost> GpuService::EstablishGpuChannelSync() { 74 scoped_refptr<gpu::GpuChannelHost> GpuService::EstablishGpuChannelSync() {
74 DCHECK(IsMainThread()); 75 DCHECK(IsMainThread());
75 if (GetGpuChannel()) 76 if (GetGpuChannel())
76 return gpu_channel_; 77 return gpu_channel_;
77 78
78 int client_id = 0; 79 int client_id = 0;
79 mojo::ScopedMessagePipeHandle channel_handle; 80 mojo::ScopedMessagePipeHandle channel_handle;
80 gpu::GPUInfo gpu_info; 81 gpu::GPUInfo gpu_info;
81 connector_->ConnectToInterface("ui", &gpu_service_); 82 connector_->ConnectToInterface(ui::mojom::kServiceName, &gpu_service_);
82 83
83 mojo::SyncCallRestrictions::ScopedAllowSyncCall allow_sync_call; 84 mojo::SyncCallRestrictions::ScopedAllowSyncCall allow_sync_call;
84 if (!gpu_service_->EstablishGpuChannel(&client_id, &channel_handle, 85 if (!gpu_service_->EstablishGpuChannel(&client_id, &channel_handle,
85 &gpu_info)) { 86 &gpu_info)) {
86 DLOG(WARNING) 87 DLOG(WARNING)
87 << "Channel encountered error while establishing gpu channel."; 88 << "Channel encountered error while establishing gpu channel.";
88 return nullptr; 89 return nullptr;
89 } 90 }
90 OnEstablishedGpuChannel(client_id, std::move(channel_handle), gpu_info); 91 OnEstablishedGpuChannel(client_id, std::move(channel_handle), gpu_info);
91 return gpu_channel_; 92 return gpu_channel_;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 MojoResult result = mojo::UnwrapSharedMemoryHandle( 147 MojoResult result = mojo::UnwrapSharedMemoryHandle(
147 std::move(handle), &platform_handle, &shared_memory_size, &readonly); 148 std::move(handle), &platform_handle, &shared_memory_size, &readonly);
148 if (result != MOJO_RESULT_OK) 149 if (result != MOJO_RESULT_OK)
149 return nullptr; 150 return nullptr;
150 DCHECK_EQ(shared_memory_size, size); 151 DCHECK_EQ(shared_memory_size, size);
151 152
152 return base::MakeUnique<base::SharedMemory>(platform_handle, readonly); 153 return base::MakeUnique<base::SharedMemory>(platform_handle, readonly);
153 } 154 }
154 155
155 } // namespace ui 156 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ime/test_ime_driver/test_ime_application.cc ('k') | services/ui/public/cpp/mojo_gpu_memory_buffer_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698