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

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

Issue 2565223003: content: Move shader cache factory singleton into a separate file. (Closed)
Patch Set: Created 4 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/gpu/shader_cache_factory.h ('k') | content/browser/gpu/shader_disk_cache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/gpu/shader_cache_factory.cc
diff --git a/content/browser/gpu/shader_cache_factory.cc b/content/browser/gpu/shader_cache_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b6f9f496314a9896f1731192d2f9a0f674b55ee4
--- /dev/null
+++ b/content/browser/gpu/shader_cache_factory.cc
@@ -0,0 +1,40 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/gpu/shader_cache_factory.h"
+
+#include "base/single_thread_task_runner.h"
+#include "content/browser/gpu/shader_disk_cache.h"
+
+namespace content {
+
+namespace {
+
+ShaderCacheFactory* factory_instance = nullptr;
+
+void CreateFactoryInstance(
+ scoped_refptr<base::SingleThreadTaskRunner> cache_task_runner) {
+ DCHECK(!factory_instance);
+ factory_instance = new ShaderCacheFactory(std::move(cache_task_runner));
+}
+
+} // namespace
+
+void InitShaderCacheFactorySingleton(
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner,
+ scoped_refptr<base::SingleThreadTaskRunner> cache_task_runner) {
+ if (task_runner->BelongsToCurrentThread()) {
+ CreateFactoryInstance(std::move(cache_task_runner));
+ } else {
+ task_runner->PostTask(FROM_HERE, base::Bind(&CreateFactoryInstance,
+ std::move(cache_task_runner)));
+ }
+}
+
+ShaderCacheFactory* GetShaderCacheFactorySingleton() {
+ DCHECK(!factory_instance || factory_instance->CalledOnValidThread());
+ return factory_instance;
+}
+
+} // namespace content
« no previous file with comments | « content/browser/gpu/shader_cache_factory.h ('k') | content/browser/gpu/shader_disk_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698