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

Side by Side Diff: content/browser/quota/mock_quota_manager.cc

Issue 1498003003: Remove kint64max. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: INT64_MAX Created 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/browser/quota/mock_quota_manager.h" 5 #include "content/browser/quota/mock_quota_manager.h"
6 6
7 #include <limits>
8
7 #include "base/location.h" 9 #include "base/location.h"
8 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
10 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
11 #include "base/thread_task_runner_handle.h" 13 #include "base/thread_task_runner_handle.h"
12 #include "url/gurl.h" 14 #include "url/gurl.h"
13 15
14 using storage::kQuotaStatusOk; 16 using storage::kQuotaStatusOk;
15 17
16 namespace content { 18 namespace content {
17 19
18 MockQuotaManager::OriginInfo::OriginInfo( 20 MockQuotaManager::OriginInfo::OriginInfo(
19 const GURL& origin, 21 const GURL& origin,
20 StorageType type, 22 StorageType type,
21 int quota_client_mask, 23 int quota_client_mask,
22 base::Time modified) 24 base::Time modified)
23 : origin(origin), 25 : origin(origin),
24 type(type), 26 type(type),
25 quota_client_mask(quota_client_mask), 27 quota_client_mask(quota_client_mask),
26 modified(modified) { 28 modified(modified) {
27 } 29 }
28 30
29 MockQuotaManager::OriginInfo::~OriginInfo() {} 31 MockQuotaManager::OriginInfo::~OriginInfo() {}
30 32
31 MockQuotaManager::StorageInfo::StorageInfo() : usage(0), quota(kint64max) {} 33 MockQuotaManager::StorageInfo::StorageInfo()
34 : usage(0), quota(std::numeric_limits<int64_t>::max()) {}
32 MockQuotaManager::StorageInfo::~StorageInfo() {} 35 MockQuotaManager::StorageInfo::~StorageInfo() {}
33 36
34 MockQuotaManager::MockQuotaManager( 37 MockQuotaManager::MockQuotaManager(
35 bool is_incognito, 38 bool is_incognito,
36 const base::FilePath& profile_path, 39 const base::FilePath& profile_path,
37 const scoped_refptr<base::SingleThreadTaskRunner>& io_thread, 40 const scoped_refptr<base::SingleThreadTaskRunner>& io_thread,
38 const scoped_refptr<base::SequencedTaskRunner>& db_thread, 41 const scoped_refptr<base::SequencedTaskRunner>& db_thread,
39 const scoped_refptr<SpecialStoragePolicy>& special_storage_policy) 42 const scoped_refptr<SpecialStoragePolicy>& special_storage_policy)
40 : QuotaManager(is_incognito, 43 : QuotaManager(is_incognito,
41 profile_path, 44 profile_path,
42 io_thread, 45 io_thread,
43 db_thread, 46 db_thread,
44 special_storage_policy), 47 special_storage_policy),
45 weak_factory_(this) { 48 weak_factory_(this) {
46 } 49 }
47 50
48 void MockQuotaManager::GetUsageAndQuota( 51 void MockQuotaManager::GetUsageAndQuota(
49 const GURL& origin, 52 const GURL& origin,
50 storage::StorageType type, 53 storage::StorageType type,
51 const GetUsageAndQuotaCallback& callback) { 54 const GetUsageAndQuotaCallback& callback) {
52 StorageInfo& info = usage_and_quota_map_[std::make_pair(origin, type)]; 55 StorageInfo& info = usage_and_quota_map_[std::make_pair(origin, type)];
53 callback.Run(storage::kQuotaStatusOk, info.usage, info.quota); 56 callback.Run(storage::kQuotaStatusOk, info.usage, info.quota);
54 } 57 }
55 58
56 void MockQuotaManager::SetQuota(const GURL& origin, StorageType type, 59 void MockQuotaManager::SetQuota(const GURL& origin,
57 int64 quota) { 60 StorageType type,
61 int64_t quota) {
58 usage_and_quota_map_[std::make_pair(origin, type)].quota = quota; 62 usage_and_quota_map_[std::make_pair(origin, type)].quota = quota;
59 } 63 }
60 64
61 bool MockQuotaManager::AddOrigin( 65 bool MockQuotaManager::AddOrigin(
62 const GURL& origin, 66 const GURL& origin,
63 StorageType type, 67 StorageType type,
64 int quota_client_mask, 68 int quota_client_mask,
65 base::Time modified) { 69 base::Time modified) {
66 origins_.push_back(OriginInfo(origin, type, quota_client_mask, modified)); 70 origins_.push_back(OriginInfo(origin, type, quota_client_mask, modified));
67 return true; 71 return true;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } 122 }
119 123
120 base::ThreadTaskRunnerHandle::Get()->PostTask( 124 base::ThreadTaskRunnerHandle::Get()->PostTask(
121 FROM_HERE, 125 FROM_HERE,
122 base::Bind(&MockQuotaManager::DidDeleteOriginData, 126 base::Bind(&MockQuotaManager::DidDeleteOriginData,
123 weak_factory_.GetWeakPtr(), callback, kQuotaStatusOk)); 127 weak_factory_.GetWeakPtr(), callback, kQuotaStatusOk));
124 } 128 }
125 129
126 MockQuotaManager::~MockQuotaManager() {} 130 MockQuotaManager::~MockQuotaManager() {}
127 131
128 void MockQuotaManager::UpdateUsage( 132 void MockQuotaManager::UpdateUsage(const GURL& origin,
129 const GURL& origin, StorageType type, int64 delta) { 133 StorageType type,
134 int64_t delta) {
130 usage_and_quota_map_[std::make_pair(origin, type)].usage += delta; 135 usage_and_quota_map_[std::make_pair(origin, type)].usage += delta;
131 } 136 }
132 137
133 void MockQuotaManager::DidGetModifiedSince( 138 void MockQuotaManager::DidGetModifiedSince(
134 const GetOriginsCallback& callback, 139 const GetOriginsCallback& callback,
135 std::set<GURL>* origins, 140 std::set<GURL>* origins,
136 StorageType storage_type) { 141 StorageType storage_type) {
137 callback.Run(*origins, storage_type); 142 callback.Run(*origins, storage_type);
138 } 143 }
139 144
140 void MockQuotaManager::DidDeleteOriginData( 145 void MockQuotaManager::DidDeleteOriginData(
141 const StatusCallback& callback, 146 const StatusCallback& callback,
142 QuotaStatusCode status) { 147 QuotaStatusCode status) {
143 callback.Run(status); 148 callback.Run(status);
144 } 149 }
145 150
146 } // namespace content 151 } // namespace content
OLDNEW
« 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