Skip to content

Commit

Permalink
gpu: Move ShaderDiskCache into //gpu/ipc/host component.
Browse files Browse the repository at this point in the history
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}
  • Loading branch information
sadrulhc authored and Commit bot committed Dec 10, 2016
1 parent 34f78aa commit 4a4522e
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 71 deletions.
2 changes: 0 additions & 2 deletions content/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -656,8 +656,6 @@ 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",
Expand Down
4 changes: 2 additions & 2 deletions content/browser/browser_main_loop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
#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"
Expand Down Expand Up @@ -91,6 +90,7 @@
#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"
Expand Down Expand Up @@ -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.
ShaderCacheFactory::InitInstance(
gpu::ShaderCacheFactory::InitInstance(
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
BrowserThread::GetTaskRunnerForThread(BrowserThread::CACHE));

Expand Down
5 changes: 3 additions & 2 deletions content/browser/gpu/browser_gpu_channel_host_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
#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"
#include "content/public/browser/gpu_data_manager.h"
#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"
Expand Down Expand Up @@ -371,7 +371,8 @@ void BrowserGpuChannelHostFactory::AddFilterOnIO(
void BrowserGpuChannelHostFactory::InitializeShaderDiskCacheOnIO(
int gpu_client_id,
const base::FilePath& cache_dir) {
ShaderCacheFactory::GetInstance()->SetCacheInfo(gpu_client_id, cache_dir);
gpu::ShaderCacheFactory::GetInstance()->SetCacheInfo(gpu_client_id,
cache_dir);
}

} // namespace content
6 changes: 3 additions & 3 deletions content/browser/gpu/gpu_process_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#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"
Expand All @@ -57,6 +56,7 @@
#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"
Expand Down Expand Up @@ -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<ShaderDiskCache> cache =
ShaderCacheFactory::GetInstance()->Get(client_id);
scoped_refptr<gpu::ShaderDiskCache> cache =
gpu::ShaderCacheFactory::GetInstance()->Get(client_id);
if (!cache.get())
return;

Expand Down
4 changes: 2 additions & 2 deletions content/browser/gpu/gpu_process_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ struct ChannelHandle;

namespace gpu {
struct GpuPreferences;
class ShaderDiskCache;
struct SyncToken;
}

Expand All @@ -52,7 +53,6 @@ class InterfaceProvider;
namespace content {
class BrowserChildProcessHostImpl;
class InProcessChildThreadParams;
class ShaderDiskCache;

typedef base::Thread* (*GpuMainThreadFactoryFunction)(
const InProcessChildThreadParams&, const gpu::GpuPreferences&);
Expand Down Expand Up @@ -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<ShaderDiskCache>>
typedef std::map<int32_t, scoped_refptr<gpu::ShaderDiskCache>>
ClientIdToShaderCacheMap;
ClientIdToShaderCacheMap client_id_to_shader_cache_;

Expand Down
10 changes: 5 additions & 5 deletions content/browser/renderer_host/render_process_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
#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"
Expand Down Expand Up @@ -170,6 +169,7 @@
#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"
Expand Down Expand Up @@ -261,13 +261,13 @@ const base::FilePath::CharType kAecDumpFileNameAddition[] =
#endif

void CacheShaderInfo(int32_t id, base::FilePath path) {
if (ShaderCacheFactory::GetInstance())
ShaderCacheFactory::GetInstance()->SetCacheInfo(id, path);
if (gpu::ShaderCacheFactory::GetInstance())
gpu::ShaderCacheFactory::GetInstance()->SetCacheInfo(id, path);
}

void RemoveShaderInfo(int32_t id) {
if (ShaderCacheFactory::GetInstance())
ShaderCacheFactory::GetInstance()->RemoveCacheInfo(id);
if (gpu::ShaderCacheFactory::GetInstance())
gpu::ShaderCacheFactory::GetInstance()->RemoveCacheInfo(id);
}

net::URLRequestContext* GetRequestContext(
Expand Down
4 changes: 2 additions & 2 deletions content/browser/storage_partition_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#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"
Expand All @@ -26,6 +25,7 @@
#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"
Expand Down Expand Up @@ -132,7 +132,7 @@ void ClearShaderCacheOnIOThread(const base::FilePath& path,
const base::Time end,
const base::Closure& callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
ShaderCacheFactory::GetInstance()->ClearByPath(
gpu::ShaderCacheFactory::GetInstance()->ClearByPath(
path, begin, end, base::Bind(&ClearedShaderCache, callback));
}

Expand Down
16 changes: 8 additions & 8 deletions content/browser/storage_partition_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#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"
Expand All @@ -22,6 +21,7 @@
#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"
Expand Down Expand Up @@ -602,19 +602,19 @@ class StoragePartitionShaderClearTest : public testing::Test {
StoragePartitionShaderClearTest()
: thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP),
browser_context_(new TestBrowserContext()) {
ShaderCacheFactory::InitInstance(
gpu::ShaderCacheFactory::InitInstance(
base::ThreadTaskRunnerHandle::Get(),
BrowserThread::GetTaskRunnerForThread(BrowserThread::CACHE));
ShaderCacheFactory::GetInstance()->SetCacheInfo(
gpu::ShaderCacheFactory::GetInstance()->SetCacheInfo(
kDefaultClientId,
BrowserContext::GetDefaultStoragePartition(
browser_context())->GetPath());
cache_ = ShaderCacheFactory::GetInstance()->Get(kDefaultClientId);
BrowserContext::GetDefaultStoragePartition(browser_context())
->GetPath());
cache_ = gpu::ShaderCacheFactory::GetInstance()->Get(kDefaultClientId);
}

~StoragePartitionShaderClearTest() override {
cache_ = NULL;
ShaderCacheFactory::GetInstance()->RemoveCacheInfo(kDefaultClientId);
gpu::ShaderCacheFactory::GetInstance()->RemoveCacheInfo(kDefaultClientId);
}

void InitCache() {
Expand All @@ -641,7 +641,7 @@ class StoragePartitionShaderClearTest : public testing::Test {
content::TestBrowserThreadBundle thread_bundle_;
std::unique_ptr<TestBrowserContext> browser_context_;

scoped_refptr<ShaderDiskCache> cache_;
scoped_refptr<gpu::ShaderDiskCache> cache_;
};

// Tests ---------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion content/test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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_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",
Expand Down Expand Up @@ -1407,6 +1406,7 @@ test("content_unittests") {
"//gin",
"//gpu",
"//gpu:test_support",
"//gpu/ipc/host",
"//ipc:test_support",
"//media:shared_memory_support",
"//media:test_support",
Expand Down
3 changes: 3 additions & 0 deletions gpu/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ 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) {
Expand All @@ -326,8 +327,10 @@ 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",
Expand Down
3 changes: 3 additions & 0 deletions gpu/ipc/host/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ 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",
]
Expand Down
3 changes: 3 additions & 0 deletions gpu/ipc/host/DEPS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include_rules = [
"+net",
]
Original file line number Diff line number Diff line change
Expand Up @@ -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 "content/browser/gpu/shader_disk_cache.h"
#include "gpu/ipc/host/shader_disk_cache.h"

#include "base/macros.h"
#include "base/memory/ptr_util.h"
Expand All @@ -13,7 +13,7 @@
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"

namespace content {
namespace gpu {

namespace {

Expand Down Expand Up @@ -79,7 +79,6 @@ class ShaderDiskReadHelper : public base::ThreadChecker {
ITERATION_FINISHED
};


void OnOpComplete(int rv);

int OpenNextEntry();
Expand Down Expand Up @@ -110,11 +109,7 @@ 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);

Expand Down Expand Up @@ -393,8 +388,7 @@ 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(
Expand Down Expand Up @@ -500,9 +494,7 @@ 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);
}

Expand Down Expand Up @@ -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)));
}

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;
}
Expand Down Expand Up @@ -603,5 +595,4 @@ int ShaderDiskCache::SetCacheCompleteCallback(
return net::ERR_IO_PENDING;
}

} // namespace content

} // namespace gpu
Loading

0 comments on commit 4a4522e

Please sign in to comment.