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

Unified Diff: content/browser/indexed_db/indexed_db_factory_unittest.cc

Issue 1841553002: IndexedDB: Use url::Origin rather than GURL for representing origins (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@origin-idb
Patch Set: Rebased Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
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 bc52fd6cfeaaad1b21e3a7b43b17ef6a4f45d783..0a6ddab4e266328a0a8b3cd04fb5ce4bdd342b20 100644
--- a/content/browser/indexed_db/indexed_db_factory_unittest.cc
+++ b/content/browser/indexed_db/indexed_db_factory_unittest.cc
@@ -22,8 +22,10 @@
#include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBDatabaseException.h"
#include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h"
#include "url/gurl.h"
+#include "url/origin.h"
using base::ASCIIToUTF16;
+using url::Origin;
namespace content {
@@ -34,7 +36,7 @@ class MockIDBFactory : public IndexedDBFactoryImpl {
explicit MockIDBFactory(IndexedDBContextImpl* context)
: IndexedDBFactoryImpl(context) {}
scoped_refptr<IndexedDBBackingStore> TestOpenBackingStore(
- const GURL& origin,
+ const Origin& origin,
const base::FilePath& data_directory) {
blink::WebIDBDataLoss data_loss =
blink::WebIDBDataLossNone;
@@ -54,12 +56,12 @@ class MockIDBFactory : public IndexedDBFactoryImpl {
}
void TestCloseBackingStore(IndexedDBBackingStore* backing_store) {
- CloseBackingStore(backing_store->origin_url());
+ CloseBackingStore(backing_store->origin());
}
void TestReleaseBackingStore(IndexedDBBackingStore* backing_store,
bool immediate) {
- ReleaseBackingStore(backing_store->origin_url(), immediate);
+ ReleaseBackingStore(backing_store->origin(), immediate);
}
private:
@@ -101,8 +103,8 @@ class IndexedDBFactoryTest : public testing::Test {
};
TEST_F(IndexedDBFactoryTest, BackingStoreLifetime) {
- GURL origin1("http://localhost:81");
- GURL origin2("http://localhost:82");
+ const Origin origin1(GURL("http://localhost:81"));
+ const Origin origin2(GURL("http://localhost:82"));
base::ScopedTempDir temp_directory;
ASSERT_TRUE(temp_directory.CreateUniqueTempDir());
@@ -128,7 +130,7 @@ TEST_F(IndexedDBFactoryTest, BackingStoreLifetime) {
}
TEST_F(IndexedDBFactoryTest, BackingStoreLazyClose) {
- GURL origin("http://localhost:81");
+ const Origin origin(GURL("http://localhost:81"));
base::ScopedTempDir temp_directory;
ASSERT_TRUE(temp_directory.CreateUniqueTempDir());
@@ -156,8 +158,8 @@ TEST_F(IndexedDBFactoryTest, BackingStoreLazyClose) {
}
TEST_F(IndexedDBFactoryTest, MemoryBackingStoreLifetime) {
- GURL origin1("http://localhost:81");
- GURL origin2("http://localhost:82");
+ const Origin origin1(GURL("http://localhost:81"));
+ const Origin origin2(GURL("http://localhost:82"));
scoped_refptr<IndexedDBBackingStore> mem_store1 =
factory()->TestOpenBackingStore(origin1, base::FilePath());
@@ -194,12 +196,12 @@ TEST_F(IndexedDBFactoryTest, RejectLongOrigins) {
EXPECT_GT(limit, 0);
std::string origin(limit + 1, 'x');
- GURL too_long_origin("http://" + origin + ":81/");
+ Origin too_long_origin(GURL("http://" + origin + ":81/"));
scoped_refptr<IndexedDBBackingStore> diskStore1 =
factory()->TestOpenBackingStore(too_long_origin, base_path);
EXPECT_FALSE(diskStore1.get());
- GURL ok_origin("http://someorigin.com:82/");
+ Origin ok_origin(GURL("http://someorigin.com:82/"));
scoped_refptr<IndexedDBBackingStore> diskStore2 =
factory()->TestOpenBackingStore(ok_origin, base_path);
EXPECT_TRUE(diskStore2.get());
@@ -215,7 +217,7 @@ class DiskFullFactory : public IndexedDBFactoryImpl {
private:
~DiskFullFactory() override {}
scoped_refptr<IndexedDBBackingStore> OpenBackingStore(
- const GURL& origin_url,
+ const Origin& origin,
const base::FilePath& data_directory,
net::URLRequestContext* request_context,
blink::WebIDBDataLoss* data_loss,
@@ -248,7 +250,7 @@ class LookingForQuotaErrorMockCallbacks : public IndexedDBCallbacks {
};
TEST_F(IndexedDBFactoryTest, QuotaErrorOnDiskFull) {
- const GURL origin("http://localhost:81");
+ const Origin origin(GURL("http://localhost:81"));
base::ScopedTempDir temp_directory;
ASSERT_TRUE(temp_directory.CreateUniqueTempDir());
@@ -263,13 +265,13 @@ TEST_F(IndexedDBFactoryTest, QuotaErrorOnDiskFull) {
0, /* child_process_id */
2, /* transaction_id */
1 /* version */);
- factory->Open(name, connection, NULL /* request_context */,
- url::Origin(origin), temp_directory.path());
+ factory->Open(name, connection, NULL /* request_context */, origin,
+ temp_directory.path());
EXPECT_TRUE(callbacks->error_called());
}
TEST_F(IndexedDBFactoryTest, BackingStoreReleasedOnForcedClose) {
- GURL origin("http://localhost:81");
+ const Origin origin(GURL("http://localhost:81"));
base::ScopedTempDir temp_directory;
ASSERT_TRUE(temp_directory.CreateUniqueTempDir());
@@ -282,7 +284,7 @@ TEST_F(IndexedDBFactoryTest, BackingStoreReleasedOnForcedClose) {
callbacks, db_callbacks, 0, /* child_process_id */
transaction_id, IndexedDBDatabaseMetadata::DEFAULT_VERSION);
factory()->Open(ASCIIToUTF16("db"), connection, NULL /* request_context */,
- url::Origin(origin), temp_directory.path());
+ origin, temp_directory.path());
EXPECT_TRUE(callbacks->connection());
@@ -296,7 +298,7 @@ TEST_F(IndexedDBFactoryTest, BackingStoreReleasedOnForcedClose) {
}
TEST_F(IndexedDBFactoryTest, BackingStoreReleaseDelayedOnClose) {
- GURL origin("http://localhost:81");
+ const Origin origin(GURL("http://localhost:81"));
base::ScopedTempDir temp_directory;
ASSERT_TRUE(temp_directory.CreateUniqueTempDir());
@@ -309,7 +311,7 @@ TEST_F(IndexedDBFactoryTest, BackingStoreReleaseDelayedOnClose) {
callbacks, db_callbacks, 0, /* child_process_id */
transaction_id, IndexedDBDatabaseMetadata::DEFAULT_VERSION);
factory()->Open(ASCIIToUTF16("db"), connection, NULL /* request_context */,
- url::Origin(origin), temp_directory.path());
+ origin, temp_directory.path());
EXPECT_TRUE(callbacks->connection());
IndexedDBBackingStore* store =
@@ -334,7 +336,7 @@ TEST_F(IndexedDBFactoryTest, BackingStoreReleaseDelayedOnClose) {
}
TEST_F(IndexedDBFactoryTest, DeleteDatabaseClosesBackingStore) {
- GURL origin("http://localhost:81");
+ const Origin origin(GURL("http://localhost:81"));
base::ScopedTempDir temp_directory;
ASSERT_TRUE(temp_directory.CreateUniqueTempDir());
@@ -345,8 +347,7 @@ TEST_F(IndexedDBFactoryTest, DeleteDatabaseClosesBackingStore) {
scoped_refptr<MockIndexedDBCallbacks> callbacks(
new MockIndexedDBCallbacks(expect_connection));
factory()->DeleteDatabase(ASCIIToUTF16("db"), NULL /* request_context */,
- callbacks, url::Origin(origin),
- temp_directory.path());
+ callbacks, origin, temp_directory.path());
EXPECT_TRUE(factory()->IsBackingStoreOpen(origin));
EXPECT_TRUE(factory()->IsBackingStorePendingClose(origin));
@@ -359,7 +360,7 @@ TEST_F(IndexedDBFactoryTest, DeleteDatabaseClosesBackingStore) {
}
TEST_F(IndexedDBFactoryTest, GetDatabaseNamesClosesBackingStore) {
- GURL origin("http://localhost:81");
+ const Origin origin(GURL("http://localhost:81"));
base::ScopedTempDir temp_directory;
ASSERT_TRUE(temp_directory.CreateUniqueTempDir());
@@ -369,8 +370,7 @@ TEST_F(IndexedDBFactoryTest, GetDatabaseNamesClosesBackingStore) {
const bool expect_connection = false;
scoped_refptr<MockIndexedDBCallbacks> callbacks(
new MockIndexedDBCallbacks(expect_connection));
- factory()->GetDatabaseNames(callbacks, url::Origin(origin),
- temp_directory.path(),
+ factory()->GetDatabaseNames(callbacks, origin, temp_directory.path(),
NULL /* request_context */);
EXPECT_TRUE(factory()->IsBackingStoreOpen(origin));
@@ -384,7 +384,7 @@ TEST_F(IndexedDBFactoryTest, GetDatabaseNamesClosesBackingStore) {
}
TEST_F(IndexedDBFactoryTest, ForceCloseReleasesBackingStore) {
- GURL origin("http://localhost:81");
+ const Origin origin(GURL("http://localhost:81"));
base::ScopedTempDir temp_directory;
ASSERT_TRUE(temp_directory.CreateUniqueTempDir());
@@ -397,7 +397,7 @@ TEST_F(IndexedDBFactoryTest, ForceCloseReleasesBackingStore) {
callbacks, db_callbacks, 0, /* child_process_id */
transaction_id, IndexedDBDatabaseMetadata::DEFAULT_VERSION);
factory()->Open(ASCIIToUTF16("db"), connection, NULL /* request_context */,
- url::Origin(origin), temp_directory.path());
+ origin, temp_directory.path());
EXPECT_TRUE(callbacks->connection());
EXPECT_TRUE(factory()->IsBackingStoreOpen(origin));
@@ -458,7 +458,7 @@ class ErrorCallbacks : public MockIndexedDBCallbacks {
};
TEST_F(IndexedDBFactoryTest, DatabaseFailedOpen) {
- GURL origin("http://localhost:81");
+ const Origin origin(GURL("http://localhost:81"));
base::ScopedTempDir temp_directory;
ASSERT_TRUE(temp_directory.CreateUniqueTempDir());
@@ -478,8 +478,8 @@ TEST_F(IndexedDBFactoryTest, DatabaseFailedOpen) {
0, /* child_process_id */
transaction_id,
db_version);
- factory()->Open(db_name, connection, NULL /* request_context */,
- url::Origin(origin), temp_directory.path());
+ factory()->Open(db_name, connection, NULL /* request_context */, origin,
+ temp_directory.path());
EXPECT_TRUE(factory()->IsDatabaseOpen(origin, db_name));
// Pump the message loop so the upgrade transaction can run.
@@ -500,8 +500,8 @@ TEST_F(IndexedDBFactoryTest, DatabaseFailedOpen) {
0, /* child_process_id */
transaction_id,
db_version - 1);
- factory()->Open(db_name, connection, NULL /* request_context */,
- url::Origin(origin), temp_directory.path());
+ factory()->Open(db_name, connection, NULL /* request_context */, origin,
+ temp_directory.path());
EXPECT_TRUE(callbacks->saw_error());
EXPECT_FALSE(factory()->IsDatabaseOpen(origin, db_name));
}
« no previous file with comments | « content/browser/indexed_db/indexed_db_factory_impl.cc ('k') | content/browser/indexed_db/indexed_db_fake_backing_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698