| OLD | NEW |
| 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_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/memory/scoped_callback_factory.h" | 10 #include "base/memory/scoped_callback_factory.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 const GURL kOriginB; | 35 const GURL kOriginB; |
| 36 const GURL kOriginOther; | 36 const GURL kOriginOther; |
| 37 | 37 |
| 38 IndexedDBQuotaClientTest() | 38 IndexedDBQuotaClientTest() |
| 39 : kOriginA("http://host"), | 39 : kOriginA("http://host"), |
| 40 kOriginB("http://host:8000"), | 40 kOriginB("http://host:8000"), |
| 41 kOriginOther("http://other"), | 41 kOriginOther("http://other"), |
| 42 usage_(0), | 42 usage_(0), |
| 43 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 43 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 44 message_loop_(MessageLoop::TYPE_IO), | 44 message_loop_(MessageLoop::TYPE_IO), |
| 45 webkit_thread_(BrowserThread::WEBKIT, &message_loop_), | 45 webkit_thread_(BrowserThread::WEBKIT_DEPRECATED, &message_loop_), |
| 46 io_thread_(BrowserThread::IO, &message_loop_) { | 46 io_thread_(BrowserThread::IO, &message_loop_) { |
| 47 TestBrowserContext browser_context; | 47 TestBrowserContext browser_context; |
| 48 idb_context_ = browser_context.GetWebKitContext()->indexed_db_context(); | 48 idb_context_ = browser_context.GetWebKitContext()->indexed_db_context(); |
| 49 setup_temp_dir(); | 49 setup_temp_dir(); |
| 50 } | 50 } |
| 51 void setup_temp_dir() { | 51 void setup_temp_dir() { |
| 52 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 52 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 53 FilePath indexeddb_dir = temp_dir_.path().Append( | 53 FilePath indexeddb_dir = temp_dir_.path().Append( |
| 54 IndexedDBContext::kIndexedDBDirectory); | 54 IndexedDBContext::kIndexedDBDirectory); |
| 55 ASSERT_TRUE(file_util::CreateDirectory(indexeddb_dir)); | 55 ASSERT_TRUE(file_util::CreateDirectory(indexeddb_dir)); |
| 56 idb_context()->set_data_path_for_testing(indexeddb_dir); | 56 idb_context()->set_data_path_for_testing(indexeddb_dir); |
| 57 } | 57 } |
| 58 | 58 |
| 59 ~IndexedDBQuotaClientTest() { | 59 ~IndexedDBQuotaClientTest() { |
| 60 // IndexedDBContext needs to be destructed on BrowserThread::WEBKIT, which | 60 // IndexedDBContext needs to be destructed on |
| 61 // is also a member variable of this class. Cause IndexedDBContext's | 61 // BrowserThread::WEBKIT_DEPRECATED, which is also a member variable of this |
| 62 // destruction now to ensure that it doesn't outlive BrowserThread::WEBKIT. | 62 // class. Cause IndexedDBContext's destruction now to ensure that it |
| 63 // doesn't outlive BrowserThread::WEBKIT_DEPRECATED. |
| 63 idb_context_ = NULL; | 64 idb_context_ = NULL; |
| 64 MessageLoop::current()->RunAllPending(); | 65 MessageLoop::current()->RunAllPending(); |
| 65 } | 66 } |
| 66 | 67 |
| 67 int64 GetOriginUsage( | 68 int64 GetOriginUsage( |
| 68 quota::QuotaClient* client, | 69 quota::QuotaClient* client, |
| 69 const GURL& origin, | 70 const GURL& origin, |
| 70 quota::StorageType type) { | 71 quota::StorageType type) { |
| 71 usage_ = -1; | 72 usage_ = -1; |
| 72 client->GetOriginUsage( | 73 client->GetOriginUsage( |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 AddFakeIndexedDB(kOriginA, 1000); | 233 AddFakeIndexedDB(kOriginA, 1000); |
| 233 AddFakeIndexedDB(kOriginB, 50); | 234 AddFakeIndexedDB(kOriginB, 50); |
| 234 EXPECT_EQ(1000, GetOriginUsage(&client, kOriginA, kTemp)); | 235 EXPECT_EQ(1000, GetOriginUsage(&client, kOriginA, kTemp)); |
| 235 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp)); | 236 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp)); |
| 236 | 237 |
| 237 quota::QuotaStatusCode delete_status = DeleteOrigin(&client, kOriginA); | 238 quota::QuotaStatusCode delete_status = DeleteOrigin(&client, kOriginA); |
| 238 EXPECT_EQ(quota::kQuotaStatusOk, delete_status); | 239 EXPECT_EQ(quota::kQuotaStatusOk, delete_status); |
| 239 EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kTemp)); | 240 EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kTemp)); |
| 240 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp)); | 241 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp)); |
| 241 } | 242 } |
| OLD | NEW |