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

Unified Diff: content/browser/gpu/browser_gpu_channel_host_factory.cc

Issue 2197613003: gpu: Introduce GpuChannelEstablishFactory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tot merge Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/gpu/browser_gpu_channel_host_factory.h ('k') | content/browser/gpu/gpu_ipc_browsertests.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/gpu/browser_gpu_channel_host_factory.cc
diff --git a/content/browser/gpu/browser_gpu_channel_host_factory.cc b/content/browser/gpu/browser_gpu_channel_host_factory.cc
index d3e8ceba95e2a106385c8cbb010538a06e5cf42d..345ad2a4f423957b4e60b9751365084ef4b0a464 100644
--- a/content/browser/gpu/browser_gpu_channel_host_factory.cc
+++ b/content/browser/gpu/browser_gpu_channel_host_factory.cc
@@ -28,10 +28,7 @@
#include "gpu/ipc/common/gpu_messages.h"
#include "ipc/ipc_channel_handle.h"
#include "ipc/message_filter.h"
-
-#if defined(MOJO_RUNNER_CLIENT)
#include "services/shell/runner/common/client_util.h"
-#endif
namespace content {
@@ -209,7 +206,7 @@ void BrowserGpuChannelHostFactory::Initialize(bool establish_gpu_channel) {
DCHECK(!instance_);
instance_ = new BrowserGpuChannelHostFactory();
if (establish_gpu_channel) {
- instance_->EstablishGpuChannel(base::Closure());
+ instance_->EstablishGpuChannel(gpu::GpuChannelEstablishedCallback());
}
}
@@ -249,7 +246,7 @@ BrowserGpuChannelHostFactory::~BrowserGpuChannelHostFactory() {
if (pending_request_.get())
pending_request_->Cancel();
for (size_t n = 0; n < established_callbacks_.size(); n++)
- established_callbacks_[n].Run();
+ established_callbacks_[n].Run(nullptr);
shutdown_event_->Signal();
if (gpu_channel_) {
gpu_channel_->DestroyChannel();
@@ -274,26 +271,9 @@ BrowserGpuChannelHostFactory::AllocateSharedMemory(size_t size) {
return shm;
}
-// Blocking the UI thread to open a GPU channel is not supported on Android.
-// (Opening the initial channel to a child process involves handling a reply
-// task on the UI thread first, so we cannot block here.)
-#if !defined(OS_ANDROID)
-scoped_refptr<gpu::GpuChannelHost>
-BrowserGpuChannelHostFactory::EstablishGpuChannelSync() {
- EstablishGpuChannel(base::Closure());
-
- if (pending_request_.get())
- pending_request_->Wait();
-
- return gpu_channel_;
-}
-#endif
-
void BrowserGpuChannelHostFactory::EstablishGpuChannel(
- const base::Closure& callback) {
-#if defined(MOJO_RUNNER_CLIENT)
+ const gpu::GpuChannelEstablishedCallback& callback) {
DCHECK(!shell::ShellIsRemote());
-#endif
if (gpu_channel_.get() && gpu_channel_->IsLost()) {
DCHECK(!pending_request_.get());
// Recreate the channel if it has been lost.
@@ -309,12 +289,29 @@ void BrowserGpuChannelHostFactory::EstablishGpuChannel(
if (!callback.is_null()) {
if (gpu_channel_.get())
- callback.Run();
+ callback.Run(gpu_channel_);
else
established_callbacks_.push_back(callback);
}
}
+// Blocking the UI thread to open a GPU channel is not supported on Android.
+// (Opening the initial channel to a child process involves handling a reply
+// task on the UI thread first, so we cannot block here.)
+scoped_refptr<gpu::GpuChannelHost>
+BrowserGpuChannelHostFactory::EstablishGpuChannelSync() {
+#if defined(OS_ANDROID)
+ NOTREACHED();
+ return nullptr;
+#endif
+ EstablishGpuChannel(gpu::GpuChannelEstablishedCallback());
+
+ if (pending_request_.get())
+ pending_request_->Wait();
+
+ return gpu_channel_;
+}
+
gpu::GpuChannelHost* BrowserGpuChannelHostFactory::GetGpuChannel() {
if (gpu_channel_.get() && !gpu_channel_->IsLost())
return gpu_channel_.get();
@@ -349,7 +346,7 @@ void BrowserGpuChannelHostFactory::GpuChannelEstablished() {
"466866 BrowserGpuChannelHostFactory::GpuChannelEstablished2"));
for (size_t n = 0; n < established_callbacks_.size(); n++)
- established_callbacks_[n].Run();
+ established_callbacks_[n].Run(gpu_channel_);
established_callbacks_.clear();
}
« no previous file with comments | « content/browser/gpu/browser_gpu_channel_host_factory.h ('k') | content/browser/gpu/gpu_ipc_browsertests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698