Commit 4a4522e8 authored by sadrul's avatar sadrul Committed by Commit bot

gpu: Move ShaderDiskCache into //gpu/ipc/host component.

BUG=643746, 604369
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel

Review-Url: https://codereview.chromium.org/2555693005
Cr-Commit-Position: refs/heads/master@{#437771}
parent 34f78aa3
...@@ -656,8 +656,6 @@ source_set("browser") { ...@@ -656,8 +656,6 @@ source_set("browser") {
"gpu/gpu_process_host.h", "gpu/gpu_process_host.h",
"gpu/gpu_process_host_ui_shim.cc", "gpu/gpu_process_host_ui_shim.cc",
"gpu/gpu_process_host_ui_shim.h", "gpu/gpu_process_host_ui_shim.h",
"gpu/shader_disk_cache.cc",
"gpu/shader_disk_cache.h",
"histogram_controller.cc", "histogram_controller.cc",
"histogram_controller.h", "histogram_controller.h",
"histogram_internals_request_job.cc", "histogram_internals_request_job.cc",
......
...@@ -60,7 +60,6 @@ ...@@ -60,7 +60,6 @@
#include "content/browser/gpu/gpu_data_manager_impl.h" #include "content/browser/gpu/gpu_data_manager_impl.h"
#include "content/browser/gpu/gpu_process_host.h" #include "content/browser/gpu/gpu_process_host.h"
#include "content/browser/gpu/gpu_process_host_ui_shim.h" #include "content/browser/gpu/gpu_process_host_ui_shim.h"
#include "content/browser/gpu/shader_disk_cache.h"
#include "content/browser/histogram_synchronizer.h" #include "content/browser/histogram_synchronizer.h"
#include "content/browser/loader/resource_dispatcher_host_impl.h" #include "content/browser/loader/resource_dispatcher_host_impl.h"
#include "content/browser/loader_delegate_impl.h" #include "content/browser/loader_delegate_impl.h"
...@@ -91,6 +90,7 @@ ...@@ -91,6 +90,7 @@
#include "device/battery/battery_status_service.h" #include "device/battery/battery_status_service.h"
#include "device/gamepad/gamepad_service.h" #include "device/gamepad/gamepad_service.h"
#include "device/time_zone_monitor/time_zone_monitor.h" #include "device/time_zone_monitor/time_zone_monitor.h"
#include "gpu/ipc/host/shader_disk_cache.h"
#include "media/base/media.h" #include "media/base/media.h"
#include "media/base/user_input_monitor.h" #include "media/base/user_input_monitor.h"
#include "media/midi/midi_manager.h" #include "media/midi/midi_manager.h"
...@@ -1342,7 +1342,7 @@ int BrowserMainLoop::BrowserThreadsStarted() { ...@@ -1342,7 +1342,7 @@ int BrowserMainLoop::BrowserThreadsStarted() {
// Initialize the GPU shader cache. This needs to be initialized before // Initialize the GPU shader cache. This needs to be initialized before
// BrowserGpuChannelHostFactory below, since that depends on an initialized // BrowserGpuChannelHostFactory below, since that depends on an initialized
// ShaderCacheFactory. // ShaderCacheFactory.
ShaderCacheFactory::InitInstance( gpu::ShaderCacheFactory::InitInstance(
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO), BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
BrowserThread::GetTaskRunnerForThread(BrowserThread::CACHE)); BrowserThread::GetTaskRunnerForThread(BrowserThread::CACHE));
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h"
#include "content/browser/gpu/gpu_data_manager_impl.h" #include "content/browser/gpu/gpu_data_manager_impl.h"
#include "content/browser/gpu/gpu_process_host.h" #include "content/browser/gpu/gpu_process_host.h"
#include "content/browser/gpu/shader_disk_cache.h"
#include "content/common/child_process_host_impl.h" #include "content/common/child_process_host_impl.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h" #include "content/public/browser/content_browser_client.h"
...@@ -26,6 +25,7 @@ ...@@ -26,6 +25,7 @@
#include "content/public/common/content_client.h" #include "content/public/common/content_client.h"
#include "gpu/command_buffer/service/gpu_switches.h" #include "gpu/command_buffer/service/gpu_switches.h"
#include "gpu/ipc/common/gpu_messages.h" #include "gpu/ipc/common/gpu_messages.h"
#include "gpu/ipc/host/shader_disk_cache.h"
#include "ipc/ipc_channel_handle.h" #include "ipc/ipc_channel_handle.h"
#include "ipc/message_filter.h" #include "ipc/message_filter.h"
#include "services/service_manager/runner/common/client_util.h" #include "services/service_manager/runner/common/client_util.h"
...@@ -371,7 +371,8 @@ void BrowserGpuChannelHostFactory::AddFilterOnIO( ...@@ -371,7 +371,8 @@ void BrowserGpuChannelHostFactory::AddFilterOnIO(
void BrowserGpuChannelHostFactory::InitializeShaderDiskCacheOnIO( void BrowserGpuChannelHostFactory::InitializeShaderDiskCacheOnIO(
int gpu_client_id, int gpu_client_id,
const base::FilePath& cache_dir) { const base::FilePath& cache_dir) {
ShaderCacheFactory::GetInstance()->SetCacheInfo(gpu_client_id, cache_dir); gpu::ShaderCacheFactory::GetInstance()->SetCacheInfo(gpu_client_id,
cache_dir);
} }
} // namespace content } // namespace content
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include "content/browser/gpu/compositor_util.h" #include "content/browser/gpu/compositor_util.h"
#include "content/browser/gpu/gpu_data_manager_impl.h" #include "content/browser/gpu/gpu_data_manager_impl.h"
#include "content/browser/gpu/gpu_process_host_ui_shim.h" #include "content/browser/gpu/gpu_process_host_ui_shim.h"
#include "content/browser/gpu/shader_disk_cache.h"
#include "content/browser/renderer_host/render_widget_host_impl.h" #include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/service_manager/service_manager_context.h" #include "content/browser/service_manager/service_manager_context.h"
#include "content/common/child_process_host_impl.h" #include "content/common/child_process_host_impl.h"
...@@ -57,6 +56,7 @@ ...@@ -57,6 +56,7 @@
#include "content/public/common/service_names.mojom.h" #include "content/public/common/service_names.mojom.h"
#include "gpu/command_buffer/service/gpu_preferences.h" #include "gpu/command_buffer/service/gpu_preferences.h"
#include "gpu/command_buffer/service/gpu_switches.h" #include "gpu/command_buffer/service/gpu_switches.h"
#include "gpu/ipc/host/shader_disk_cache.h"
#include "gpu/ipc/service/switches.h" #include "gpu/ipc/service/switches.h"
#include "ipc/ipc_channel_handle.h" #include "ipc/ipc_channel_handle.h"
#include "ipc/message_filter.h" #include "ipc/message_filter.h"
...@@ -1171,8 +1171,8 @@ void GpuProcessHost::LoadedShader(const std::string& key, ...@@ -1171,8 +1171,8 @@ void GpuProcessHost::LoadedShader(const std::string& key,
void GpuProcessHost::CreateChannelCache(int32_t client_id) { void GpuProcessHost::CreateChannelCache(int32_t client_id) {
TRACE_EVENT0("gpu", "GpuProcessHost::CreateChannelCache"); TRACE_EVENT0("gpu", "GpuProcessHost::CreateChannelCache");
scoped_refptr<ShaderDiskCache> cache = scoped_refptr<gpu::ShaderDiskCache> cache =
ShaderCacheFactory::GetInstance()->Get(client_id); gpu::ShaderCacheFactory::GetInstance()->Get(client_id);
if (!cache.get()) if (!cache.get())
return; return;
......
...@@ -42,6 +42,7 @@ struct ChannelHandle; ...@@ -42,6 +42,7 @@ struct ChannelHandle;
namespace gpu { namespace gpu {
struct GpuPreferences; struct GpuPreferences;
class ShaderDiskCache;
struct SyncToken; struct SyncToken;
} }
...@@ -52,7 +53,6 @@ class InterfaceProvider; ...@@ -52,7 +53,6 @@ class InterfaceProvider;
namespace content { namespace content {
class BrowserChildProcessHostImpl; class BrowserChildProcessHostImpl;
class InProcessChildThreadParams; class InProcessChildThreadParams;
class ShaderDiskCache;
typedef base::Thread* (*GpuMainThreadFactoryFunction)( typedef base::Thread* (*GpuMainThreadFactoryFunction)(
const InProcessChildThreadParams&, const gpu::GpuPreferences&); const InProcessChildThreadParams&, const gpu::GpuPreferences&);
...@@ -282,7 +282,7 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate, ...@@ -282,7 +282,7 @@ class GpuProcessHost : public BrowserChildProcessHostDelegate,
// automatic execution of 3D content from those domains. // automatic execution of 3D content from those domains.
std::multiset<GURL> urls_with_live_offscreen_contexts_; std::multiset<GURL> urls_with_live_offscreen_contexts_;
typedef std::map<int32_t, scoped_refptr<ShaderDiskCache>> typedef std::map<int32_t, scoped_refptr<gpu::ShaderDiskCache>>
ClientIdToShaderCacheMap; ClientIdToShaderCacheMap;
ClientIdToShaderCacheMap client_id_to_shader_cache_; ClientIdToShaderCacheMap client_id_to_shader_cache_;
......
...@@ -73,7 +73,6 @@ ...@@ -73,7 +73,6 @@
#include "content/browser/gpu/compositor_util.h" #include "content/browser/gpu/compositor_util.h"
#include "content/browser/gpu/gpu_data_manager_impl.h" #include "content/browser/gpu/gpu_data_manager_impl.h"
#include "content/browser/gpu/gpu_process_host.h" #include "content/browser/gpu/gpu_process_host.h"
#include "content/browser/gpu/shader_disk_cache.h"
#include "content/browser/histogram_message_filter.h" #include "content/browser/histogram_message_filter.h"
#include "content/browser/indexed_db/indexed_db_context_impl.h" #include "content/browser/indexed_db/indexed_db_context_impl.h"
#include "content/browser/indexed_db/indexed_db_dispatcher_host.h" #include "content/browser/indexed_db/indexed_db_dispatcher_host.h"
...@@ -170,6 +169,7 @@ ...@@ -170,6 +169,7 @@
#include "gpu/command_buffer/client/gpu_switches.h" #include "gpu/command_buffer/client/gpu_switches.h"
#include "gpu/command_buffer/common/gles2_cmd_utils.h" #include "gpu/command_buffer/common/gles2_cmd_utils.h"
#include "gpu/command_buffer/service/gpu_switches.h" #include "gpu/command_buffer/service/gpu_switches.h"
#include "gpu/ipc/host/shader_disk_cache.h"
#include "ipc/ipc.mojom.h" #include "ipc/ipc.mojom.h"
#include "ipc/ipc_channel.h" #include "ipc/ipc_channel.h"
#include "ipc/ipc_channel_mojo.h" #include "ipc/ipc_channel_mojo.h"
...@@ -261,13 +261,13 @@ const base::FilePath::CharType kAecDumpFileNameAddition[] = ...@@ -261,13 +261,13 @@ const base::FilePath::CharType kAecDumpFileNameAddition[] =
#endif #endif
void CacheShaderInfo(int32_t id, base::FilePath path) { void CacheShaderInfo(int32_t id, base::FilePath path) {
if (ShaderCacheFactory::GetInstance()) if (gpu::ShaderCacheFactory::GetInstance())
ShaderCacheFactory::GetInstance()->SetCacheInfo(id, path); gpu::ShaderCacheFactory::GetInstance()->SetCacheInfo(id, path);
} }
void RemoveShaderInfo(int32_t id) { void RemoveShaderInfo(int32_t id) {
if (ShaderCacheFactory::GetInstance()) if (gpu::ShaderCacheFactory::GetInstance())
ShaderCacheFactory::GetInstance()->RemoveCacheInfo(id); gpu::ShaderCacheFactory::GetInstance()->RemoveCacheInfo(id);
} }
net::URLRequestContext* GetRequestContext( net::URLRequestContext* GetRequestContext(
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "content/browser/browser_main_loop.h" #include "content/browser/browser_main_loop.h"
#include "content/browser/fileapi/browser_file_system_helper.h" #include "content/browser/fileapi/browser_file_system_helper.h"
#include "content/browser/gpu/shader_disk_cache.h"
#include "content/browser/host_zoom_map_impl.h" #include "content/browser/host_zoom_map_impl.h"
#include "content/browser/notifications/platform_notification_context_impl.h" #include "content/browser/notifications/platform_notification_context_impl.h"
#include "content/common/dom_storage/dom_storage_types.h" #include "content/common/dom_storage/dom_storage_types.h"
...@@ -26,6 +25,7 @@ ...@@ -26,6 +25,7 @@
#include "content/public/browser/indexed_db_context.h" #include "content/public/browser/indexed_db_context.h"
#include "content/public/browser/local_storage_usage_info.h" #include "content/public/browser/local_storage_usage_info.h"
#include "content/public/browser/session_storage_usage_info.h" #include "content/public/browser/session_storage_usage_info.h"
#include "gpu/ipc/host/shader_disk_cache.h"
#include "net/base/completion_callback.h" #include "net/base/completion_callback.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
#include "net/cookies/canonical_cookie.h" #include "net/cookies/canonical_cookie.h"
...@@ -132,7 +132,7 @@ void ClearShaderCacheOnIOThread(const base::FilePath& path, ...@@ -132,7 +132,7 @@ void ClearShaderCacheOnIOThread(const base::FilePath& path,
const base::Time end, const base::Time end,
const base::Closure& callback) { const base::Closure& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK_CURRENTLY_ON(BrowserThread::IO);
ShaderCacheFactory::GetInstance()->ClearByPath( gpu::ShaderCacheFactory::GetInstance()->ClearByPath(
path, begin, end, base::Bind(&ClearedShaderCache, callback)); path, begin, end, base::Bind(&ClearedShaderCache, callback));
} }
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "base/threading/thread.h" #include "base/threading/thread.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "content/browser/browser_thread_impl.h" #include "content/browser/browser_thread_impl.h"
#include "content/browser/gpu/shader_disk_cache.h"
#include "content/browser/quota/mock_quota_manager.h" #include "content/browser/quota/mock_quota_manager.h"
#include "content/browser/storage_partition_impl.h" #include "content/browser/storage_partition_impl.h"
#include "content/public/browser/local_storage_usage_info.h" #include "content/public/browser/local_storage_usage_info.h"
...@@ -22,6 +21,7 @@ ...@@ -22,6 +21,7 @@
#include "content/public/test/test_browser_context.h" #include "content/public/test/test_browser_context.h"
#include "content/public/test/test_browser_thread.h" #include "content/public/test/test_browser_thread.h"
#include "content/public/test/test_browser_thread_bundle.h" #include "content/public/test/test_browser_thread_bundle.h"
#include "gpu/ipc/host/shader_disk_cache.h"
#include "net/base/test_completion_callback.h" #include "net/base/test_completion_callback.h"
#include "net/cookies/canonical_cookie.h" #include "net/cookies/canonical_cookie.h"
#include "net/cookies/cookie_store.h" #include "net/cookies/cookie_store.h"
...@@ -602,19 +602,19 @@ class StoragePartitionShaderClearTest : public testing::Test { ...@@ -602,19 +602,19 @@ class StoragePartitionShaderClearTest : public testing::Test {
StoragePartitionShaderClearTest() StoragePartitionShaderClearTest()
: thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP),
browser_context_(new TestBrowserContext()) { browser_context_(new TestBrowserContext()) {
ShaderCacheFactory::InitInstance( gpu::ShaderCacheFactory::InitInstance(
base::ThreadTaskRunnerHandle::Get(), base::ThreadTaskRunnerHandle::Get(),
BrowserThread::GetTaskRunnerForThread(BrowserThread::CACHE)); BrowserThread::GetTaskRunnerForThread(BrowserThread::CACHE));
ShaderCacheFactory::GetInstance()->SetCacheInfo( gpu::ShaderCacheFactory::GetInstance()->SetCacheInfo(
kDefaultClientId, kDefaultClientId,
BrowserContext::GetDefaultStoragePartition( BrowserContext::GetDefaultStoragePartition(browser_context())
browser_context())->GetPath()); ->GetPath());
cache_ = ShaderCacheFactory::GetInstance()->Get(kDefaultClientId); cache_ = gpu::ShaderCacheFactory::GetInstance()->Get(kDefaultClientId);
} }
~StoragePartitionShaderClearTest() override { ~StoragePartitionShaderClearTest() override {
cache_ = NULL; cache_ = NULL;
ShaderCacheFactory::GetInstance()->RemoveCacheInfo(kDefaultClientId); gpu::ShaderCacheFactory::GetInstance()->RemoveCacheInfo(kDefaultClientId);
} }
void InitCache() { void InitCache() {
...@@ -641,7 +641,7 @@ class StoragePartitionShaderClearTest : public testing::Test { ...@@ -641,7 +641,7 @@ class StoragePartitionShaderClearTest : public testing::Test {
content::TestBrowserThreadBundle thread_bundle_; content::TestBrowserThreadBundle thread_bundle_;
std::unique_ptr<TestBrowserContext> browser_context_; std::unique_ptr<TestBrowserContext> browser_context_;
scoped_refptr<ShaderDiskCache> cache_; scoped_refptr<gpu::ShaderDiskCache> cache_;
}; };
// Tests --------------------------------------------------------------------- // Tests ---------------------------------------------------------------------
......
...@@ -1073,7 +1073,6 @@ test("content_unittests") { ...@@ -1073,7 +1073,6 @@ test("content_unittests") {
"../browser/frame_host/render_widget_host_view_child_frame_unittest.cc", "../browser/frame_host/render_widget_host_view_child_frame_unittest.cc",
"../browser/frame_host/render_widget_host_view_guest_unittest.cc", "../browser/frame_host/render_widget_host_view_guest_unittest.cc",
"../browser/gpu/gpu_data_manager_impl_private_unittest.cc", "../browser/gpu/gpu_data_manager_impl_private_unittest.cc",
"../browser/gpu/shader_disk_cache_unittest.cc",
"../browser/host_zoom_map_impl_unittest.cc", "../browser/host_zoom_map_impl_unittest.cc",
"../browser/indexed_db/indexed_db_active_blob_registry_unittest.cc", "../browser/indexed_db/indexed_db_active_blob_registry_unittest.cc",
"../browser/indexed_db/indexed_db_backing_store_unittest.cc", "../browser/indexed_db/indexed_db_backing_store_unittest.cc",
...@@ -1407,6 +1406,7 @@ test("content_unittests") { ...@@ -1407,6 +1406,7 @@ test("content_unittests") {
"//gin", "//gin",
"//gpu", "//gpu",
"//gpu:test_support", "//gpu:test_support",
"//gpu/ipc/host",
"//ipc:test_support", "//ipc:test_support",
"//media:shared_memory_support", "//media:shared_memory_support",
"//media:test_support", "//media:test_support",
......
...@@ -302,6 +302,7 @@ test("gpu_unittests") { ...@@ -302,6 +302,7 @@ test("gpu_unittests") {
"ipc/client/gpu_memory_buffer_impl_shared_memory_unittest.cc", "ipc/client/gpu_memory_buffer_impl_shared_memory_unittest.cc",
"ipc/client/gpu_memory_buffer_impl_test_template.h", "ipc/client/gpu_memory_buffer_impl_test_template.h",
"ipc/common/struct_traits_unittest.cc", "ipc/common/struct_traits_unittest.cc",
"ipc/host/shader_disk_cache_unittest.cc",
] ]
if (is_mac) { if (is_mac) {
...@@ -326,8 +327,10 @@ test("gpu_unittests") { ...@@ -326,8 +327,10 @@ test("gpu_unittests") {
"//gpu/command_buffer/common:gles2_utils", "//gpu/command_buffer/common:gles2_utils",
"//gpu/ipc:gl_in_process_context", "//gpu/ipc:gl_in_process_context",
"//gpu/ipc/common:test_interfaces", "//gpu/ipc/common:test_interfaces",
"//gpu/ipc/host",
"//mojo/edk/system", "//mojo/edk/system",
"//mojo/public/cpp/bindings", "//mojo/public/cpp/bindings",
"//net:test_support",
"//testing/gmock", "//testing/gmock",
"//testing/gtest", "//testing/gtest",
"//third_party/angle:translator", "//third_party/angle:translator",
......
...@@ -10,11 +10,14 @@ source_set("host") { ...@@ -10,11 +10,14 @@ source_set("host") {
"gpu_memory_buffer_support.h", "gpu_memory_buffer_support.h",
"gpu_switches.cc", "gpu_switches.cc",
"gpu_switches.h", "gpu_switches.h",
"shader_disk_cache.cc",
"shader_disk_cache.h",
] ]
deps = [ deps = [
"//base", "//base",
"//gpu/ipc/common", "//gpu/ipc/common",
"//net",
"//ui/gfx", "//ui/gfx",
"//ui/gl", "//ui/gl",
] ]
......
include_rules = [
"+net",
]
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "content/browser/gpu/shader_disk_cache.h" #include "gpu/ipc/host/shader_disk_cache.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include "net/base/io_buffer.h" #include "net/base/io_buffer.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
namespace content { namespace gpu {
namespace { namespace {
...@@ -79,7 +79,6 @@ class ShaderDiskReadHelper : public base::ThreadChecker { ...@@ -79,7 +79,6 @@ class ShaderDiskReadHelper : public base::ThreadChecker {
ITERATION_FINISHED ITERATION_FINISHED
}; };
void OnOpComplete(int rv); void OnOpComplete(int rv);
int OpenNextEntry(); int OpenNextEntry();
...@@ -110,11 +109,7 @@ class ShaderClearHelper : public base::ThreadChecker { ...@@ -110,11 +109,7 @@ class ShaderClearHelper : public base::ThreadChecker {
void Clear(); void Clear();
private: private:
enum OpType { enum OpType { TERMINATE, VERIFY_CACHE_SETUP, DELETE_CACHE };
TERMINATE,
VERIFY_CACHE_SETUP,
DELETE_CACHE
};
void DoClearShaderCache(int rv); void DoClearShaderCache(int rv);
...@@ -393,8 +388,7 @@ ShaderCacheFactory::ShaderCacheFactory( ...@@ -393,8 +388,7 @@ ShaderCacheFactory::ShaderCacheFactory(
scoped_refptr<base::SingleThreadTaskRunner> cache_task_runner) scoped_refptr<base::SingleThreadTaskRunner> cache_task_runner)
: cache_task_runner_(std::move(cache_task_runner)) {} : cache_task_runner_(std::move(cache_task_runner)) {}
ShaderCacheFactory::~ShaderCacheFactory() { ShaderCacheFactory::~ShaderCacheFactory() {}
}
// static // static
void ShaderCacheFactory::CreateFactoryInstance( void ShaderCacheFactory::CreateFactoryInstance(
...@@ -500,9 +494,7 @@ void ShaderCacheFactory::CacheCleared(const base::FilePath& path) { ...@@ -500,9 +494,7 @@ void ShaderCacheFactory::CacheCleared(const base::FilePath& path) {
// ShaderDiskCache // ShaderDiskCache
ShaderDiskCache::ShaderDiskCache(const base::FilePath& cache_path) ShaderDiskCache::ShaderDiskCache(const base::FilePath& cache_path)
: cache_available_(false), : cache_available_(false), cache_path_(cache_path), is_initialized_(false) {
cache_path_(cache_path),
is_initialized_(false) {
ShaderCacheFactory::GetInstance()->AddToCache(cache_path_, this); ShaderCacheFactory::GetInstance()->AddToCache(cache_path_, this);
} }
...@@ -538,15 +530,15 @@ void ShaderDiskCache::Cache(const std::string& key, const std::string& shader) { ...@@ -538,15 +530,15 @@ void ShaderDiskCache::Cache(const std::string& key, const std::string& shader) {
entries_.insert(std::make_pair(raw_ptr, std::move(shim))); entries_.insert(std::make_pair(raw_ptr, std::move(shim)));
} }
int ShaderDiskCache::Clear( int ShaderDiskCache::Clear(const base::Time begin_time,
const base::Time begin_time, const base::Time end_time, const base::Time end_time,
const net::CompletionCallback& completion_callback) { const net::CompletionCallback& completion_callback) {
int rv; int rv;
if (begin_time.is_null()) { if (begin_time.is_null()) {
rv = backend_->DoomAllEntries(completion_callback); rv = backend_->DoomAllEntries(completion_callback);
} else { } else {
rv = backend_->DoomEntriesBetween(begin_time, end_time, rv =
completion_callback); backend_->DoomEntriesBetween(begin_time, end_time, completion_callback);
} }
return rv; return rv;
} }
...@@ -603,5 +595,4 @@ int ShaderDiskCache::SetCacheCompleteCallback( ...@@ -603,5 +595,4 @@ int ShaderDiskCache::SetCacheCompleteCallback(
return net::ERR_IO_PENDING; return net::ERR_IO_PENDING;
} }
} // namespace content } // namespace gpu
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CONTENT_BROWSER_GPU_SHADER_DISK_CACHE_H_ #ifndef GPU_IPC_HOST_SHADER_DISK_CACHE_H_
#define CONTENT_BROWSER_GPU_SHADER_DISK_CACHE_H_ #define GPU_IPC_HOST_SHADER_DISK_CACHE_H_
#include <stdint.h> #include <stdint.h>
...@@ -15,10 +15,9 @@ ...@@ -15,10 +15,9 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/threading/thread_checker.h" #include "base/threading/thread_checker.h"
#include "content/common/content_export.h"
#include "net/disk_cache/disk_cache.h" #include "net/disk_cache/disk_cache.h"
namespace content { namespace gpu {
class ShaderDiskCacheEntry; class ShaderDiskCacheEntry;
class ShaderDiskReadHelper; class ShaderDiskReadHelper;
...@@ -26,8 +25,7 @@ class ShaderClearHelper; ...@@ -26,8 +25,7 @@ class ShaderClearHelper;
// ShaderDiskCache is the interface to the on disk cache for // ShaderDiskCache is the interface to the on disk cache for
// GL shaders. // GL shaders.
class CONTENT_EXPORT ShaderDiskCache class ShaderDiskCache : public base::RefCounted<ShaderDiskCache> {
: public base::RefCounted<ShaderDiskCache> {
public: public:
using ShaderLoadedCallback = using ShaderLoadedCallback =
base::Callback<void(const std::string&, const std::string&)>; base::Callback<void(const std::string&, const std::string&)>;
...@@ -44,10 +42,9 @@ class CONTENT_EXPORT ShaderDiskCache ...@@ -44,10 +42,9 @@ class CONTENT_EXPORT ShaderDiskCache
// The return value is a net error code. If this method returns // The return value is a net error code. If this method returns
// ERR_IO_PENDING, the |completion_callback| will be invoked when the // ERR_IO_PENDING, the |completion_callback| will be invoked when the
// operation completes. // operation completes.
int Clear( int Clear(const base::Time begin_time,
const base::Time begin_time, const base::Time end_time,
const base::Time end_time, const net::CompletionCallback& completion_callback);
const net::CompletionCallback& completion_callback);
// Sets a callback for when the cache is available. If the cache is // Sets a callback for when the cache is available. If the cache is
// already available the callback will not be called and net::OK is returned. // already available the callback will not be called and net::OK is returned.
...@@ -101,8 +98,7 @@ class CONTENT_EXPORT ShaderDiskCache ...@@ -101,8 +98,7 @@ class CONTENT_EXPORT ShaderDiskCache
// ShaderCacheFactory maintains a cache of ShaderDiskCache objects // ShaderCacheFactory maintains a cache of ShaderDiskCache objects
// so we only create one per profile directory. // so we only create one per profile directory.
class CONTENT_EXPORT ShaderCacheFactory class ShaderCacheFactory : public base::ThreadChecker {
: NON_EXPORTED_BASE(public base::ThreadChecker) {
public: public:
// Initializes the ShaderCacheFactory singleton instance. The singleton // Initializes the ShaderCacheFactory singleton instance. The singleton
// instance is created and used in the thread associated with |task_runner|. // instance is created and used in the thread associated with |task_runner|.
...@@ -168,7 +164,6 @@ class CONTENT_EXPORT ShaderCacheFactory ...@@ -168,7 +164,6 @@ class CONTENT_EXPORT ShaderCacheFactory
DISALLOW_COPY_AND_ASSIGN(ShaderCacheFactory); DISALLOW_COPY_AND_ASSIGN(ShaderCacheFactory);
}; };
} // namespace content } // namespace gpu
#endif // CONTENT_BROWSER_GPU_SHADER_DISK_CACHE_H_
#endif // GPU_IPC_HOST_SHADER_DISK_CACHE_H_
...@@ -4,15 +4,14 @@ ...@@ -4,15 +4,14 @@
#include "base/files/scoped_temp_dir.h" #include "base/files/scoped_temp_dir.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/message_loop/message_loop.h"
#include "base/threading/thread.h" #include "base/threading/thread.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "content/browser/browser_thread_impl.h" #include "gpu/ipc/host/shader_disk_cache.h"
#include "content/browser/gpu/shader_disk_cache.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "net/base/test_completion_callback.h" #include "net/base/test_completion_callback.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace content { namespace gpu {
namespace { namespace {
const int kDefaultClientId = 42; const int kDefaultClientId = 42;
...@@ -24,10 +23,13 @@ const char kCacheValue[] = "cached value"; ...@@ -24,10 +23,13 @@ const char kCacheValue[] = "cached value";
class ShaderDiskCacheTest : public testing::Test { class ShaderDiskCacheTest : public testing::Test {
public: public:
ShaderDiskCacheTest() ShaderDiskCacheTest()
: thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) { : cache_thread_("CacheThread") {
base::Thread::Options options;
options.message_loop_type = base::MessageLoop::TYPE_IO;
CHECK(cache_thread_.StartWithOptions(options));
ShaderCacheFactory::InitInstance( ShaderCacheFactory::InitInstance(
base::ThreadTaskRunnerHandle::Get(), base::ThreadTaskRunnerHandle::Get(),
BrowserThread::GetTaskRunnerForThread(BrowserThread::CACHE)); cache_thread_.task_runner());
} }
~ShaderDiskCacheTest() override {} ~ShaderDiskCacheTest() override {}
...@@ -37,7 +39,7 @@ class ShaderDiskCacheTest : public testing::Test { ...@@ -37,7 +39,7 @@ class ShaderDiskCacheTest : public testing::Test {
void InitCache() { void InitCache() {
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
ShaderCacheFactory::GetInstance()->SetCacheInfo(kDefaultClientId, ShaderCacheFactory::GetInstance()->SetCacheInfo(kDefaultClientId,
cache_path()); cache_path());
} }
private: private:
...@@ -46,7 +48,8 @@ class ShaderDiskCacheTest : public testing::Test { ...@@ -46,7 +48,8 @@ class ShaderDiskCacheTest : public testing::Test {
} }
base::ScopedTempDir temp_dir_; base::ScopedTempDir temp_dir_;
content::TestBrowserThreadBundle thread_bundle_; base::Thread cache_thread_;
base::MessageLoopForIO message_loop_;
DISALLOW_COPY_AND_ASSIGN(ShaderDiskCacheTest); DISALLOW_COPY_AND_ASSIGN(ShaderDiskCacheTest);
}; };
...@@ -77,4 +80,4 @@ TEST_F(ShaderDiskCacheTest, ClearsCache) { ...@@ -77,4 +80,4 @@ TEST_F(ShaderDiskCacheTest, ClearsCache) {
EXPECT_EQ(0, cache->Size()); EXPECT_EQ(0, cache->Size());
}; };
} // namespace content } // namespace gpu
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment