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

Side by Side Diff: content/browser/quota/usage_tracker_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 "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 "storage/browser/quota/usage_tracker.h" 9 #include "storage/browser/quota/usage_tracker.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 27 matching lines...) Expand all
38 EXPECT_FALSE(*done); 38 EXPECT_FALSE(*done);
39 *done = true; 39 *done = true;
40 *usage_out = usage; 40 *usage_out = usage;
41 } 41 }
42 42
43 } // namespace 43 } // namespace
44 44
45 class MockQuotaClient : public QuotaClient { 45 class MockQuotaClient : public QuotaClient {
46 public: 46 public:
47 MockQuotaClient() {} 47 MockQuotaClient() {}
48 virtual ~MockQuotaClient() {} 48 ~MockQuotaClient() override {}
49 49
50 virtual ID id() const override { 50 ID id() const override { return kFileSystem; }
51 return kFileSystem;
52 }
53 51
54 virtual void OnQuotaManagerDestroyed() override {} 52 void OnQuotaManagerDestroyed() override {}
55 53
56 virtual void GetOriginUsage(const GURL& origin, 54 void GetOriginUsage(const GURL& origin,
57 StorageType type, 55 StorageType type,
58 const GetUsageCallback& callback) override { 56 const GetUsageCallback& callback) override {
59 EXPECT_EQ(kStorageTypeTemporary, type); 57 EXPECT_EQ(kStorageTypeTemporary, type);
60 int64 usage = GetUsage(origin); 58 int64 usage = GetUsage(origin);
61 base::MessageLoop::current()->PostTask(FROM_HERE, 59 base::MessageLoop::current()->PostTask(FROM_HERE,
62 base::Bind(callback, usage)); 60 base::Bind(callback, usage));
63 } 61 }
64 62
65 virtual void GetOriginsForType(StorageType type, 63 void GetOriginsForType(StorageType type,
66 const GetOriginsCallback& callback) override { 64 const GetOriginsCallback& callback) override {
67 EXPECT_EQ(kStorageTypeTemporary, type); 65 EXPECT_EQ(kStorageTypeTemporary, type);
68 std::set<GURL> origins; 66 std::set<GURL> origins;
69 for (UsageMap::const_iterator itr = usage_map_.begin(); 67 for (UsageMap::const_iterator itr = usage_map_.begin();
70 itr != usage_map_.end(); ++itr) { 68 itr != usage_map_.end(); ++itr) {
71 origins.insert(itr->first); 69 origins.insert(itr->first);
72 } 70 }
73 base::MessageLoop::current()->PostTask(FROM_HERE, 71 base::MessageLoop::current()->PostTask(FROM_HERE,
74 base::Bind(callback, origins)); 72 base::Bind(callback, origins));
75 } 73 }
76 74
77 virtual void GetOriginsForHost(StorageType type, 75 void GetOriginsForHost(StorageType type,
78 const std::string& host, 76 const std::string& host,
79 const GetOriginsCallback& callback) override { 77 const GetOriginsCallback& callback) override {
80 EXPECT_EQ(kStorageTypeTemporary, type); 78 EXPECT_EQ(kStorageTypeTemporary, type);
81 std::set<GURL> origins; 79 std::set<GURL> origins;
82 for (UsageMap::const_iterator itr = usage_map_.begin(); 80 for (UsageMap::const_iterator itr = usage_map_.begin();
83 itr != usage_map_.end(); ++itr) { 81 itr != usage_map_.end(); ++itr) {
84 if (net::GetHostOrSpecFromURL(itr->first) == host) 82 if (net::GetHostOrSpecFromURL(itr->first) == host)
85 origins.insert(itr->first); 83 origins.insert(itr->first);
86 } 84 }
87 base::MessageLoop::current()->PostTask(FROM_HERE, 85 base::MessageLoop::current()->PostTask(FROM_HERE,
88 base::Bind(callback, origins)); 86 base::Bind(callback, origins));
89 } 87 }
90 88
91 virtual void DeleteOriginData(const GURL& origin, 89 void DeleteOriginData(const GURL& origin,
92 StorageType type, 90 StorageType type,
93 const DeletionCallback& callback) override { 91 const DeletionCallback& callback) override {
94 EXPECT_EQ(kStorageTypeTemporary, type); 92 EXPECT_EQ(kStorageTypeTemporary, type);
95 usage_map_.erase(origin); 93 usage_map_.erase(origin);
96 base::MessageLoop::current()->PostTask( 94 base::MessageLoop::current()->PostTask(
97 FROM_HERE, base::Bind(callback, kQuotaStatusOk)); 95 FROM_HERE, base::Bind(callback, kQuotaStatusOk));
98 } 96 }
99 97
100 virtual bool DoesSupport(storage::StorageType type) const override { 98 bool DoesSupport(storage::StorageType type) const override {
101 return type == storage::kStorageTypeTemporary; 99 return type == storage::kStorageTypeTemporary;
102 } 100 }
103 101
104 int64 GetUsage(const GURL& origin) { 102 int64 GetUsage(const GURL& origin) {
105 UsageMap::const_iterator found = usage_map_.find(origin); 103 UsageMap::const_iterator found = usage_map_.find(origin);
106 if (found == usage_map_.end()) 104 if (found == usage_map_.end())
107 return 0; 105 return 0;
108 return found->second; 106 return found->second;
109 } 107 }
110 108
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 325
328 GetGlobalLimitedUsage(&limited_usage); 326 GetGlobalLimitedUsage(&limited_usage);
329 GetGlobalUsage(&total_usage, &unlimited_usage); 327 GetGlobalUsage(&total_usage, &unlimited_usage);
330 EXPECT_EQ(1 + 16, limited_usage); 328 EXPECT_EQ(1 + 16, limited_usage);
331 EXPECT_EQ(1 + 2 + 16 + 32, total_usage); 329 EXPECT_EQ(1 + 2 + 16 + 32, total_usage);
332 EXPECT_EQ(2 + 32, unlimited_usage); 330 EXPECT_EQ(2 + 32, unlimited_usage);
333 } 331 }
334 332
335 333
336 } // namespace content 334 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/quota/storage_monitor_unittest.cc ('k') | content/browser/quota_dispatcher_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698