| 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/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/message_loop_proxy.h" | 11 #include "base/message_loop_proxy.h" |
| 12 #include "base/scoped_temp_dir.h" | 12 #include "base/scoped_temp_dir.h" |
| 13 #include "content/browser/browser_thread_impl.h" | 13 #include "content/browser/browser_thread_impl.h" |
| 14 #include "content/browser/in_process_webkit/indexed_db_context_impl.h" | 14 #include "content/browser/in_process_webkit/indexed_db_context_impl.h" |
| 15 #include "content/browser/in_process_webkit/indexed_db_quota_client.h" | 15 #include "content/browser/in_process_webkit/indexed_db_quota_client.h" |
| 16 #include "content/public/browser/storage_partition.h" |
| 16 #include "content/public/test/test_browser_context.h" | 17 #include "content/public/test/test_browser_context.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 18 #include "webkit/database/database_util.h" | 19 #include "webkit/database/database_util.h" |
| 19 | 20 |
| 20 using content::BrowserContext; | 21 using content::BrowserContext; |
| 21 using content::BrowserThread; | 22 using content::BrowserThread; |
| 22 | 23 |
| 23 // Declared to shorten the line lengths. | 24 // Declared to shorten the line lengths. |
| 24 static const quota::StorageType kTemp = quota::kStorageTypeTemporary; | 25 static const quota::StorageType kTemp = quota::kStorageTypeTemporary; |
| 25 static const quota::StorageType kPerm = quota::kStorageTypePersistent; | 26 static const quota::StorageType kPerm = quota::kStorageTypePersistent; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 42 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 43 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 43 message_loop_(MessageLoop::TYPE_IO), | 44 message_loop_(MessageLoop::TYPE_IO), |
| 44 db_thread_(BrowserThread::DB, &message_loop_), | 45 db_thread_(BrowserThread::DB, &message_loop_), |
| 45 webkit_thread_(BrowserThread::WEBKIT_DEPRECATED, &message_loop_), | 46 webkit_thread_(BrowserThread::WEBKIT_DEPRECATED, &message_loop_), |
| 46 file_thread_(BrowserThread::FILE, &message_loop_), | 47 file_thread_(BrowserThread::FILE, &message_loop_), |
| 47 file_user_blocking_thread_( | 48 file_user_blocking_thread_( |
| 48 BrowserThread::FILE_USER_BLOCKING, &message_loop_), | 49 BrowserThread::FILE_USER_BLOCKING, &message_loop_), |
| 49 io_thread_(BrowserThread::IO, &message_loop_) { | 50 io_thread_(BrowserThread::IO, &message_loop_) { |
| 50 browser_context_.reset(new content::TestBrowserContext()); | 51 browser_context_.reset(new content::TestBrowserContext()); |
| 51 idb_context_ = static_cast<IndexedDBContextImpl*>( | 52 idb_context_ = static_cast<IndexedDBContextImpl*>( |
| 52 BrowserContext::GetIndexedDBContext(browser_context_.get())); | 53 BrowserContext::GetDefaultStoragePartition(browser_context_.get())-> |
| 54 GetIndexedDBContext()); |
| 53 message_loop_.RunAllPending(); | 55 message_loop_.RunAllPending(); |
| 54 setup_temp_dir(); | 56 setup_temp_dir(); |
| 55 } | 57 } |
| 56 void setup_temp_dir() { | 58 void setup_temp_dir() { |
| 57 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 59 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 58 FilePath indexeddb_dir = temp_dir_.path().Append( | 60 FilePath indexeddb_dir = temp_dir_.path().Append( |
| 59 IndexedDBContextImpl::kIndexedDBDirectory); | 61 IndexedDBContextImpl::kIndexedDBDirectory); |
| 60 ASSERT_TRUE(file_util::CreateDirectory(indexeddb_dir)); | 62 ASSERT_TRUE(file_util::CreateDirectory(indexeddb_dir)); |
| 61 idb_context()->set_data_path_for_testing(indexeddb_dir); | 63 idb_context()->set_data_path_for_testing(indexeddb_dir); |
| 62 } | 64 } |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 AddFakeIndexedDB(kOriginA, 1000); | 245 AddFakeIndexedDB(kOriginA, 1000); |
| 244 AddFakeIndexedDB(kOriginB, 50); | 246 AddFakeIndexedDB(kOriginB, 50); |
| 245 EXPECT_EQ(1000, GetOriginUsage(&client, kOriginA, kTemp)); | 247 EXPECT_EQ(1000, GetOriginUsage(&client, kOriginA, kTemp)); |
| 246 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp)); | 248 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp)); |
| 247 | 249 |
| 248 quota::QuotaStatusCode delete_status = DeleteOrigin(&client, kOriginA); | 250 quota::QuotaStatusCode delete_status = DeleteOrigin(&client, kOriginA); |
| 249 EXPECT_EQ(quota::kQuotaStatusOk, delete_status); | 251 EXPECT_EQ(quota::kQuotaStatusOk, delete_status); |
| 250 EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kTemp)); | 252 EXPECT_EQ(0, GetOriginUsage(&client, kOriginA, kTemp)); |
| 251 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp)); | 253 EXPECT_EQ(50, GetOriginUsage(&client, kOriginB, kTemp)); |
| 252 } | 254 } |
| OLD | NEW |