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

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

Issue 15984016: Call scoped_refptr<T>::get() rather than relying on implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 BrowserThreadImpl db_thread_; 158 BrowserThreadImpl db_thread_;
159 BrowserThreadImpl webkit_thread_; 159 BrowserThreadImpl webkit_thread_;
160 BrowserThreadImpl file_thread_; 160 BrowserThreadImpl file_thread_;
161 BrowserThreadImpl file_user_blocking_thread_; 161 BrowserThreadImpl file_user_blocking_thread_;
162 BrowserThreadImpl io_thread_; 162 BrowserThreadImpl io_thread_;
163 scoped_ptr<TestBrowserContext> browser_context_; 163 scoped_ptr<TestBrowserContext> browser_context_;
164 quota::QuotaStatusCode delete_status_; 164 quota::QuotaStatusCode delete_status_;
165 }; 165 };
166 166
167 TEST_F(IndexedDBQuotaClientTest, GetOriginUsage) { 167 TEST_F(IndexedDBQuotaClientTest, GetOriginUsage) {
168 IndexedDBQuotaClient client(base::MessageLoopProxy::current(), idb_context()); 168 IndexedDBQuotaClient client(base::MessageLoopProxy::current().get(),
169 idb_context());
169 170
170 AddFakeIndexedDB(kOriginA, 6); 171 AddFakeIndexedDB(kOriginA, 6);
171 AddFakeIndexedDB(kOriginB, 3); 172 AddFakeIndexedDB(kOriginB, 3);
172 EXPECT_EQ(6, GetOriginUsage(&client, kOriginA, kTemp)); 173 EXPECT_EQ(6, GetOriginUsage(&client, kOriginA, kTemp));
173 EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kPerm)); 174 EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kPerm));
174 EXPECT_EQ(3, GetOriginUsage(&client, kOriginB, kTemp)); 175 EXPECT_EQ(3, GetOriginUsage(&client, kOriginB, kTemp));
175 EXPECT_EQ(0, GetOriginUsage(&client, kOriginB, kPerm)); 176 EXPECT_EQ(0, GetOriginUsage(&client, kOriginB, kPerm));
176 177
177 AddFakeIndexedDB(kOriginA, 1000); 178 AddFakeIndexedDB(kOriginA, 1000);
178 EXPECT_EQ(1000, GetOriginUsage(&client, kOriginA, kTemp)); 179 EXPECT_EQ(1000, GetOriginUsage(&client, kOriginA, kTemp));
179 EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kPerm)); 180 EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kPerm));
180 EXPECT_EQ(3, GetOriginUsage(&client, kOriginB, kTemp)); 181 EXPECT_EQ(3, GetOriginUsage(&client, kOriginB, kTemp));
181 EXPECT_EQ(0, GetOriginUsage(&client, kOriginB, kPerm)); 182 EXPECT_EQ(0, GetOriginUsage(&client, kOriginB, kPerm));
182 } 183 }
183 184
184 TEST_F(IndexedDBQuotaClientTest, GetOriginsForHost) { 185 TEST_F(IndexedDBQuotaClientTest, GetOriginsForHost) {
185 IndexedDBQuotaClient client(base::MessageLoopProxy::current(), idb_context()); 186 IndexedDBQuotaClient client(base::MessageLoopProxy::current().get(),
187 idb_context());
186 188
187 EXPECT_EQ(kOriginA.host(), kOriginB.host()); 189 EXPECT_EQ(kOriginA.host(), kOriginB.host());
188 EXPECT_NE(kOriginA.host(), kOriginOther.host()); 190 EXPECT_NE(kOriginA.host(), kOriginOther.host());
189 191
190 std::set<GURL> origins = GetOriginsForHost(&client, kTemp, kOriginA.host()); 192 std::set<GURL> origins = GetOriginsForHost(&client, kTemp, kOriginA.host());
191 EXPECT_TRUE(origins.empty()); 193 EXPECT_TRUE(origins.empty());
192 194
193 AddFakeIndexedDB(kOriginA, 1000); 195 AddFakeIndexedDB(kOriginA, 1000);
194 origins = GetOriginsForHost(&client, kTemp, kOriginA.host()); 196 origins = GetOriginsForHost(&client, kTemp, kOriginA.host());
195 EXPECT_EQ(origins.size(), 1ul); 197 EXPECT_EQ(origins.size(), 1ul);
196 EXPECT_TRUE(origins.find(kOriginA) != origins.end()); 198 EXPECT_TRUE(origins.find(kOriginA) != origins.end());
197 199
198 AddFakeIndexedDB(kOriginB, 1000); 200 AddFakeIndexedDB(kOriginB, 1000);
199 origins = GetOriginsForHost(&client, kTemp, kOriginA.host()); 201 origins = GetOriginsForHost(&client, kTemp, kOriginA.host());
200 EXPECT_EQ(origins.size(), 2ul); 202 EXPECT_EQ(origins.size(), 2ul);
201 EXPECT_TRUE(origins.find(kOriginA) != origins.end()); 203 EXPECT_TRUE(origins.find(kOriginA) != origins.end());
202 EXPECT_TRUE(origins.find(kOriginB) != origins.end()); 204 EXPECT_TRUE(origins.find(kOriginB) != origins.end());
203 205
204 EXPECT_TRUE(GetOriginsForHost(&client, kPerm, kOriginA.host()).empty()); 206 EXPECT_TRUE(GetOriginsForHost(&client, kPerm, kOriginA.host()).empty());
205 EXPECT_TRUE(GetOriginsForHost(&client, kTemp, kOriginOther.host()).empty()); 207 EXPECT_TRUE(GetOriginsForHost(&client, kTemp, kOriginOther.host()).empty());
206 } 208 }
207 209
208 TEST_F(IndexedDBQuotaClientTest, GetOriginsForType) { 210 TEST_F(IndexedDBQuotaClientTest, GetOriginsForType) {
209 IndexedDBQuotaClient client(base::MessageLoopProxy::current(), idb_context()); 211 IndexedDBQuotaClient client(base::MessageLoopProxy::current().get(),
212 idb_context());
210 213
211 EXPECT_TRUE(GetOriginsForType(&client, kTemp).empty()); 214 EXPECT_TRUE(GetOriginsForType(&client, kTemp).empty());
212 EXPECT_TRUE(GetOriginsForType(&client, kPerm).empty()); 215 EXPECT_TRUE(GetOriginsForType(&client, kPerm).empty());
213 216
214 AddFakeIndexedDB(kOriginA, 1000); 217 AddFakeIndexedDB(kOriginA, 1000);
215 std::set<GURL> origins = GetOriginsForType(&client, kTemp); 218 std::set<GURL> origins = GetOriginsForType(&client, kTemp);
216 EXPECT_EQ(origins.size(), 1ul); 219 EXPECT_EQ(origins.size(), 1ul);
217 EXPECT_TRUE(origins.find(kOriginA) != origins.end()); 220 EXPECT_TRUE(origins.find(kOriginA) != origins.end());
218 221
219 EXPECT_TRUE(GetOriginsForType(&client, kPerm).empty()); 222 EXPECT_TRUE(GetOriginsForType(&client, kPerm).empty());
220 } 223 }
221 224
222 TEST_F(IndexedDBQuotaClientTest, DeleteOrigin) { 225 TEST_F(IndexedDBQuotaClientTest, DeleteOrigin) {
223 IndexedDBQuotaClient client(base::MessageLoopProxy::current(), idb_context()); 226 IndexedDBQuotaClient client(base::MessageLoopProxy::current().get(),
227 idb_context());
224 228
225 AddFakeIndexedDB(kOriginA, 1000); 229 AddFakeIndexedDB(kOriginA, 1000);
226 AddFakeIndexedDB(kOriginB, 50); 230 AddFakeIndexedDB(kOriginB, 50);
227 EXPECT_EQ(1000, GetOriginUsage(&client, kOriginA, kTemp)); 231 EXPECT_EQ(1000, GetOriginUsage(&client, kOriginA, kTemp));
228 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp)); 232 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp));
229 233
230 quota::QuotaStatusCode delete_status = DeleteOrigin(&client, kOriginA); 234 quota::QuotaStatusCode delete_status = DeleteOrigin(&client, kOriginA);
231 EXPECT_EQ(quota::kQuotaStatusOk, delete_status); 235 EXPECT_EQ(quota::kQuotaStatusOk, delete_status);
232 EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kTemp)); 236 EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kTemp));
233 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp)); 237 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp));
234 } 238 }
235 239
236 } // namespace content 240 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_factory.cc ('k') | content/browser/indexed_db/indexed_db_transaction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698