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

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

Issue 667943003: Standardize usage of virtual/override/final in content/browser/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 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 <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 17 matching lines...) Expand all
28 namespace { 28 namespace {
29 29
30 class MockQuotaEvictionHandler : public storage::QuotaEvictionHandler { 30 class MockQuotaEvictionHandler : public storage::QuotaEvictionHandler {
31 public: 31 public:
32 explicit MockQuotaEvictionHandler(QuotaTemporaryStorageEvictorTest *test) 32 explicit MockQuotaEvictionHandler(QuotaTemporaryStorageEvictorTest *test)
33 : quota_(0), 33 : quota_(0),
34 available_space_(0), 34 available_space_(0),
35 error_on_evict_origin_data_(false), 35 error_on_evict_origin_data_(false),
36 error_on_get_usage_and_quota_(false) {} 36 error_on_get_usage_and_quota_(false) {}
37 37
38 virtual void EvictOriginData( 38 void EvictOriginData(const GURL& origin,
39 const GURL& origin, 39 StorageType type,
40 StorageType type, 40 const EvictOriginDataCallback& callback) override {
41 const EvictOriginDataCallback& callback) override {
42 if (error_on_evict_origin_data_) { 41 if (error_on_evict_origin_data_) {
43 callback.Run(storage::kQuotaErrorInvalidModification); 42 callback.Run(storage::kQuotaErrorInvalidModification);
44 return; 43 return;
45 } 44 }
46 int64 origin_usage = EnsureOriginRemoved(origin); 45 int64 origin_usage = EnsureOriginRemoved(origin);
47 if (origin_usage >= 0) 46 if (origin_usage >= 0)
48 available_space_ += origin_usage; 47 available_space_ += origin_usage;
49 callback.Run(storage::kQuotaStatusOk); 48 callback.Run(storage::kQuotaStatusOk);
50 } 49 }
51 50
52 virtual void GetUsageAndQuotaForEviction( 51 void GetUsageAndQuotaForEviction(
53 const UsageAndQuotaCallback& callback) override { 52 const UsageAndQuotaCallback& callback) override {
54 if (error_on_get_usage_and_quota_) { 53 if (error_on_get_usage_and_quota_) {
55 callback.Run(storage::kQuotaErrorInvalidAccess, UsageAndQuota()); 54 callback.Run(storage::kQuotaErrorInvalidAccess, UsageAndQuota());
56 return; 55 return;
57 } 56 }
58 if (!task_for_get_usage_and_quota_.is_null()) 57 if (!task_for_get_usage_and_quota_.is_null())
59 task_for_get_usage_and_quota_.Run(); 58 task_for_get_usage_and_quota_.Run();
60 UsageAndQuota quota_and_usage(-1, GetUsage(), quota_, available_space_); 59 UsageAndQuota quota_and_usage(-1, GetUsage(), quota_, available_space_);
61 callback.Run(storage::kQuotaStatusOk, quota_and_usage); 60 callback.Run(storage::kQuotaStatusOk, quota_and_usage);
62 } 61 }
63 62
64 virtual void GetLRUOrigin( 63 void GetLRUOrigin(StorageType type,
65 StorageType type, 64 const GetLRUOriginCallback& callback) override {
66 const GetLRUOriginCallback& callback) override {
67 if (origin_order_.empty()) 65 if (origin_order_.empty())
68 callback.Run(GURL()); 66 callback.Run(GURL());
69 else 67 else
70 callback.Run(GURL(origin_order_.front())); 68 callback.Run(GURL(origin_order_.front()));
71 } 69 }
72 70
73 int64 GetUsage() const { 71 int64 GetUsage() const {
74 int64 total_usage = 0; 72 int64 total_usage = 0;
75 for (std::map<GURL, int64>::const_iterator p = origins_.begin(); 73 for (std::map<GURL, int64>::const_iterator p = origins_.begin();
76 p != origins_.end(); 74 p != origins_.end();
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 EXPECT_EQ(150 + 300, quota_eviction_handler()->GetUsage()); 403 EXPECT_EQ(150 + 300, quota_eviction_handler()->GetUsage());
406 404
407 EXPECT_EQ(0, statistics().num_errors_on_evicting_origin); 405 EXPECT_EQ(0, statistics().num_errors_on_evicting_origin);
408 EXPECT_EQ(0, statistics().num_errors_on_getting_usage_and_quota); 406 EXPECT_EQ(0, statistics().num_errors_on_getting_usage_and_quota);
409 EXPECT_EQ(2, statistics().num_evicted_origins); 407 EXPECT_EQ(2, statistics().num_evicted_origins);
410 EXPECT_EQ(1, statistics().num_eviction_rounds); 408 EXPECT_EQ(1, statistics().num_eviction_rounds);
411 EXPECT_EQ(0, statistics().num_skipped_eviction_rounds); 409 EXPECT_EQ(0, statistics().num_skipped_eviction_rounds);
412 } 410 }
413 411
414 } // namespace content 412 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/quota/quota_reservation_manager_unittest.cc ('k') | content/browser/quota/storage_monitor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698