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

Side by Side Diff: content/browser/gpu/gpu_process_host_ui_shim.cc

Issue 2723013004: gpu: Replace more chrome ipc with mojom API. (Closed)
Patch Set: . Created 3 years, 9 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 | « content/browser/gpu/gpu_process_host_ui_shim.h ('k') | content/common/gpu_host_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/gpu/gpu_process_host_ui_shim.h" 5 #include "content/browser/gpu/gpu_process_host_ui_shim.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 25 matching lines...) Expand all
36 namespace { 36 namespace {
37 37
38 // One of the linux specific headers defines this as a macro. 38 // One of the linux specific headers defines this as a macro.
39 #ifdef DestroyAll 39 #ifdef DestroyAll
40 #undef DestroyAll 40 #undef DestroyAll
41 #endif 41 #endif
42 42
43 base::LazyInstance<IDMap<GpuProcessHostUIShim*>> g_hosts_by_id = 43 base::LazyInstance<IDMap<GpuProcessHostUIShim*>> g_hosts_by_id =
44 LAZY_INSTANCE_INITIALIZER; 44 LAZY_INSTANCE_INITIALIZER;
45 45
46 void SendOnIOThreadTask(int host_id, IPC::Message* msg) {
47 GpuProcessHost* host = GpuProcessHost::FromID(host_id);
48 if (host)
49 host->Send(msg);
50 else
51 delete msg;
52 }
53
54 void StopGpuProcessOnIO(int host_id) { 46 void StopGpuProcessOnIO(int host_id) {
55 GpuProcessHost* host = GpuProcessHost::FromID(host_id); 47 GpuProcessHost* host = GpuProcessHost::FromID(host_id);
56 if (host) 48 if (host)
57 host->StopGpuProcess(); 49 host->StopGpuProcess();
58 } 50 }
59 51
60 } // namespace 52 } // namespace
61 53
62 void RouteToGpuProcessHostUIShimTask(int host_id, const IPC::Message& msg) { 54 void RouteToGpuProcessHostUIShimTask(int host_id, const IPC::Message& msg) {
63 GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(host_id); 55 GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(host_id);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 107
116 // static 108 // static
117 GpuProcessHostUIShim* GpuProcessHostUIShim::GetOneInstance() { 109 GpuProcessHostUIShim* GpuProcessHostUIShim::GetOneInstance() {
118 DCHECK_CURRENTLY_ON(BrowserThread::UI); 110 DCHECK_CURRENTLY_ON(BrowserThread::UI);
119 if (g_hosts_by_id.Pointer()->IsEmpty()) 111 if (g_hosts_by_id.Pointer()->IsEmpty())
120 return NULL; 112 return NULL;
121 IDMap<GpuProcessHostUIShim*>::iterator it(g_hosts_by_id.Pointer()); 113 IDMap<GpuProcessHostUIShim*>::iterator it(g_hosts_by_id.Pointer());
122 return it.GetCurrentValue(); 114 return it.GetCurrentValue();
123 } 115 }
124 116
125 bool GpuProcessHostUIShim::Send(IPC::Message* msg) {
126 DCHECK(CalledOnValidThread());
127 return BrowserThread::PostTask(BrowserThread::IO,
128 FROM_HERE,
129 base::Bind(&SendOnIOThreadTask,
130 host_id_,
131 msg));
132 }
133
134 bool GpuProcessHostUIShim::OnMessageReceived(const IPC::Message& message) { 117 bool GpuProcessHostUIShim::OnMessageReceived(const IPC::Message& message) {
135 DCHECK(CalledOnValidThread()); 118 DCHECK(CalledOnValidThread());
136 119
137 #if defined(USE_OZONE) 120 #if defined(USE_OZONE)
138 if (ui::OzonePlatform::GetInstance() 121 if (ui::OzonePlatform::GetInstance()
139 ->GetGpuPlatformSupportHost() 122 ->GetGpuPlatformSupportHost()
140 ->OnMessageReceived(message)) 123 ->OnMessageReceived(message))
141 return true; 124 return true;
142 #endif 125 #endif
143 126
144 if (message.routing_id() != MSG_ROUTING_CONTROL) 127 if (message.routing_id() != MSG_ROUTING_CONTROL)
145 return false; 128 return false;
146 129
147 return OnControlMessageReceived(message); 130 return OnControlMessageReceived(message);
148 } 131 }
149 132
150 void GpuProcessHostUIShim::StopGpuProcess(const base::Closure& callback) { 133 void GpuProcessHostUIShim::StopGpuProcess(const base::Closure& callback) {
151 close_callback_ = callback; 134 close_callback_ = callback;
152 135
153 BrowserThread::PostTask( 136 BrowserThread::PostTask(
154 BrowserThread::IO, FROM_HERE, base::Bind(&StopGpuProcessOnIO, host_id_)); 137 BrowserThread::IO, FROM_HERE, base::Bind(&StopGpuProcessOnIO, host_id_));
155 } 138 }
156 139
157 void GpuProcessHostUIShim::SimulateRemoveAllContext() { 140 void GpuProcessHostUIShim::SimulateRemoveAllContext() {
158 Send(new GpuMsg_Clean()); 141 GpuProcessHost::CallOnIO(GpuProcessHost::GPU_PROCESS_KIND_UNSANDBOXED,
jbauman 2017/03/01 22:04:26 We should have a version of CallOnIO that takes ho
jbauman 2017/03/01 22:43:04 For example, these should all be done on the SANDB
sadrul 2017/03/02 03:36:54 Fixed, thanks for catching these! I did a little
142 false /* force_create */,
143 base::Bind([](GpuProcessHost* host) {
144 host->gpu_service()->DestroyAllChannels();
145 }));
159 } 146 }
160 147
161 void GpuProcessHostUIShim::SimulateCrash() { 148 void GpuProcessHostUIShim::SimulateCrash() {
162 Send(new GpuMsg_Crash()); 149 GpuProcessHost::CallOnIO(
150 GpuProcessHost::GPU_PROCESS_KIND_UNSANDBOXED, false /* force_create */,
151 base::Bind([](GpuProcessHost* host) { host->gpu_service()->Crash(); }));
163 } 152 }
164 153
165 void GpuProcessHostUIShim::SimulateHang() { 154 void GpuProcessHostUIShim::SimulateHang() {
166 Send(new GpuMsg_Hang()); 155 GpuProcessHost::CallOnIO(
156 GpuProcessHost::GPU_PROCESS_KIND_UNSANDBOXED, false /* force_create */,
157 base::Bind([](GpuProcessHost* host) { host->gpu_service()->Hang(); }));
167 } 158 }
168 159
169 #if defined(OS_ANDROID) 160 #if defined(OS_ANDROID)
170 void GpuProcessHostUIShim::SimulateJavaCrash() { 161 void GpuProcessHostUIShim::SimulateJavaCrash() {
171 Send(new GpuMsg_JavaCrash()); 162 GpuProcessHost::CallOnIO(GpuProcessHost::GPU_PROCESS_KIND_UNSANDBOXED,
163 false /* force_create */,
164 base::Bind([](GpuProcessHost* host) {
165 host->gpu_service()->ThrowJavaException();
166 }));
172 } 167 }
173 #endif 168 #endif
174 169
175 GpuProcessHostUIShim::~GpuProcessHostUIShim() { 170 GpuProcessHostUIShim::~GpuProcessHostUIShim() {
176 DCHECK(CalledOnValidThread()); 171 DCHECK(CalledOnValidThread());
177 if (!close_callback_.is_null()) 172 if (!close_callback_.is_null())
178 base::ResetAndReturn(&close_callback_).Run(); 173 base::ResetAndReturn(&close_callback_).Run();
179 g_hosts_by_id.Pointer()->Remove(host_id_); 174 g_hosts_by_id.Pointer()->Remove(host_id_);
180 } 175 }
181 176
(...skipping 23 matching lines...) Expand all
205 void GpuProcessHostUIShim::OnGraphicsInfoCollected( 200 void GpuProcessHostUIShim::OnGraphicsInfoCollected(
206 const gpu::GPUInfo& gpu_info) { 201 const gpu::GPUInfo& gpu_info) {
207 // OnGraphicsInfoCollected is sent back after the GPU process successfully 202 // OnGraphicsInfoCollected is sent back after the GPU process successfully
208 // initializes GL. 203 // initializes GL.
209 TRACE_EVENT0("test_gpu", "OnGraphicsInfoCollected"); 204 TRACE_EVENT0("test_gpu", "OnGraphicsInfoCollected");
210 205
211 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info); 206 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info);
212 } 207 }
213 208
214 } // namespace content 209 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/gpu/gpu_process_host_ui_shim.h ('k') | content/common/gpu_host_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698