OLD | NEW |
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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "content/public/test/mock_special_storage_policy.h" | 7 #include "content/public/test/mock_special_storage_policy.h" |
8 #include "net/base/net_util.h" | 8 #include "net/base/net_util.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "webkit/browser/quota/usage_tracker.h" | 10 #include "webkit/browser/quota/usage_tracker.h" |
11 | 11 |
12 using quota::kQuotaStatusOk; | 12 using storage::kQuotaStatusOk; |
13 using quota::kStorageTypeTemporary; | 13 using storage::kStorageTypeTemporary; |
14 using quota::QuotaClient; | 14 using storage::QuotaClient; |
15 using quota::QuotaClientList; | 15 using storage::QuotaClientList; |
16 using quota::SpecialStoragePolicy; | 16 using storage::SpecialStoragePolicy; |
17 using quota::StorageType; | 17 using storage::StorageType; |
18 using quota::UsageTracker; | 18 using storage::UsageTracker; |
19 | 19 |
20 namespace content { | 20 namespace content { |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 void DidGetGlobalUsage(bool* done, | 24 void DidGetGlobalUsage(bool* done, |
25 int64* usage_out, | 25 int64* usage_out, |
26 int64* unlimited_usage_out, | 26 int64* unlimited_usage_out, |
27 int64 usage, | 27 int64 usage, |
28 int64 unlimited_usage) { | 28 int64 unlimited_usage) { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 90 |
91 virtual void DeleteOriginData(const GURL& origin, | 91 virtual void DeleteOriginData(const GURL& origin, |
92 StorageType type, | 92 StorageType type, |
93 const DeletionCallback& callback) OVERRIDE { | 93 const DeletionCallback& callback) OVERRIDE { |
94 EXPECT_EQ(kStorageTypeTemporary, type); | 94 EXPECT_EQ(kStorageTypeTemporary, type); |
95 usage_map_.erase(origin); | 95 usage_map_.erase(origin); |
96 base::MessageLoop::current()->PostTask( | 96 base::MessageLoop::current()->PostTask( |
97 FROM_HERE, base::Bind(callback, kQuotaStatusOk)); | 97 FROM_HERE, base::Bind(callback, kQuotaStatusOk)); |
98 } | 98 } |
99 | 99 |
100 virtual bool DoesSupport(quota::StorageType type) const OVERRIDE { | 100 virtual bool DoesSupport(storage::StorageType type) const OVERRIDE { |
101 return type == quota::kStorageTypeTemporary; | 101 return type == storage::kStorageTypeTemporary; |
102 } | 102 } |
103 | 103 |
104 int64 GetUsage(const GURL& origin) { | 104 int64 GetUsage(const GURL& origin) { |
105 UsageMap::const_iterator found = usage_map_.find(origin); | 105 UsageMap::const_iterator found = usage_map_.find(origin); |
106 if (found == usage_map_.end()) | 106 if (found == usage_map_.end()) |
107 return 0; | 107 return 0; |
108 return found->second; | 108 return found->second; |
109 } | 109 } |
110 | 110 |
111 void SetUsage(const GURL& origin, int64 usage) { | 111 void SetUsage(const GURL& origin, int64 usage) { |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 | 327 |
328 GetGlobalLimitedUsage(&limited_usage); | 328 GetGlobalLimitedUsage(&limited_usage); |
329 GetGlobalUsage(&total_usage, &unlimited_usage); | 329 GetGlobalUsage(&total_usage, &unlimited_usage); |
330 EXPECT_EQ(1 + 16, limited_usage); | 330 EXPECT_EQ(1 + 16, limited_usage); |
331 EXPECT_EQ(1 + 2 + 16 + 32, total_usage); | 331 EXPECT_EQ(1 + 2 + 16 + 32, total_usage); |
332 EXPECT_EQ(2 + 32, unlimited_usage); | 332 EXPECT_EQ(2 + 32, unlimited_usage); |
333 } | 333 } |
334 | 334 |
335 | 335 |
336 } // namespace content | 336 } // namespace content |
OLD | NEW |