Index: content/browser/indexed_db/indexed_db_factory_unittest.cc |
diff --git a/content/browser/indexed_db/indexed_db_factory_unittest.cc b/content/browser/indexed_db/indexed_db_factory_unittest.cc |
index a3142a4b863a03834962e2929878cc409c87b027..8c2085e164032b3c56cfaf581f13c483380ae8ef 100644 |
--- a/content/browser/indexed_db/indexed_db_factory_unittest.cc |
+++ b/content/browser/indexed_db/indexed_db_factory_unittest.cc |
@@ -16,9 +16,9 @@ |
#include "content/browser/indexed_db/indexed_db_connection.h" |
#include "content/browser/indexed_db/indexed_db_context_impl.h" |
#include "content/browser/indexed_db/indexed_db_factory_impl.h" |
-#include "content/browser/indexed_db/mock_indexed_db_callbacks.h" |
-#include "content/browser/indexed_db/mock_indexed_db_database_callbacks.h" |
+#include "content/browser/indexed_db/mock_indexed_db_change_handler.h" |
#include "content/browser/quota/mock_quota_manager_proxy.h" |
+#include "net/url_request/url_request_context_getter.h" |
#include "testing/gtest/include/gtest/gtest.h" |
#include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseException.h" |
#include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h" |
@@ -225,6 +225,7 @@ class DiskFullFactory : public IndexedDBFactoryImpl { |
DISALLOW_COPY_AND_ASSIGN(DiskFullFactory); |
}; |
+#ifdef CJM_NEED_CALLBACK |
class LookingForQuotaErrorMockCallbacks : public IndexedDBCallbacks { |
public: |
LookingForQuotaErrorMockCallbacks() |
@@ -241,6 +242,7 @@ class LookingForQuotaErrorMockCallbacks : public IndexedDBCallbacks { |
DISALLOW_COPY_AND_ASSIGN(LookingForQuotaErrorMockCallbacks); |
}; |
+#endif |
TEST_F(IndexedDBFactoryTest, QuotaErrorOnDiskFull) { |
const Origin origin(GURL("http://localhost:81")); |
@@ -248,18 +250,20 @@ TEST_F(IndexedDBFactoryTest, QuotaErrorOnDiskFull) { |
ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); |
scoped_refptr<DiskFullFactory> factory = new DiskFullFactory(context()); |
+#ifdef CJM_NEED_CALLBACK |
scoped_refptr<LookingForQuotaErrorMockCallbacks> callbacks = |
new LookingForQuotaErrorMockCallbacks; |
- scoped_refptr<IndexedDBDatabaseCallbacks> dummy_database_callbacks = |
- new IndexedDBDatabaseCallbacks(nullptr, 0, 0); |
+ scoped_refptr<IndexedDBChangeHandler> dummy_change_handler = |
+ new IndexedDBChangeHandler(nullptr, 0, 0); |
const base::string16 name(ASCIIToUTF16("name")); |
std::unique_ptr<IndexedDBPendingConnection> connection( |
base::MakeUnique<IndexedDBPendingConnection>( |
- callbacks, dummy_database_callbacks, 0 /* child_process_id */, |
+ callbacks, dummy_change_handler, 0 /* child_process_id */, |
2 /* transaction_id */, 1 /* version */)); |
factory->Open(name, std::move(connection), nullptr /* request_context */, |
origin, temp_directory.path()); |
EXPECT_TRUE(callbacks->error_called()); |
+#endif |
} |
TEST_F(IndexedDBFactoryTest, BackingStoreReleasedOnForcedClose) { |
@@ -268,13 +272,14 @@ TEST_F(IndexedDBFactoryTest, BackingStoreReleasedOnForcedClose) { |
base::ScopedTempDir temp_directory; |
ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); |
+#ifdef CJM_NEED_CALLBACK |
scoped_refptr<MockIndexedDBCallbacks> callbacks(new MockIndexedDBCallbacks()); |
- scoped_refptr<MockIndexedDBDatabaseCallbacks> db_callbacks( |
- new MockIndexedDBDatabaseCallbacks()); |
+ scoped_refptr<MockIndexedDBChangeHandler> change_handler( |
+ new MockIndexedDBChangeHandler()); |
const int64_t transaction_id = 1; |
std::unique_ptr<IndexedDBPendingConnection> connection( |
base::MakeUnique<IndexedDBPendingConnection>( |
- callbacks, db_callbacks, 0 /* child_process_id */, transaction_id, |
+ callbacks, change_handler, 0 /* child_process_id */, transaction_id, |
IndexedDBDatabaseMetadata::DEFAULT_VERSION)); |
factory()->Open(ASCIIToUTF16("db"), std::move(connection), |
nullptr /* request_context */, origin, temp_directory.path()); |
@@ -288,6 +293,7 @@ TEST_F(IndexedDBFactoryTest, BackingStoreReleasedOnForcedClose) { |
EXPECT_FALSE(factory()->IsBackingStoreOpen(origin)); |
EXPECT_FALSE(factory()->IsBackingStorePendingClose(origin)); |
+#endif |
} |
TEST_F(IndexedDBFactoryTest, BackingStoreReleaseDelayedOnClose) { |
@@ -296,13 +302,14 @@ TEST_F(IndexedDBFactoryTest, BackingStoreReleaseDelayedOnClose) { |
base::ScopedTempDir temp_directory; |
ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); |
+#ifdef CJM_NEED_CALLBACK |
scoped_refptr<MockIndexedDBCallbacks> callbacks(new MockIndexedDBCallbacks()); |
- scoped_refptr<MockIndexedDBDatabaseCallbacks> db_callbacks( |
- new MockIndexedDBDatabaseCallbacks()); |
+ scoped_refptr<MockIndexedDBChangeHandler> change_handler( |
+ new MockIndexedDBChangeHandler()); |
const int64_t transaction_id = 1; |
std::unique_ptr<IndexedDBPendingConnection> connection( |
base::MakeUnique<IndexedDBPendingConnection>( |
- callbacks, db_callbacks, 0 /* child_process_id */, transaction_id, |
+ callbacks, change_handler, 0 /* child_process_id */, transaction_id, |
IndexedDBDatabaseMetadata::DEFAULT_VERSION)); |
factory()->Open(ASCIIToUTF16("db"), std::move(connection), |
nullptr /* request_context */, origin, temp_directory.path()); |
@@ -327,6 +334,7 @@ TEST_F(IndexedDBFactoryTest, BackingStoreReleaseDelayedOnClose) { |
EXPECT_FALSE(store->close_timer()->IsRunning()); |
EXPECT_FALSE(factory()->IsBackingStoreOpen(origin)); |
EXPECT_FALSE(factory()->IsBackingStorePendingClose(origin)); |
+#endif |
} |
TEST_F(IndexedDBFactoryTest, DeleteDatabaseClosesBackingStore) { |
@@ -337,6 +345,7 @@ TEST_F(IndexedDBFactoryTest, DeleteDatabaseClosesBackingStore) { |
EXPECT_FALSE(factory()->IsBackingStoreOpen(origin)); |
+#ifdef CJM_NEED_CALLBACK |
const bool expect_connection = false; |
scoped_refptr<MockIndexedDBCallbacks> callbacks( |
new MockIndexedDBCallbacks(expect_connection)); |
@@ -351,6 +360,7 @@ TEST_F(IndexedDBFactoryTest, DeleteDatabaseClosesBackingStore) { |
EXPECT_FALSE(factory()->IsBackingStoreOpen(origin)); |
EXPECT_FALSE(factory()->IsBackingStorePendingClose(origin)); |
+#endif |
} |
TEST_F(IndexedDBFactoryTest, GetDatabaseNamesClosesBackingStore) { |
@@ -361,6 +371,7 @@ TEST_F(IndexedDBFactoryTest, GetDatabaseNamesClosesBackingStore) { |
EXPECT_FALSE(factory()->IsBackingStoreOpen(origin)); |
+#ifdef CJM_NEED_CALLBACK |
const bool expect_connection = false; |
scoped_refptr<MockIndexedDBCallbacks> callbacks( |
new MockIndexedDBCallbacks(expect_connection)); |
@@ -375,6 +386,7 @@ TEST_F(IndexedDBFactoryTest, GetDatabaseNamesClosesBackingStore) { |
EXPECT_FALSE(factory()->IsBackingStoreOpen(origin)); |
EXPECT_FALSE(factory()->IsBackingStorePendingClose(origin)); |
+#endif |
} |
TEST_F(IndexedDBFactoryTest, ForceCloseReleasesBackingStore) { |
@@ -383,13 +395,14 @@ TEST_F(IndexedDBFactoryTest, ForceCloseReleasesBackingStore) { |
base::ScopedTempDir temp_directory; |
ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); |
+#ifdef CJM_NEED_CALLBACK |
scoped_refptr<MockIndexedDBCallbacks> callbacks(new MockIndexedDBCallbacks()); |
- scoped_refptr<MockIndexedDBDatabaseCallbacks> db_callbacks( |
- new MockIndexedDBDatabaseCallbacks()); |
+ scoped_refptr<MockIndexedDBChangeHandler> change_handler( |
+ new MockIndexedDBChangeHandler()); |
const int64_t transaction_id = 1; |
std::unique_ptr<IndexedDBPendingConnection> connection( |
base::MakeUnique<IndexedDBPendingConnection>( |
- callbacks, db_callbacks, 0 /* child_process_id */, transaction_id, |
+ callbacks, change_handler, 0 /* child_process_id */, transaction_id, |
IndexedDBDatabaseMetadata::DEFAULT_VERSION)); |
factory()->Open(ASCIIToUTF16("db"), std::move(connection), |
nullptr /* request_context */, origin, temp_directory.path()); |
@@ -410,8 +423,10 @@ TEST_F(IndexedDBFactoryTest, ForceCloseReleasesBackingStore) { |
// Ensure it is safe if the store is not open. |
factory()->ForceClose(origin); |
+#endif |
} |
+#ifdef CJM_NEED_CALLBACK |
class UpgradeNeededCallbacks : public MockIndexedDBCallbacks { |
public: |
UpgradeNeededCallbacks() {} |
@@ -451,6 +466,7 @@ class ErrorCallbacks : public MockIndexedDBCallbacks { |
DISALLOW_COPY_AND_ASSIGN(ErrorCallbacks); |
}; |
+#endif |
TEST_F(IndexedDBFactoryTest, DatabaseFailedOpen) { |
const Origin origin(GURL("http://localhost:81")); |
@@ -458,11 +474,12 @@ TEST_F(IndexedDBFactoryTest, DatabaseFailedOpen) { |
base::ScopedTempDir temp_directory; |
ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); |
+#ifdef CJM_NEED_CALLBACK |
const base::string16 db_name(ASCIIToUTF16("db")); |
const int64_t db_version = 2; |
const int64_t transaction_id = 1; |
- scoped_refptr<IndexedDBDatabaseCallbacks> db_callbacks( |
- new MockIndexedDBDatabaseCallbacks()); |
+ scoped_refptr<IndexedDBChangeHandler> change_handler( |
+ new MockIndexedDBChangeHandler()); |
// Open at version 2, then close. |
{ |
@@ -470,7 +487,7 @@ TEST_F(IndexedDBFactoryTest, DatabaseFailedOpen) { |
new UpgradeNeededCallbacks()); |
std::unique_ptr<IndexedDBPendingConnection> connection( |
base::MakeUnique<IndexedDBPendingConnection>( |
- callbacks, db_callbacks, 0 /* child_process_id */, transaction_id, |
+ callbacks, change_handler, 0 /* child_process_id */, transaction_id, |
db_version)); |
factory()->Open(db_name, std::move(connection), |
nullptr /* request_context */, origin, |
@@ -503,6 +520,7 @@ TEST_F(IndexedDBFactoryTest, DatabaseFailedOpen) { |
// Terminate all pending-close timers. |
factory()->ForceClose(origin); |
+#endif |
} |
} // namespace content |