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

Unified Diff: content/browser/renderer_host/gpu_message_filter.cc

Issue 8887001: Remove custom Task implementations and re-exorcise old callbacks from gpu. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: base::IgnoreResult instead of base::IgnoreReturn Created 9 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/renderer_host/gpu_message_filter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/gpu_message_filter.cc
diff --git a/content/browser/renderer_host/gpu_message_filter.cc b/content/browser/renderer_host/gpu_message_filter.cc
index 40e8803189c3b685c6e5ba7fc3e8ad79172b429b..0533829c651cd278cb6d67c1e27d0b8737676748 100644
--- a/content/browser/renderer_host/gpu_message_filter.cc
+++ b/content/browser/renderer_host/gpu_message_filter.cc
@@ -8,7 +8,7 @@
#include "content/browser/renderer_host/gpu_message_filter.h"
-#include "base/callback.h"
+#include "base/bind.h"
#include "content/browser/gpu/gpu_process_host.h"
#include "content/browser/renderer_host/render_widget_helper.h"
#include "content/common/gpu/gpu_messages.h"
@@ -41,98 +41,11 @@ bool GpuMessageFilter::OnMessageReceived(
return handled;
}
-// Callbacks used in this file.
-namespace {
-
-class EstablishChannelCallback
- : public CallbackRunner<Tuple3<const IPC::ChannelHandle&,
- base::ProcessHandle,
- const content::GPUInfo&> > {
- public:
- EstablishChannelCallback(GpuMessageFilter* filter, IPC::Message* reply)
- : filter_(filter->AsWeakPtr()),
- reply_(reply) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- }
-
- virtual void RunWithParams(const TupleType& params) {
- DispatchToMethod(this, &EstablishChannelCallback::Send, params);
- }
-
- void Send(const IPC::ChannelHandle& channel,
- base::ProcessHandle gpu_process_for_browser,
- const content::GPUInfo& gpu_info) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
-
- if (!filter_)
- return;
-
- base::ProcessHandle renderer_process_for_gpu;
- if (gpu_process_for_browser != 0) {
-#if defined(OS_WIN)
- // Create a process handle that the renderer process can give to the GPU
- // process to give it access to its handles.
- DuplicateHandle(base::GetCurrentProcessHandle(),
- filter_->peer_handle(),
- gpu_process_for_browser,
- &renderer_process_for_gpu,
- PROCESS_DUP_HANDLE,
- FALSE,
- 0);
-#else
- renderer_process_for_gpu = filter_->peer_handle();
-#endif
- } else {
- renderer_process_for_gpu = 0;
- }
-
- GpuHostMsg_EstablishGpuChannel::WriteReplyParams(reply_,
- channel,
- renderer_process_for_gpu,
- gpu_info);
- filter_->Send(reply_);
- }
-
- private:
- base::WeakPtr<GpuMessageFilter> filter_;
- IPC::Message* reply_;
-};
-
-class CreateCommandBufferCallback : public CallbackRunner<Tuple1<int32> > {
- public:
- CreateCommandBufferCallback(GpuMessageFilter* filter,
- IPC::Message* reply) :
- filter_(filter->AsWeakPtr()),
- reply_(reply) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- }
-
- virtual void RunWithParams(const TupleType& params) {
- DispatchToMethod(this, &CreateCommandBufferCallback::Send, params);
- }
-
- void Send(int32 route_id) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- GpuHostMsg_CreateViewCommandBuffer::WriteReplyParams(reply_, route_id);
- if (filter_)
- filter_->Send(reply_);
- }
-
- private:
- base::WeakPtr<GpuMessageFilter> filter_;
- IPC::Message* reply_;
-};
-
-} // namespace
-
void GpuMessageFilter::OnEstablishGpuChannel(
content::CauseForGpuLaunch cause_for_gpu_launch,
IPC::Message* reply) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- scoped_ptr<EstablishChannelCallback> callback(
- new EstablishChannelCallback(this, reply));
-
// TODO(apatrick): Eventually, this will return the route ID of a
// GpuProcessStub, from which the renderer process will create a
// GpuProcessProxy. The renderer will use the proxy for all subsequent
@@ -153,7 +66,11 @@ void GpuMessageFilter::OnEstablishGpuChannel(
gpu_host_id_ = host->host_id();
}
- host->EstablishGpuChannel(render_process_id_, callback.release());
+ host->EstablishGpuChannel(
+ render_process_id_,
+ base::Bind(&GpuMessageFilter::EstablishChannelCallback,
+ AsWeakPtr(),
+ reply));
}
void GpuMessageFilter::OnCreateViewCommandBuffer(
@@ -181,5 +98,46 @@ void GpuMessageFilter::OnCreateViewCommandBuffer(
render_view_id,
render_process_id_,
init_params,
- new CreateCommandBufferCallback(this, reply));
+ base::Bind(&GpuMessageFilter::CreateCommandBufferCallback,
+ AsWeakPtr(),
+ reply));
+}
+
+void GpuMessageFilter::EstablishChannelCallback(
+ IPC::Message* reply,
+ const IPC::ChannelHandle& channel,
+ base::ProcessHandle gpu_process_for_browser,
+ const content::GPUInfo& gpu_info) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+
+ base::ProcessHandle renderer_process_for_gpu;
+ if (gpu_process_for_browser != 0) {
+#if defined(OS_WIN)
+ // Create a process handle that the renderer process can give to the GPU
+ // process to give it access to its handles.
+ DuplicateHandle(base::GetCurrentProcessHandle(),
+ peer_handle(),
+ gpu_process_for_browser,
+ &renderer_process_for_gpu,
+ PROCESS_DUP_HANDLE,
+ FALSE,
+ 0);
+#else
+ renderer_process_for_gpu = peer_handle();
+#endif
+ } else {
+ renderer_process_for_gpu = 0;
+ }
+
+ GpuHostMsg_EstablishGpuChannel::WriteReplyParams(
+ reply, channel, renderer_process_for_gpu, gpu_info);
+ Send(reply);
}
+
+void GpuMessageFilter::CreateCommandBufferCallback(
+ IPC::Message* reply, int32 route_id) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ GpuHostMsg_CreateViewCommandBuffer::WriteReplyParams(reply, route_id);
+ Send(reply);
+}
+
« no previous file with comments | « content/browser/renderer_host/gpu_message_filter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698