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