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

Side by Side Diff: components/mus/common/gpu_service.cc

Issue 2049083002: Implement MusGpuMemoryBufferManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update Created 4 years, 6 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 "components/mus/common/gpu_service.h" 5 #include "components/mus/common/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_restrictions.h"
9 #include "components/mus/common/gpu_type_converters.h" 10 #include "components/mus/common/gpu_type_converters.h"
10 #include "components/mus/common/mojo_gpu_memory_buffer_manager.h" 11 #include "components/mus/common/mojo_gpu_memory_buffer_manager.h"
11 #include "components/mus/common/switches.h" 12 #include "components/mus/common/switches.h"
12 #include "components/mus/public/interfaces/gpu_service.mojom.h" 13 #include "components/mus/public/interfaces/gpu_service.mojom.h"
13 #include "services/shell/public/cpp/connector.h" 14 #include "services/shell/public/cpp/connector.h"
14 15
15 namespace mus { 16 namespace mus {
16 17
17 namespace { 18 namespace {
18 19
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 64
64 if (gpu_channel_) 65 if (gpu_channel_)
65 return gpu_channel_; 66 return gpu_channel_;
66 67
67 mus::mojom::GpuServicePtr gpu_service; 68 mus::mojom::GpuServicePtr gpu_service;
68 connector->ConnectToInterface("mojo:mus", &gpu_service); 69 connector->ConnectToInterface("mojo:mus", &gpu_service);
69 70
70 int client_id = 0; 71 int client_id = 0;
71 IPC::ChannelHandle channel_handle; 72 IPC::ChannelHandle channel_handle;
72 gpu::GPUInfo gpu_info; 73 gpu::GPUInfo gpu_info;
73 gpu_service->EstablishGpuChannel(base::Bind( 74 gpu_service->EstablishGpuChannel(base::Bind(
Fady Samuel 2016/06/10 15:23:02 Can't we just make this sync?
jam 2016/06/10 15:31:15 +1
Peng 2016/06/10 17:39:30 Done
74 &GpuChannelEstablishCallback, &client_id, &channel_handle, &gpu_info)); 75 &GpuChannelEstablishCallback, &client_id, &channel_handle, &gpu_info));
75 if (!gpu_service.WaitForIncomingResponse()) { 76
76 DLOG(WARNING) 77 {
77 << "Channel encountered error while establishing gpu channel."; 78 base::ThreadRestrictions::ScopedAllowWait allow_wait;
78 return nullptr; 79 if (!gpu_service.WaitForIncomingResponse()) {
80 DLOG(WARNING)
81 << "Channel encountered error while establishing gpu channel.";
82 return nullptr;
83 }
79 } 84 }
80 gpu_channel_ = gpu::GpuChannelHost::Create(this, client_id, gpu_info, 85 gpu_channel_ = gpu::GpuChannelHost::Create(this, client_id, gpu_info,
81 channel_handle, &shutdown_event_, 86 channel_handle, &shutdown_event_,
82 gpu_memory_buffer_manager_.get()); 87 gpu_memory_buffer_manager_.get());
83 return gpu_channel_; 88 return gpu_channel_;
84 } 89 }
85 90
86 bool GpuService::IsMainThread() { 91 bool GpuService::IsMainThread() {
87 return base::MessageLoop::current() == main_message_loop_; 92 return base::MessageLoop::current() == main_message_loop_;
88 } 93 }
89 94
90 scoped_refptr<base::SingleThreadTaskRunner> 95 scoped_refptr<base::SingleThreadTaskRunner>
91 GpuService::GetIOThreadTaskRunner() { 96 GpuService::GetIOThreadTaskRunner() {
92 return io_thread_.task_runner(); 97 return io_thread_.task_runner();
93 } 98 }
94 99
95 std::unique_ptr<base::SharedMemory> GpuService::AllocateSharedMemory( 100 std::unique_ptr<base::SharedMemory> GpuService::AllocateSharedMemory(
96 size_t size) { 101 size_t size) {
97 std::unique_ptr<base::SharedMemory> shm(new base::SharedMemory()); 102 std::unique_ptr<base::SharedMemory> shm(new base::SharedMemory());
98 if (!shm->CreateAnonymous(size)) 103 if (!shm->CreateAnonymous(size))
99 return std::unique_ptr<base::SharedMemory>(); 104 return std::unique_ptr<base::SharedMemory>();
100 return shm; 105 return shm;
101 } 106 }
102 107
103 } // namespace mus 108 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/common/generic_shared_memory_id_generator.cc ('k') | components/mus/gpu/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698