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

Side by Side Diff: content/browser/storage_partition_impl_unittest.cc

Issue 2565243002: Revert of gpu: Move ShaderDiskCache into //gpu/ipc/host component. (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 unified diff | Download patch
« no previous file with comments | « content/browser/storage_partition_impl.cc ('k') | content/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
13 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
14 #include "base/threading/thread_task_runner_handle.h" 14 #include "base/threading/thread_task_runner_handle.h"
15 #include "content/browser/browser_thread_impl.h" 15 #include "content/browser/browser_thread_impl.h"
16 #include "content/browser/gpu/shader_disk_cache.h"
16 #include "content/browser/quota/mock_quota_manager.h" 17 #include "content/browser/quota/mock_quota_manager.h"
17 #include "content/browser/storage_partition_impl.h" 18 #include "content/browser/storage_partition_impl.h"
18 #include "content/public/browser/local_storage_usage_info.h" 19 #include "content/public/browser/local_storage_usage_info.h"
19 #include "content/public/browser/storage_partition.h" 20 #include "content/public/browser/storage_partition.h"
20 #include "content/public/test/mock_special_storage_policy.h" 21 #include "content/public/test/mock_special_storage_policy.h"
21 #include "content/public/test/test_browser_context.h" 22 #include "content/public/test/test_browser_context.h"
22 #include "content/public/test/test_browser_thread.h" 23 #include "content/public/test/test_browser_thread.h"
23 #include "content/public/test/test_browser_thread_bundle.h" 24 #include "content/public/test/test_browser_thread_bundle.h"
24 #include "gpu/ipc/host/shader_disk_cache.h"
25 #include "net/base/test_completion_callback.h" 25 #include "net/base/test_completion_callback.h"
26 #include "net/cookies/canonical_cookie.h" 26 #include "net/cookies/canonical_cookie.h"
27 #include "net/cookies/cookie_store.h" 27 #include "net/cookies/cookie_store.h"
28 #include "net/url_request/url_request_context.h" 28 #include "net/url_request/url_request_context.h"
29 #include "net/url_request/url_request_context_getter.h" 29 #include "net/url_request/url_request_context_getter.h"
30 #include "ppapi/features/features.h" 30 #include "ppapi/features/features.h"
31 #include "storage/browser/quota/quota_manager.h" 31 #include "storage/browser/quota/quota_manager.h"
32 #include "testing/gtest/include/gtest/gtest.h" 32 #include "testing/gtest/include/gtest/gtest.h"
33 33
34 #if BUILDFLAG(ENABLE_PLUGINS) 34 #if BUILDFLAG(ENABLE_PLUGINS)
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 scoped_refptr<MockQuotaManager> quota_manager_; 595 scoped_refptr<MockQuotaManager> quota_manager_;
596 596
597 DISALLOW_COPY_AND_ASSIGN(StoragePartitionImplTest); 597 DISALLOW_COPY_AND_ASSIGN(StoragePartitionImplTest);
598 }; 598 };
599 599
600 class StoragePartitionShaderClearTest : public testing::Test { 600 class StoragePartitionShaderClearTest : public testing::Test {
601 public: 601 public:
602 StoragePartitionShaderClearTest() 602 StoragePartitionShaderClearTest()
603 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), 603 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP),
604 browser_context_(new TestBrowserContext()) { 604 browser_context_(new TestBrowserContext()) {
605 gpu::ShaderCacheFactory::InitInstance( 605 ShaderCacheFactory::InitInstance(
606 base::ThreadTaskRunnerHandle::Get(), 606 base::ThreadTaskRunnerHandle::Get(),
607 BrowserThread::GetTaskRunnerForThread(BrowserThread::CACHE)); 607 BrowserThread::GetTaskRunnerForThread(BrowserThread::CACHE));
608 gpu::ShaderCacheFactory::GetInstance()->SetCacheInfo( 608 ShaderCacheFactory::GetInstance()->SetCacheInfo(
609 kDefaultClientId, 609 kDefaultClientId,
610 BrowserContext::GetDefaultStoragePartition(browser_context()) 610 BrowserContext::GetDefaultStoragePartition(
611 ->GetPath()); 611 browser_context())->GetPath());
612 cache_ = gpu::ShaderCacheFactory::GetInstance()->Get(kDefaultClientId); 612 cache_ = ShaderCacheFactory::GetInstance()->Get(kDefaultClientId);
613 } 613 }
614 614
615 ~StoragePartitionShaderClearTest() override { 615 ~StoragePartitionShaderClearTest() override {
616 cache_ = NULL; 616 cache_ = NULL;
617 gpu::ShaderCacheFactory::GetInstance()->RemoveCacheInfo(kDefaultClientId); 617 ShaderCacheFactory::GetInstance()->RemoveCacheInfo(kDefaultClientId);
618 } 618 }
619 619
620 void InitCache() { 620 void InitCache() {
621 net::TestCompletionCallback available_cb; 621 net::TestCompletionCallback available_cb;
622 int rv = cache_->SetAvailableCallback(available_cb.callback()); 622 int rv = cache_->SetAvailableCallback(available_cb.callback());
623 ASSERT_EQ(net::OK, available_cb.GetResult(rv)); 623 ASSERT_EQ(net::OK, available_cb.GetResult(rv));
624 EXPECT_EQ(0, cache_->Size()); 624 EXPECT_EQ(0, cache_->Size());
625 625
626 cache_->Cache(kCacheKey, kCacheValue); 626 cache_->Cache(kCacheKey, kCacheValue);
627 627
628 net::TestCompletionCallback complete_cb; 628 net::TestCompletionCallback complete_cb;
629 629
630 rv = cache_->SetCacheCompleteCallback(complete_cb.callback()); 630 rv = cache_->SetCacheCompleteCallback(complete_cb.callback());
631 ASSERT_EQ(net::OK, complete_cb.GetResult(rv)); 631 ASSERT_EQ(net::OK, complete_cb.GetResult(rv));
632 } 632 }
633 633
634 size_t Size() { return cache_->Size(); } 634 size_t Size() { return cache_->Size(); }
635 635
636 TestBrowserContext* browser_context() { 636 TestBrowserContext* browser_context() {
637 return browser_context_.get(); 637 return browser_context_.get();
638 } 638 }
639 639
640 private: 640 private:
641 content::TestBrowserThreadBundle thread_bundle_; 641 content::TestBrowserThreadBundle thread_bundle_;
642 std::unique_ptr<TestBrowserContext> browser_context_; 642 std::unique_ptr<TestBrowserContext> browser_context_;
643 643
644 scoped_refptr<gpu::ShaderDiskCache> cache_; 644 scoped_refptr<ShaderDiskCache> cache_;
645 }; 645 };
646 646
647 // Tests --------------------------------------------------------------------- 647 // Tests ---------------------------------------------------------------------
648 648
649 TEST_F(StoragePartitionShaderClearTest, ClearShaderCache) { 649 TEST_F(StoragePartitionShaderClearTest, ClearShaderCache) {
650 InitCache(); 650 InitCache();
651 EXPECT_EQ(1u, Size()); 651 EXPECT_EQ(1u, Size());
652 652
653 base::RunLoop run_loop; 653 base::RunLoop run_loop;
654 base::ThreadTaskRunnerHandle::Get()->PostTask( 654 base::ThreadTaskRunnerHandle::Get()->PostTask(
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 CanonicalCookie::Create(url2, "A=B;domain=.example.com", now, options)); 1316 CanonicalCookie::Create(url2, "A=B;domain=.example.com", now, options));
1317 invalid_cookies.push_back(CanonicalCookie::Create(url3, "A=B", now, options)); 1317 invalid_cookies.push_back(CanonicalCookie::Create(url3, "A=B", now, options));
1318 1318
1319 for (const auto& cookie : valid_cookies) 1319 for (const auto& cookie : valid_cookies)
1320 EXPECT_TRUE(predicate.Run(*cookie)) << cookie->DebugString(); 1320 EXPECT_TRUE(predicate.Run(*cookie)) << cookie->DebugString();
1321 for (const auto& cookie : invalid_cookies) 1321 for (const auto& cookie : invalid_cookies)
1322 EXPECT_FALSE(predicate.Run(*cookie)) << cookie->DebugString(); 1322 EXPECT_FALSE(predicate.Run(*cookie)) << cookie->DebugString();
1323 } 1323 }
1324 1324
1325 } // namespace content 1325 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/storage_partition_impl.cc ('k') | content/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698