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

Side by Side Diff: content/browser/indexed_db/indexed_db_quota_client_unittest.cc

Issue 15925005: [Quota][Clean up] Drop non-informative StorageType parameter on GetOriginsForType callback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <map> 5 #include <map>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 weak_factory_.GetWeakPtr())); 82 weak_factory_.GetWeakPtr()));
83 base::MessageLoop::current()->RunUntilIdle(); 83 base::MessageLoop::current()->RunUntilIdle();
84 EXPECT_GT(usage_, -1); 84 EXPECT_GT(usage_, -1);
85 return usage_; 85 return usage_;
86 } 86 }
87 87
88 const std::set<GURL>& GetOriginsForType( 88 const std::set<GURL>& GetOriginsForType(
89 quota::QuotaClient* client, 89 quota::QuotaClient* client,
90 quota::StorageType type) { 90 quota::StorageType type) {
91 origins_.clear(); 91 origins_.clear();
92 type_ = quota::kStorageTypeTemporary;
93 client->GetOriginsForType( 92 client->GetOriginsForType(
94 type, 93 type,
95 base::Bind(&IndexedDBQuotaClientTest::OnGetOriginsComplete, 94 base::Bind(&IndexedDBQuotaClientTest::OnGetOriginsComplete,
96 weak_factory_.GetWeakPtr())); 95 weak_factory_.GetWeakPtr()));
97 base::MessageLoop::current()->RunUntilIdle(); 96 base::MessageLoop::current()->RunUntilIdle();
98 return origins_; 97 return origins_;
99 } 98 }
100 99
101 const std::set<GURL>& GetOriginsForHost( 100 const std::set<GURL>& GetOriginsForHost(
102 quota::QuotaClient* client, 101 quota::QuotaClient* client,
103 quota::StorageType type, 102 quota::StorageType type,
104 const std::string& host) { 103 const std::string& host) {
105 origins_.clear(); 104 origins_.clear();
106 type_ = quota::kStorageTypeTemporary;
107 client->GetOriginsForHost( 105 client->GetOriginsForHost(
108 type, host, 106 type, host,
109 base::Bind(&IndexedDBQuotaClientTest::OnGetOriginsComplete, 107 base::Bind(&IndexedDBQuotaClientTest::OnGetOriginsComplete,
110 weak_factory_.GetWeakPtr())); 108 weak_factory_.GetWeakPtr()));
111 base::MessageLoop::current()->RunUntilIdle(); 109 base::MessageLoop::current()->RunUntilIdle();
112 return origins_; 110 return origins_;
113 } 111 }
114 112
115 quota::QuotaStatusCode DeleteOrigin(quota::QuotaClient* client, 113 quota::QuotaStatusCode DeleteOrigin(quota::QuotaClient* client,
116 const GURL& origin_url) { 114 const GURL& origin_url) {
(...skipping 23 matching lines...) Expand all
140 file_path_origin = file_path_origin.Append(FILE_PATH_LITERAL("fake_file")); 138 file_path_origin = file_path_origin.Append(FILE_PATH_LITERAL("fake_file"));
141 SetFileSizeTo(file_path_origin, size); 139 SetFileSizeTo(file_path_origin, size);
142 idb_context()->ResetCaches(); 140 idb_context()->ResetCaches();
143 } 141 }
144 142
145 private: 143 private:
146 void OnGetOriginUsageComplete(int64 usage) { 144 void OnGetOriginUsageComplete(int64 usage) {
147 usage_ = usage; 145 usage_ = usage;
148 } 146 }
149 147
150 void OnGetOriginsComplete(const std::set<GURL>& origins, 148 void OnGetOriginsComplete(const std::set<GURL>& origins) {
151 quota::StorageType type) {
152 origins_ = origins; 149 origins_ = origins;
153 type_ = type;
154 } 150 }
155 151
156 void OnDeleteOriginComplete(quota::QuotaStatusCode code) { 152 void OnDeleteOriginComplete(quota::QuotaStatusCode code) {
157 delete_status_ = code; 153 delete_status_ = code;
158 } 154 }
159 155
160 base::ScopedTempDir temp_dir_; 156 base::ScopedTempDir temp_dir_;
161 int64 usage_; 157 int64 usage_;
162 std::set<GURL> origins_; 158 std::set<GURL> origins_;
163 quota::StorageType type_;
164 scoped_refptr<IndexedDBContextImpl> idb_context_; 159 scoped_refptr<IndexedDBContextImpl> idb_context_;
165 base::WeakPtrFactory<IndexedDBQuotaClientTest> weak_factory_; 160 base::WeakPtrFactory<IndexedDBQuotaClientTest> weak_factory_;
166 base::MessageLoop message_loop_; 161 base::MessageLoop message_loop_;
167 BrowserThreadImpl db_thread_; 162 BrowserThreadImpl db_thread_;
168 BrowserThreadImpl webkit_thread_; 163 BrowserThreadImpl webkit_thread_;
169 BrowserThreadImpl file_thread_; 164 BrowserThreadImpl file_thread_;
170 BrowserThreadImpl file_user_blocking_thread_; 165 BrowserThreadImpl file_user_blocking_thread_;
171 BrowserThreadImpl io_thread_; 166 BrowserThreadImpl io_thread_;
172 scoped_ptr<TestBrowserContext> browser_context_; 167 scoped_ptr<TestBrowserContext> browser_context_;
173 quota::QuotaStatusCode delete_status_; 168 quota::QuotaStatusCode delete_status_;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 EXPECT_EQ(1000, GetOriginUsage(&client, kOriginA, kTemp)); 239 EXPECT_EQ(1000, GetOriginUsage(&client, kOriginA, kTemp));
245 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp)); 240 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp));
246 241
247 quota::QuotaStatusCode delete_status = DeleteOrigin(&client, kOriginA); 242 quota::QuotaStatusCode delete_status = DeleteOrigin(&client, kOriginA);
248 EXPECT_EQ(quota::kQuotaStatusOk, delete_status); 243 EXPECT_EQ(quota::kQuotaStatusOk, delete_status);
249 EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kTemp)); 244 EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kTemp));
250 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp)); 245 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp));
251 } 246 }
252 247
253 } // namespace content 248 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_quota_client.cc ('k') | webkit/appcache/appcache_quota_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698