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

Unified Diff: content/browser/quota/mock_quota_manager.cc

Issue 2368913003: Populate storage_unittests target. (Closed)
Patch Set: Removed unnecessary include from storage/browser/blob/blob_storage_context_unittest.cc. Created 4 years, 3 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
« no previous file with comments | « content/browser/quota/mock_quota_manager.h ('k') | content/browser/quota/mock_quota_manager_proxy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/quota/mock_quota_manager.cc
diff --git a/content/browser/quota/mock_quota_manager.cc b/content/browser/quota/mock_quota_manager.cc
deleted file mode 100644
index 73407970de53a73d28cea6edf0eadad2994108eb..0000000000000000000000000000000000000000
--- a/content/browser/quota/mock_quota_manager.cc
+++ /dev/null
@@ -1,151 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "content/browser/quota/mock_quota_manager.h"
-
-#include <limits>
-#include <memory>
-
-#include "base/location.h"
-#include "base/memory/ref_counted.h"
-#include "base/single_thread_task_runner.h"
-#include "base/threading/thread_task_runner_handle.h"
-#include "url/gurl.h"
-
-using storage::kQuotaStatusOk;
-
-namespace content {
-
-MockQuotaManager::OriginInfo::OriginInfo(
- const GURL& origin,
- StorageType type,
- int quota_client_mask,
- base::Time modified)
- : origin(origin),
- type(type),
- quota_client_mask(quota_client_mask),
- modified(modified) {
-}
-
-MockQuotaManager::OriginInfo::~OriginInfo() {}
-
-MockQuotaManager::StorageInfo::StorageInfo()
- : usage(0), quota(std::numeric_limits<int64_t>::max()) {}
-MockQuotaManager::StorageInfo::~StorageInfo() {}
-
-MockQuotaManager::MockQuotaManager(
- bool is_incognito,
- const base::FilePath& profile_path,
- const scoped_refptr<base::SingleThreadTaskRunner>& io_thread,
- const scoped_refptr<base::SequencedTaskRunner>& db_thread,
- const scoped_refptr<SpecialStoragePolicy>& special_storage_policy)
- : QuotaManager(is_incognito,
- profile_path,
- io_thread,
- db_thread,
- special_storage_policy),
- weak_factory_(this) {
-}
-
-void MockQuotaManager::GetUsageAndQuota(
- const GURL& origin,
- storage::StorageType type,
- const GetUsageAndQuotaCallback& callback) {
- StorageInfo& info = usage_and_quota_map_[std::make_pair(origin, type)];
- callback.Run(storage::kQuotaStatusOk, info.usage, info.quota);
-}
-
-void MockQuotaManager::SetQuota(const GURL& origin,
- StorageType type,
- int64_t quota) {
- usage_and_quota_map_[std::make_pair(origin, type)].quota = quota;
-}
-
-bool MockQuotaManager::AddOrigin(
- const GURL& origin,
- StorageType type,
- int quota_client_mask,
- base::Time modified) {
- origins_.push_back(OriginInfo(origin, type, quota_client_mask, modified));
- return true;
-}
-
-bool MockQuotaManager::OriginHasData(
- const GURL& origin,
- StorageType type,
- QuotaClient::ID quota_client) const {
- for (std::vector<OriginInfo>::const_iterator current = origins_.begin();
- current != origins_.end();
- ++current) {
- if (current->origin == origin &&
- current->type == type &&
- current->quota_client_mask & quota_client)
- return true;
- }
- return false;
-}
-
-void MockQuotaManager::GetOriginsModifiedSince(
- StorageType type,
- base::Time modified_since,
- const GetOriginsCallback& callback) {
- std::set<GURL>* origins_to_return = new std::set<GURL>();
- for (std::vector<OriginInfo>::const_iterator current = origins_.begin();
- current != origins_.end();
- ++current) {
- if (current->type == type && current->modified >= modified_since)
- origins_to_return->insert(current->origin);
- }
-
- base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(&MockQuotaManager::DidGetModifiedSince,
- weak_factory_.GetWeakPtr(), callback,
- base::Owned(origins_to_return), type));
-}
-
-void MockQuotaManager::DeleteOriginData(
- const GURL& origin,
- StorageType type,
- int quota_client_mask,
- const StatusCallback& callback) {
- for (std::vector<OriginInfo>::iterator current = origins_.begin();
- current != origins_.end();
- ++current) {
- if (current->origin == origin && current->type == type) {
- // Modify the mask: if it's 0 after "deletion", remove the origin.
- current->quota_client_mask &= ~quota_client_mask;
- if (current->quota_client_mask == 0)
- origins_.erase(current);
- break;
- }
- }
-
- base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE,
- base::Bind(&MockQuotaManager::DidDeleteOriginData,
- weak_factory_.GetWeakPtr(), callback, kQuotaStatusOk));
-}
-
-MockQuotaManager::~MockQuotaManager() {}
-
-void MockQuotaManager::UpdateUsage(const GURL& origin,
- StorageType type,
- int64_t delta) {
- usage_and_quota_map_[std::make_pair(origin, type)].usage += delta;
-}
-
-void MockQuotaManager::DidGetModifiedSince(
- const GetOriginsCallback& callback,
- std::set<GURL>* origins,
- StorageType storage_type) {
- callback.Run(*origins, storage_type);
-}
-
-void MockQuotaManager::DidDeleteOriginData(
- const StatusCallback& callback,
- QuotaStatusCode status) {
- callback.Run(status);
-}
-
-} // namespace content
« no previous file with comments | « content/browser/quota/mock_quota_manager.h ('k') | content/browser/quota/mock_quota_manager_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698