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

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

Issue 2067833002: Fix a crash in mus::GpuService (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
« no previous file with comments | « base/threading/thread_restrictions.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 "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 GpuService::GpuService() 18 GpuService::GpuService()
18 : main_message_loop_(base::MessageLoop::current()), 19 : main_message_loop_(base::MessageLoop::current()),
(...skipping 30 matching lines...) Expand all
49 50
50 if (gpu_channel_) 51 if (gpu_channel_)
51 return gpu_channel_; 52 return gpu_channel_;
52 53
53 mus::mojom::GpuServicePtr gpu_service; 54 mus::mojom::GpuServicePtr gpu_service;
54 connector->ConnectToInterface("mojo:mus", &gpu_service); 55 connector->ConnectToInterface("mojo:mus", &gpu_service);
55 56
56 int client_id = 0; 57 int client_id = 0;
57 mojom::ChannelHandlePtr channel_handle; 58 mojom::ChannelHandlePtr channel_handle;
58 mojom::GpuInfoPtr gpu_info; 59 mojom::GpuInfoPtr gpu_info;
59 if (!gpu_service->EstablishGpuChannel(&client_id, &channel_handle, 60 {
60 &gpu_info)) { 61 // TODO(penghuang): Remove the ScopedAllowWait when HW rendering is enabled
61 DLOG(WARNING) 62 // in mus chrome.
62 << "Channel encountered error while establishing gpu channel."; 63 base::ThreadRestrictions::ScopedAllowWait allow_wait;
63 return nullptr; 64 if (!gpu_service->EstablishGpuChannel(&client_id, &channel_handle,
65 &gpu_info)) {
66 DLOG(WARNING)
67 << "Channel encountered error while establishing gpu channel.";
68 return nullptr;
69 }
64 } 70 }
65 71
66 // TODO(penghuang): Get the real gpu info from mus. 72 // TODO(penghuang): Get the real gpu info from mus.
67 gpu_channel_ = gpu::GpuChannelHost::Create( 73 gpu_channel_ = gpu::GpuChannelHost::Create(
68 this, client_id, gpu::GPUInfo(), channel_handle.To<IPC::ChannelHandle>(), 74 this, client_id, gpu::GPUInfo(), channel_handle.To<IPC::ChannelHandle>(),
69 &shutdown_event_, gpu_memory_buffer_manager_.get()); 75 &shutdown_event_, gpu_memory_buffer_manager_.get());
70 return gpu_channel_; 76 return gpu_channel_;
71 } 77 }
72 78
73 bool GpuService::IsMainThread() { 79 bool GpuService::IsMainThread() {
74 return base::MessageLoop::current() == main_message_loop_; 80 return base::MessageLoop::current() == main_message_loop_;
75 } 81 }
76 82
77 scoped_refptr<base::SingleThreadTaskRunner> 83 scoped_refptr<base::SingleThreadTaskRunner>
78 GpuService::GetIOThreadTaskRunner() { 84 GpuService::GetIOThreadTaskRunner() {
79 return io_thread_.task_runner(); 85 return io_thread_.task_runner();
80 } 86 }
81 87
82 std::unique_ptr<base::SharedMemory> GpuService::AllocateSharedMemory( 88 std::unique_ptr<base::SharedMemory> GpuService::AllocateSharedMemory(
83 size_t size) { 89 size_t size) {
84 std::unique_ptr<base::SharedMemory> shm(new base::SharedMemory()); 90 std::unique_ptr<base::SharedMemory> shm(new base::SharedMemory());
85 if (!shm->CreateAnonymous(size)) 91 if (!shm->CreateAnonymous(size))
86 return std::unique_ptr<base::SharedMemory>(); 92 return std::unique_ptr<base::SharedMemory>();
87 return shm; 93 return shm;
88 } 94 }
89 95
90 } // namespace mus 96 } // namespace mus
OLDNEW
« no previous file with comments | « base/threading/thread_restrictions.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698