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

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

Issue 2617883002: Add a new BindInterface() method to Connector. (Closed)
Patch Set: . Created 3 years, 11 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
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/gpu.h" 5 #include "services/ui/public/cpp/gpu/gpu.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/threading/thread_task_runner_handle.h" 8 #include "base/threading/thread_task_runner_handle.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "mojo/public/cpp/bindings/sync_call_restrictions.h" 10 #include "mojo/public/cpp/bindings/sync_call_restrictions.h"
(...skipping 12 matching lines...) Expand all
23 : main_task_runner_(base::ThreadTaskRunnerHandle::Get()), 23 : main_task_runner_(base::ThreadTaskRunnerHandle::Get()),
24 io_task_runner_(std::move(task_runner)), 24 io_task_runner_(std::move(task_runner)),
25 connector_(connector), 25 connector_(connector),
26 interface_provider_(provider), 26 interface_provider_(provider),
27 shutdown_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC, 27 shutdown_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC,
28 base::WaitableEvent::InitialState::NOT_SIGNALED) { 28 base::WaitableEvent::InitialState::NOT_SIGNALED) {
29 DCHECK(main_task_runner_); 29 DCHECK(main_task_runner_);
30 DCHECK(connector_ || interface_provider_); 30 DCHECK(connector_ || interface_provider_);
31 mojom::GpuPtr gpu_ptr; 31 mojom::GpuPtr gpu_ptr;
32 if (connector_) 32 if (connector_)
33 connector_->ConnectToInterface(ui::mojom::kServiceName, &gpu_ptr); 33 connector_->BindInterface(ui::mojom::kServiceName, &gpu_ptr);
34 else 34 else
35 interface_provider_->GetInterface(&gpu_ptr); 35 interface_provider_->GetInterface(&gpu_ptr);
36 gpu_memory_buffer_manager_ = 36 gpu_memory_buffer_manager_ =
37 base::MakeUnique<ClientGpuMemoryBufferManager>(std::move(gpu_ptr)); 37 base::MakeUnique<ClientGpuMemoryBufferManager>(std::move(gpu_ptr));
38 if (!io_task_runner_) { 38 if (!io_task_runner_) {
39 io_thread_.reset(new base::Thread("GPUIOThread")); 39 io_thread_.reset(new base::Thread("GPUIOThread"));
40 base::Thread::Options thread_options(base::MessageLoop::TYPE_IO, 0); 40 base::Thread::Options thread_options(base::MessageLoop::TYPE_IO, 0);
41 thread_options.priority = base::ThreadPriority::NORMAL; 41 thread_options.priority = base::ThreadPriority::NORMAL;
42 CHECK(io_thread_->StartWithOptions(thread_options)); 42 CHECK(io_thread_->StartWithOptions(thread_options));
43 io_task_runner_ = io_thread_->task_runner(); 43 io_task_runner_ = io_thread_->task_runner();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 if (channel) { 94 if (channel) {
95 main_task_runner_->PostTask(FROM_HERE, 95 main_task_runner_->PostTask(FROM_HERE,
96 base::Bind(callback, std::move(channel))); 96 base::Bind(callback, std::move(channel)));
97 return; 97 return;
98 } 98 }
99 establish_callbacks_.push_back(callback); 99 establish_callbacks_.push_back(callback);
100 if (gpu_) 100 if (gpu_)
101 return; 101 return;
102 102
103 if (connector_) 103 if (connector_)
104 connector_->ConnectToInterface(ui::mojom::kServiceName, &gpu_); 104 connector_->BindInterface(ui::mojom::kServiceName, &gpu_);
105 else 105 else
106 interface_provider_->GetInterface(&gpu_); 106 interface_provider_->GetInterface(&gpu_);
107 gpu_->EstablishGpuChannel( 107 gpu_->EstablishGpuChannel(
108 base::Bind(&Gpu::OnEstablishedGpuChannel, base::Unretained(this))); 108 base::Bind(&Gpu::OnEstablishedGpuChannel, base::Unretained(this)));
109 } 109 }
110 110
111 scoped_refptr<gpu::GpuChannelHost> Gpu::EstablishGpuChannelSync() { 111 scoped_refptr<gpu::GpuChannelHost> Gpu::EstablishGpuChannelSync() {
112 DCHECK(IsMainThread()); 112 DCHECK(IsMainThread());
113 if (GetGpuChannel()) 113 if (GetGpuChannel())
114 return gpu_channel_; 114 return gpu_channel_;
115 115
116 int client_id = 0; 116 int client_id = 0;
117 mojo::ScopedMessagePipeHandle channel_handle; 117 mojo::ScopedMessagePipeHandle channel_handle;
118 gpu::GPUInfo gpu_info; 118 gpu::GPUInfo gpu_info;
119 if (connector_) 119 if (connector_)
120 connector_->ConnectToInterface(ui::mojom::kServiceName, &gpu_); 120 connector_->BindInterface(ui::mojom::kServiceName, &gpu_);
121 else 121 else
122 interface_provider_->GetInterface(&gpu_); 122 interface_provider_->GetInterface(&gpu_);
123 123
124 mojo::SyncCallRestrictions::ScopedAllowSyncCall allow_sync_call; 124 mojo::SyncCallRestrictions::ScopedAllowSyncCall allow_sync_call;
125 if (!gpu_->EstablishGpuChannel(&client_id, &channel_handle, &gpu_info)) { 125 if (!gpu_->EstablishGpuChannel(&client_id, &channel_handle, &gpu_info)) {
126 DLOG(WARNING) 126 DLOG(WARNING)
127 << "Channel encountered error while establishing gpu channel."; 127 << "Channel encountered error while establishing gpu channel.";
128 return nullptr; 128 return nullptr;
129 } 129 }
130 OnEstablishedGpuChannel(client_id, std::move(channel_handle), gpu_info); 130 OnEstablishedGpuChannel(client_id, std::move(channel_handle), gpu_info);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 MojoResult result = mojo::UnwrapSharedMemoryHandle( 183 MojoResult result = mojo::UnwrapSharedMemoryHandle(
184 std::move(handle), &platform_handle, &shared_memory_size, &readonly); 184 std::move(handle), &platform_handle, &shared_memory_size, &readonly);
185 if (result != MOJO_RESULT_OK) 185 if (result != MOJO_RESULT_OK)
186 return nullptr; 186 return nullptr;
187 DCHECK_EQ(shared_memory_size, size); 187 DCHECK_EQ(shared_memory_size, size);
188 188
189 return base::MakeUnique<base::SharedMemory>(platform_handle, readonly); 189 return base::MakeUnique<base::SharedMemory>(platform_handle, readonly);
190 } 190 }
191 191
192 } // namespace ui 192 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ime/test_ime_driver/test_ime_application.cc ('k') | services/ui/public/cpp/window_tree_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698