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

Unified Diff: content/browser/indexed_db/indexed_db_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: Created 4 years, 9 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_unittest.cc
diff --git a/content/browser/indexed_db/indexed_db_unittest.cc b/content/browser/indexed_db/indexed_db_unittest.cc
index 24dcaa6db71f57e51b4aee791840150c6f9d3c97..f14ad96fd3437819350b8aa6433d89f818debbec 100644
--- a/content/browser/indexed_db/indexed_db_unittest.cc
+++ b/content/browser/indexed_db/indexed_db_unittest.cc
@@ -30,18 +30,19 @@ namespace content {
class IndexedDBTest : public testing::Test {
public:
- const GURL kNormalOrigin;
- const GURL kSessionOnlyOrigin;
+ const url::Origin kNormalOrigin;
+ const url::Origin kSessionOnlyOrigin;
IndexedDBTest()
- : kNormalOrigin("http://normal/"),
- kSessionOnlyOrigin("http://session-only/"),
+ : kNormalOrigin(GURL("http://normal/")),
+ kSessionOnlyOrigin(GURL("http://session-only/")),
task_runner_(new base::TestSimpleTaskRunner),
special_storage_policy_(new MockSpecialStoragePolicy),
quota_manager_proxy_(new MockQuotaManagerProxy(nullptr, nullptr)),
file_thread_(BrowserThread::FILE_USER_BLOCKING, &message_loop_),
io_thread_(BrowserThread::IO, &message_loop_) {
- special_storage_policy_->AddSessionOnly(kSessionOnlyOrigin);
+ special_storage_policy_->AddSessionOnly(
+ GURL(kSessionOnlyOrigin.Serialize()));
}
~IndexedDBTest() override {
quota_manager_proxy_->SimulateQuotaManagerDestroyed();
@@ -132,17 +133,17 @@ TEST_F(IndexedDBTest, SetForceKeepSessionState) {
class ForceCloseDBCallbacks : public IndexedDBCallbacks {
public:
ForceCloseDBCallbacks(scoped_refptr<IndexedDBContextImpl> idb_context,
- const GURL& origin_url)
+ const url::Origin& origin)
: IndexedDBCallbacks(NULL, 0, 0),
idb_context_(idb_context),
- origin_url_(origin_url) {}
+ origin_(origin) {}
void OnSuccess() override {}
void OnSuccess(const std::vector<base::string16>&) override {}
void OnSuccess(scoped_ptr<IndexedDBConnection> connection,
const IndexedDBDatabaseMetadata& metadata) override {
connection_ = std::move(connection);
- idb_context_->ConnectionOpened(origin_url_, connection_.get());
+ idb_context_->ConnectionOpened(origin_, connection_.get());
}
IndexedDBConnection* connection() { return connection_.get(); }
@@ -152,7 +153,7 @@ class ForceCloseDBCallbacks : public IndexedDBCallbacks {
private:
scoped_refptr<IndexedDBContextImpl> idb_context_;
- GURL origin_url_;
+ url::Origin origin_;
scoped_ptr<IndexedDBConnection> connection_;
DISALLOW_COPY_AND_ASSIGN(ForceCloseDBCallbacks);
};
@@ -172,7 +173,7 @@ TEST_F(IndexedDBTest, ForceCloseOpenDatabasesOnDelete) {
{
TestBrowserContext browser_context;
- const GURL kTestOrigin("http://test/");
+ const url::Origin kTestOrigin(GURL("http://test/"));
scoped_refptr<IndexedDBContextImpl> idb_context =
new IndexedDBContextImpl(temp_dir.path(),
@@ -209,10 +210,13 @@ TEST_F(IndexedDBTest, ForceCloseOpenDatabasesOnDelete) {
closed_callbacks->connection()->Close();
+ // TODO(jsbell): Remove static_cast<> when overloads are eliminated.
idb_context->TaskRunner()->PostTask(
FROM_HERE,
base::Bind(
- &IndexedDBContextImpl::DeleteForOrigin, idb_context, kTestOrigin));
+ static_cast<void (IndexedDBContextImpl::*)(const url::Origin&)>(
+ &IndexedDBContextImpl::DeleteForOrigin),
+ idb_context, kTestOrigin));
FlushIndexedDBTaskRunner();
message_loop_.RunUntilIdle();
}
@@ -228,7 +232,7 @@ TEST_F(IndexedDBTest, ForceCloseOpenDatabasesOnDelete) {
TEST_F(IndexedDBTest, DeleteFailsIfDirectoryLocked) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- const GURL kTestOrigin("http://test/");
+ const url::Origin kTestOrigin(GURL("http://test/"));
scoped_refptr<IndexedDBContextImpl> idb_context = new IndexedDBContextImpl(
temp_dir.path(), special_storage_policy_.get(),
@@ -241,17 +245,20 @@ TEST_F(IndexedDBTest, DeleteFailsIfDirectoryLocked) {
LevelDBDatabase::LockForTesting(test_path);
ASSERT_TRUE(lock);
+ // TODO(jsbell): Remove static_cast<> when overloads are eliminated.
idb_context->TaskRunner()->PostTask(
FROM_HERE,
base::Bind(
- &IndexedDBContextImpl::DeleteForOrigin, idb_context, kTestOrigin));
+ static_cast<void (IndexedDBContextImpl::*)(const url::Origin&)>(
+ &IndexedDBContextImpl::DeleteForOrigin),
+ idb_context, kTestOrigin));
FlushIndexedDBTaskRunner();
EXPECT_TRUE(base::DirectoryExists(test_path));
}
TEST_F(IndexedDBTest, ForceCloseOpenDatabasesOnCommitFailure) {
- const GURL kTestOrigin("http://test/");
+ const url::Origin kTestOrigin(GURL("http://test/"));
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());

Powered by Google App Engine
This is Rietveld 408576698