summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chromium/content/browser/gpu/gpu_main_thread_factory.h9
-rw-r--r--chromium/content/browser/gpu/gpu_process_host.cc15
-rw-r--r--chromium/content/browser/gpu/gpu_process_host.h3
-rw-r--r--chromium/content/gpu/in_process_gpu_thread.cc32
-rw-r--r--chromium/content/gpu/in_process_gpu_thread.h3
5 files changed, 45 insertions, 17 deletions
diff --git a/chromium/content/browser/gpu/gpu_main_thread_factory.h b/chromium/content/browser/gpu/gpu_main_thread_factory.h
index d1fba87d78c..d53cd9bf5a4 100644
--- a/chromium/content/browser/gpu/gpu_main_thread_factory.h
+++ b/chromium/content/browser/gpu/gpu_main_thread_factory.h
@@ -7,6 +7,8 @@
#include "content/common/content_export.h"
+#include <memory>
+
namespace base {
class Thread;
}
@@ -18,7 +20,12 @@ struct GpuPreferences;
namespace content {
class InProcessChildThreadParams;
-typedef base::Thread* (*GpuMainThreadFactoryFunction)(
+class CONTENT_EXPORT GpuThreadController {
+public:
+ virtual ~GpuThreadController() {}
+};
+
+typedef std::unique_ptr<GpuThreadController> (*GpuMainThreadFactoryFunction)(
const InProcessChildThreadParams&,
const gpu::GpuPreferences&);
diff --git a/chromium/content/browser/gpu/gpu_process_host.cc b/chromium/content/browser/gpu/gpu_process_host.cc
index 48314ce94fb..4bb20fc8198 100644
--- a/chromium/content/browser/gpu/gpu_process_host.cc
+++ b/chromium/content/browser/gpu/gpu_process_host.cc
@@ -828,8 +828,7 @@ GpuProcessHost::~GpuProcessHost() {
base::BindOnce(&OnGpuProcessHostDestroyedOnUI, host_id_, message));
}
- if (in_process_)
- in_process_gpu_thread_->WaitUntilThreadStarted();
+ in_process_gpu_thread_.reset();
// If there are any remaining offscreen contexts at the point the GPU process
// exits, assume something went wrong, and block their URLs from accessing
@@ -854,18 +853,10 @@ bool GpuProcessHost::Init() {
gpu::GpuPreferences gpu_preferences = GetGpuPreferencesFromCommandLine();
GpuDataManagerImpl::GetInstance()->UpdateGpuPreferences(
&gpu_preferences, GPU_PROCESS_KIND_SANDBOXED);
- in_process_gpu_thread_.reset(GetGpuMainThreadFactory()(
+ in_process_gpu_thread_ = GetGpuMainThreadFactory()(
InProcessChildThreadParams(base::ThreadTaskRunnerHandle::Get(),
process_->GetInProcessMojoInvitation()),
- gpu_preferences));
- base::Thread::Options options;
-#if (defined(OS_WIN) || defined(OS_MAC)) && !defined(TOOLKIT_QT)
- // WGL needs to create its own window and pump messages on it.
- options.message_pump_type = base::MessagePumpType::UI;
-#endif
- if (base::FeatureList::IsEnabled(features::kGpuUseDisplayThreadPriority))
- options.priority = base::ThreadPriority::DISPLAY;
- in_process_gpu_thread_->StartWithOptions(options);
+ gpu_preferences);
} else if (!LaunchGpuProcess()) {
return false;
}
diff --git a/chromium/content/browser/gpu/gpu_process_host.h b/chromium/content/browser/gpu/gpu_process_host.h
index 1d317c9564e..d95b1daea29 100644
--- a/chromium/content/browser/gpu/gpu_process_host.h
+++ b/chromium/content/browser/gpu/gpu_process_host.h
@@ -56,6 +56,7 @@ class Thread;
namespace content {
class BrowserChildProcessHostImpl;
+class GpuThreadController;
#if defined(OS_MAC)
class CATransactionGPUCoordinator;
@@ -246,7 +247,7 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate,
// Otherwise, under rare timings when the thread is still in Init(),
// it could crash as it fails to find a message pipe to the host.
std::unique_ptr<BrowserChildProcessHostImpl> process_;
- std::unique_ptr<base::Thread> in_process_gpu_thread_;
+ std::unique_ptr<GpuThreadController> in_process_gpu_thread_;
#if defined(OS_MAC)
scoped_refptr<CATransactionGPUCoordinator> ca_transaction_gpu_coordinator_;
diff --git a/chromium/content/gpu/in_process_gpu_thread.cc b/chromium/content/gpu/in_process_gpu_thread.cc
index 146ee6a9325..efe399b0a7d 100644
--- a/chromium/content/gpu/in_process_gpu_thread.cc
+++ b/chromium/content/gpu/in_process_gpu_thread.cc
@@ -11,6 +11,7 @@
#include "content/gpu/gpu_process.h"
#include "content/public/common/content_client.h"
#include "content/public/common/content_switches.h"
+#include "gpu/config/gpu_finch_features.h"
#include "gpu/config/gpu_preferences.h"
#include "gpu/ipc/service/gpu_init.h"
#include "media/gpu/buildflags.h"
@@ -79,10 +80,37 @@ void InProcessGpuThread::CleanUp() {
delete gpu_process_;
}
-base::Thread* CreateInProcessGpuThread(
+namespace {
+
+class Controller final : public GpuThreadController {
+public:
+ Controller(std::unique_ptr<base::Thread> thread) : thread_(std::move(thread))
+ {
+ base::Thread::Options options;
+#if (defined(OS_WIN) || defined(OS_MAC)) && !defined(TOOLKIT_QT)
+ // WGL needs to create its own window and pump messages on it.
+ options.message_loop_type = base::MessagePumpType::UI;
+#endif
+
+ if (base::FeatureList::IsEnabled(features::kGpuUseDisplayThreadPriority))
+ options.priority = base::ThreadPriority::DISPLAY;
+ thread_->StartWithOptions(options);
+ }
+
+ ~Controller() override {
+ // Don't stop before starting.
+ thread_->WaitUntilThreadStarted();
+ }
+
+private:
+ std::unique_ptr<base::Thread> thread_;
+};
+} // namespace
+
+std::unique_ptr<GpuThreadController> CreateInProcessGpuThread(
const InProcessChildThreadParams& params,
const gpu::GpuPreferences& gpu_preferences) {
- return new InProcessGpuThread(params, gpu_preferences);
+ return std::make_unique<Controller>(std::make_unique<InProcessGpuThread>(params, gpu_preferences));
}
} // namespace content
diff --git a/chromium/content/gpu/in_process_gpu_thread.h b/chromium/content/gpu/in_process_gpu_thread.h
index 12b24cad398..5699706d16f 100644
--- a/chromium/content/gpu/in_process_gpu_thread.h
+++ b/chromium/content/gpu/in_process_gpu_thread.h
@@ -9,6 +9,7 @@
#include "base/macros.h"
#include "base/threading/thread.h"
+#include "content/browser/gpu/gpu_main_thread_factory.h"
#include "content/common/content_export.h"
#include "content/common/in_process_child_thread_params.h"
#include "gpu/config/gpu_preferences.h"
@@ -40,7 +41,7 @@ class InProcessGpuThread : public base::Thread {
DISALLOW_COPY_AND_ASSIGN(InProcessGpuThread);
};
-CONTENT_EXPORT base::Thread* CreateInProcessGpuThread(
+CONTENT_EXPORT std::unique_ptr<GpuThreadController> CreateInProcessGpuThread(
const InProcessChildThreadParams& params,
const gpu::GpuPreferences& gpu_preferences);