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

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: tot merge 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 delete it.GetCurrentValue(); 98 delete it.GetCurrentValue();
107 } 99 }
108 } 100 }
109 101
110 // static 102 // static
111 GpuProcessHostUIShim* GpuProcessHostUIShim::FromID(int host_id) { 103 GpuProcessHostUIShim* GpuProcessHostUIShim::FromID(int host_id) {
112 DCHECK_CURRENTLY_ON(BrowserThread::UI); 104 DCHECK_CURRENTLY_ON(BrowserThread::UI);
113 return g_hosts_by_id.Pointer()->Lookup(host_id); 105 return g_hosts_by_id.Pointer()->Lookup(host_id);
114 } 106 }
115 107
116 // static
117 GpuProcessHostUIShim* GpuProcessHostUIShim::GetOneInstance() {
118 DCHECK_CURRENTLY_ON(BrowserThread::UI);
119 if (g_hosts_by_id.Pointer()->IsEmpty())
120 return NULL;
121 IDMap<GpuProcessHostUIShim*>::iterator it(g_hosts_by_id.Pointer());
122 return it.GetCurrentValue();
123 }
124
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) { 108 bool GpuProcessHostUIShim::OnMessageReceived(const IPC::Message& message) {
135 DCHECK(CalledOnValidThread()); 109 DCHECK(CalledOnValidThread());
136 110
137 #if defined(USE_OZONE) 111 #if defined(USE_OZONE)
138 if (ui::OzonePlatform::GetInstance() 112 if (ui::OzonePlatform::GetInstance()
139 ->GetGpuPlatformSupportHost() 113 ->GetGpuPlatformSupportHost()
140 ->OnMessageReceived(message)) 114 ->OnMessageReceived(message))
141 return true; 115 return true;
142 #endif 116 #endif
143 117
144 if (message.routing_id() != MSG_ROUTING_CONTROL) 118 if (message.routing_id() != MSG_ROUTING_CONTROL)
145 return false; 119 return false;
146 120
147 return OnControlMessageReceived(message); 121 return OnControlMessageReceived(message);
148 } 122 }
149 123
150 void GpuProcessHostUIShim::StopGpuProcess(const base::Closure& callback) { 124 void GpuProcessHostUIShim::StopGpuProcess(const base::Closure& callback) {
151 close_callback_ = callback; 125 close_callback_ = callback;
152 126
153 BrowserThread::PostTask( 127 BrowserThread::PostTask(
154 BrowserThread::IO, FROM_HERE, base::Bind(&StopGpuProcessOnIO, host_id_)); 128 BrowserThread::IO, FROM_HERE, base::Bind(&StopGpuProcessOnIO, host_id_));
155 } 129 }
156 130
157 void GpuProcessHostUIShim::SimulateRemoveAllContext() {
158 Send(new GpuMsg_Clean());
159 }
160
161 void GpuProcessHostUIShim::SimulateCrash() {
162 Send(new GpuMsg_Crash());
163 }
164
165 void GpuProcessHostUIShim::SimulateHang() {
166 Send(new GpuMsg_Hang());
167 }
168
169 #if defined(OS_ANDROID)
170 void GpuProcessHostUIShim::SimulateJavaCrash() {
171 Send(new GpuMsg_JavaCrash());
172 }
173 #endif
174
175 GpuProcessHostUIShim::~GpuProcessHostUIShim() { 131 GpuProcessHostUIShim::~GpuProcessHostUIShim() {
176 DCHECK(CalledOnValidThread()); 132 DCHECK(CalledOnValidThread());
177 if (!close_callback_.is_null()) 133 if (!close_callback_.is_null())
178 base::ResetAndReturn(&close_callback_).Run(); 134 base::ResetAndReturn(&close_callback_).Run();
179 g_hosts_by_id.Pointer()->Remove(host_id_); 135 g_hosts_by_id.Pointer()->Remove(host_id_);
180 } 136 }
181 137
182 bool GpuProcessHostUIShim::OnControlMessageReceived( 138 bool GpuProcessHostUIShim::OnControlMessageReceived(
183 const IPC::Message& message) { 139 const IPC::Message& message) {
184 DCHECK(CalledOnValidThread()); 140 DCHECK(CalledOnValidThread());
(...skipping 20 matching lines...) Expand all
205 void GpuProcessHostUIShim::OnGraphicsInfoCollected( 161 void GpuProcessHostUIShim::OnGraphicsInfoCollected(
206 const gpu::GPUInfo& gpu_info) { 162 const gpu::GPUInfo& gpu_info) {
207 // OnGraphicsInfoCollected is sent back after the GPU process successfully 163 // OnGraphicsInfoCollected is sent back after the GPU process successfully
208 // initializes GL. 164 // initializes GL.
209 TRACE_EVENT0("test_gpu", "OnGraphicsInfoCollected"); 165 TRACE_EVENT0("test_gpu", "OnGraphicsInfoCollected");
210 166
211 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info); 167 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info);
212 } 168 }
213 169
214 } // namespace content 170 } // 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