Commit a3533cd7 authored by gab's avatar gab Committed by Commit bot

Revert of gpu: Move ShaderDiskCache into //gpu/ipc/host component. (patchset...

Revert of gpu: Move ShaderDiskCache into //gpu/ipc/host component. (patchset #5 id:80001 of https://codereview.chromium.org/2555693005/ )

Reason for revert:
Makes StoragePartitionShaderClearTest.ClearShaderCache fail on Linux Tests bot: https://build.chromium.org/p/chromium.linux/builders/Linux%20Tests%20%28dbg%29%281%29

Original issue's description:
> 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

TBR=piman@chromium.org,rch@chromium.org,rsleevi@chromium.org,ben@chromium.org,sadrul@chromium.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=643746, 604369

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