OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <list> | 5 #include <list> |
6 #include <map> | 6 #include <map> |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 class MockQuotaEvictionHandler : public quota::QuotaEvictionHandler { | 26 class MockQuotaEvictionHandler : public quota::QuotaEvictionHandler { |
27 public: | 27 public: |
28 explicit MockQuotaEvictionHandler(QuotaTemporaryStorageEvictorTest *test) | 28 explicit MockQuotaEvictionHandler(QuotaTemporaryStorageEvictorTest *test) |
29 : quota_(0), | 29 : quota_(0), |
30 unlimited_usage_(0), | 30 unlimited_usage_(0), |
31 available_space_(0), | 31 available_space_(0), |
32 error_on_evict_origin_data_(false), | 32 error_on_evict_origin_data_(false), |
33 error_on_get_usage_and_quota_(false), | 33 error_on_get_usage_and_quota_(false) {} |
34 test_(test) {} | |
35 | 34 |
36 virtual void EvictOriginData( | 35 virtual void EvictOriginData( |
37 const GURL& origin, | 36 const GURL& origin, |
38 StorageType type, | 37 StorageType type, |
39 const EvictOriginDataCallback& callback) OVERRIDE { | 38 const EvictOriginDataCallback& callback) OVERRIDE { |
40 if (error_on_evict_origin_data_) { | 39 if (error_on_evict_origin_data_) { |
41 callback.Run(quota::kQuotaErrorInvalidModification); | 40 callback.Run(quota::kQuotaErrorInvalidModification); |
42 return; | 41 return; |
43 } | 42 } |
44 int64 origin_usage = EnsureOriginRemoved(origin); | 43 int64 origin_usage = EnsureOriginRemoved(origin); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 } | 127 } |
129 | 128 |
130 int64 quota_; | 129 int64 quota_; |
131 int64 unlimited_usage_; | 130 int64 unlimited_usage_; |
132 int64 available_space_; | 131 int64 available_space_; |
133 std::list<GURL> origin_order_; | 132 std::list<GURL> origin_order_; |
134 std::map<GURL, int64> origins_; | 133 std::map<GURL, int64> origins_; |
135 bool error_on_evict_origin_data_; | 134 bool error_on_evict_origin_data_; |
136 bool error_on_get_usage_and_quota_; | 135 bool error_on_get_usage_and_quota_; |
137 | 136 |
138 QuotaTemporaryStorageEvictorTest *test_; | |
139 base::Closure task_for_get_usage_and_quota_; | 137 base::Closure task_for_get_usage_and_quota_; |
140 }; | 138 }; |
141 | 139 |
142 } // anonymous namespace | 140 } // anonymous namespace |
143 | 141 |
144 class QuotaTemporaryStorageEvictorTest : public testing::Test { | 142 class QuotaTemporaryStorageEvictorTest : public testing::Test { |
145 public: | 143 public: |
146 QuotaTemporaryStorageEvictorTest() | 144 QuotaTemporaryStorageEvictorTest() |
147 : num_get_usage_and_quota_for_eviction_(0), | 145 : num_get_usage_and_quota_for_eviction_(0), |
148 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {} | 146 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {} |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 quota_eviction_handler()->set_available_space(1000000000); | 423 quota_eviction_handler()->set_available_space(1000000000); |
426 EXPECT_EQ(3000 + 200 + 500000, quota_eviction_handler()->GetUsage()); | 424 EXPECT_EQ(3000 + 200 + 500000, quota_eviction_handler()->GetUsage()); |
427 set_repeated_eviction(false); | 425 set_repeated_eviction(false); |
428 temporary_storage_evictor()->Start(); | 426 temporary_storage_evictor()->Start(); |
429 MessageLoop::current()->RunAllPending(); | 427 MessageLoop::current()->RunAllPending(); |
430 // Nothing should have been evicted. | 428 // Nothing should have been evicted. |
431 EXPECT_EQ(3000 + 200 + 500000, quota_eviction_handler()->GetUsage()); | 429 EXPECT_EQ(3000 + 200 + 500000, quota_eviction_handler()->GetUsage()); |
432 } | 430 } |
433 | 431 |
434 } // namespace quota | 432 } // namespace quota |
OLD | NEW |