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

Unified Diff: content/browser/cache_storage/cache_storage_manager_unittest.cc

Issue 1636613002: [CacheStorage] Check quota before put operations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Set quota per origin and fix order of operations error Created 4 years, 11 months 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
Index: content/browser/cache_storage/cache_storage_manager_unittest.cc
diff --git a/content/browser/cache_storage/cache_storage_manager_unittest.cc b/content/browser/cache_storage/cache_storage_manager_unittest.cc
index f8d94976e2bc33004aac54696cfaae87cea18f17..0f549f62aa9d14b4f5ef32807cb2700ff7e3bf32 100644
--- a/content/browser/cache_storage/cache_storage_manager_unittest.cc
+++ b/content/browser/cache_storage/cache_storage_manager_unittest.cc
@@ -24,6 +24,7 @@
#include "content/browser/quota/mock_quota_manager_proxy.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/cache_storage_usage_info.h"
+#include "content/public/test/mock_special_storage_policy.h"
#include "content/public/test/test_browser_context.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "net/url_request/url_request_context.h"
@@ -75,19 +76,25 @@ class CacheStorageManagerTest : public testing::Test {
url_request_context->set_job_factory(url_request_job_factory_.get());
+ if (!MemoryOnly())
+ ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
+
+ quota_policy_ = new MockSpecialStoragePolicy;
+ mock_quota_manager_ = new MockQuotaManager(
+ MemoryOnly() /* is incognito */, temp_dir_.path(),
+ base::ThreadTaskRunnerHandle::Get().get(),
+ base::ThreadTaskRunnerHandle::Get().get(), quota_policy_.get());
+ mock_quota_manager_->SetQuota(
+ GURL(origin1_), storage::kStorageTypeTemporary, 1024 * 1024 * 100);
+ mock_quota_manager_->SetQuota(
+ GURL(origin2_), storage::kStorageTypeTemporary, 1024 * 1024 * 100);
+
quota_manager_proxy_ = new MockQuotaManagerProxy(
- nullptr, base::ThreadTaskRunnerHandle::Get().get());
+ mock_quota_manager_.get(), base::ThreadTaskRunnerHandle::Get().get());
- if (MemoryOnly()) {
- cache_manager_ = CacheStorageManager::Create(
- base::FilePath(), base::ThreadTaskRunnerHandle::Get(),
- quota_manager_proxy_);
- } else {
- ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
- cache_manager_ = CacheStorageManager::Create(
- temp_dir_.path(), base::ThreadTaskRunnerHandle::Get(),
- quota_manager_proxy_);
- }
+ cache_manager_ = CacheStorageManager::Create(
+ temp_dir_.path(), base::ThreadTaskRunnerHandle::Get(),
+ quota_manager_proxy_);
cache_manager_->SetBlobParametersForCache(
browser_context_.GetRequestContext(),
@@ -307,6 +314,8 @@ class CacheStorageManagerTest : public testing::Test {
scoped_ptr<net::URLRequestJobFactoryImpl> url_request_job_factory_;
storage::BlobStorageContext* blob_storage_context_;
+ scoped_refptr<MockSpecialStoragePolicy> quota_policy_;
+ scoped_refptr<MockQuotaManager> mock_quota_manager_;
scoped_refptr<MockQuotaManagerProxy> quota_manager_proxy_;
scoped_ptr<CacheStorageManager> cache_manager_;
« no previous file with comments | « content/browser/cache_storage/cache_storage_dispatcher_host.cc ('k') | content/browser/quota/mock_quota_manager_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698