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

Unified Diff: content/gpu/gpu_child_thread.cc

Issue 1859403002: Avoid GpuPreferences exposed in content public gpu interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address jam's comments Created 4 years, 8 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/gpu/gpu_child_thread.h ('k') | content/public/gpu/DEPS » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/gpu/gpu_child_thread.cc
diff --git a/content/gpu/gpu_child_thread.cc b/content/gpu/gpu_child_thread.cc
index 6eee7220acd55d4fc2c1bbc1916e39f4a11e0a58..deb234eacc391a783186e44be25a00228f11e964 100644
--- a/content/gpu/gpu_child_thread.cc
+++ b/content/gpu/gpu_child_thread.cc
@@ -10,6 +10,7 @@
#include "base/bind.h"
#include "base/lazy_instance.h"
#include "base/strings/string_number_conversions.h"
+#include "base/threading/thread_local.h"
#include "base/threading/worker_pool.h"
#include "build/build_config.h"
#include "content/child/child_process.h"
@@ -50,6 +51,9 @@
namespace content {
namespace {
+base::LazyInstance<base::ThreadLocalPointer<GpuChildThread>> g_lazy_tls =
+ LAZY_INSTANCE_INITIALIZER;
+
static base::LazyInstance<scoped_refptr<ThreadSafeSender> >
g_thread_safe_sender = LAZY_INSTANCE_INITIALIZER;
@@ -148,6 +152,11 @@ ChildThreadImpl::Options GetOptions(
} // namespace
+// static
+GpuChildThread* GpuChildThread::current() {
+ return g_lazy_tls.Pointer()->Get();
+}
+
GpuChildThread::GpuChildThread(
GpuWatchdogThread* watchdog_thread,
bool dead_on_arrival,
@@ -167,6 +176,7 @@ GpuChildThread::GpuChildThread(
target_services_ = NULL;
#endif
g_thread_safe_sender.Get() = thread_safe_sender();
+ g_lazy_tls.Pointer()->Set(this);
}
GpuChildThread::GpuChildThread(
@@ -201,6 +211,7 @@ GpuChildThread::GpuChildThread(
VLOG(1) << "gfx::GLSurface::InitializeOneOff failed";
g_thread_safe_sender.Get() = thread_safe_sender();
+ g_lazy_tls.Pointer()->Set(this);
}
GpuChildThread::~GpuChildThread() {
@@ -208,6 +219,7 @@ GpuChildThread::~GpuChildThread() {
delete deferred_messages_.front();
deferred_messages_.pop();
}
+ g_lazy_tls.Pointer()->Set(nullptr);
}
void GpuChildThread::Shutdown() {
« no previous file with comments | « content/gpu/gpu_child_thread.h ('k') | content/public/gpu/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698