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

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: 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_unittest.cc
diff --git a/content/browser/indexed_db/indexed_db_unittest.cc b/content/browser/indexed_db/indexed_db_unittest.cc
index b27080389bfe75903d684cfc1bcc544f1ac756df..ea958de168bacf12b03c5ebea89aca98b59a6350 100644
--- a/content/browser/indexed_db/indexed_db_unittest.cc
+++ b/content/browser/indexed_db/indexed_db_unittest.cc
@@ -26,22 +26,25 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "url/origin.h"
+using url::Origin;
+
namespace content {
class IndexedDBTest : public testing::Test {
public:
- const GURL kNormalOrigin;
- const GURL kSessionOnlyOrigin;
+ const Origin kNormalOrigin;
+ const 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 +135,17 @@ TEST_F(IndexedDBTest, SetForceKeepSessionState) {
class ForceCloseDBCallbacks : public IndexedDBCallbacks {
public:
ForceCloseDBCallbacks(scoped_refptr<IndexedDBContextImpl> idb_context,
- const GURL& origin_url)
+ const 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(std::unique_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 +155,7 @@ class ForceCloseDBCallbacks : public IndexedDBCallbacks {
private:
scoped_refptr<IndexedDBContextImpl> idb_context_;
- GURL origin_url_;
+ Origin origin_;
std::unique_ptr<IndexedDBConnection> connection_;
DISALLOW_COPY_AND_ASSIGN(ForceCloseDBCallbacks);
};
@@ -172,7 +175,7 @@ TEST_F(IndexedDBTest, ForceCloseOpenDatabasesOnDelete) {
{
TestBrowserContext browser_context;
- const GURL kTestOrigin("http://test/");
+ const Origin kTestOrigin(GURL("http://test/"));
scoped_refptr<IndexedDBContextImpl> idb_context =
new IndexedDBContextImpl(temp_dir.path(),
@@ -196,7 +199,7 @@ TEST_F(IndexedDBTest, ForceCloseOpenDatabasesOnDelete) {
0 /* host_transaction_id */,
0 /* version */);
factory->Open(base::ASCIIToUTF16("opendb"), open_connection,
- NULL /* request_context */, url::Origin(kTestOrigin),
+ NULL /* request_context */, Origin(kTestOrigin),
idb_context->data_path());
IndexedDBPendingConnection closed_connection(closed_callbacks,
closed_db_callbacks,
@@ -204,15 +207,17 @@ TEST_F(IndexedDBTest, ForceCloseOpenDatabasesOnDelete) {
0 /* host_transaction_id */,
0 /* version */);
factory->Open(base::ASCIIToUTF16("closeddb"), closed_connection,
- NULL /* request_context */, url::Origin(kTestOrigin),
+ NULL /* request_context */, Origin(kTestOrigin),
idb_context->data_path());
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));
+ base::Bind(static_cast<void (IndexedDBContextImpl::*)(const Origin&)>(
+ &IndexedDBContextImpl::DeleteForOrigin),
+ idb_context, kTestOrigin));
FlushIndexedDBTaskRunner();
message_loop_.RunUntilIdle();
}
@@ -228,7 +233,7 @@ TEST_F(IndexedDBTest, ForceCloseOpenDatabasesOnDelete) {
TEST_F(IndexedDBTest, DeleteFailsIfDirectoryLocked) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
- const GURL kTestOrigin("http://test/");
+ const Origin kTestOrigin(GURL("http://test/"));
scoped_refptr<IndexedDBContextImpl> idb_context = new IndexedDBContextImpl(
temp_dir.path(), special_storage_policy_.get(),
@@ -241,17 +246,19 @@ 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));
+ base::Bind(static_cast<void (IndexedDBContextImpl::*)(const Origin&)>(
+ &IndexedDBContextImpl::DeleteForOrigin),
+ idb_context, kTestOrigin));
FlushIndexedDBTaskRunner();
EXPECT_TRUE(base::DirectoryExists(test_path));
}
TEST_F(IndexedDBTest, ForceCloseOpenDatabasesOnCommitFailure) {
- const GURL kTestOrigin("http://test/");
+ const Origin kTestOrigin(GURL("http://test/"));
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
@@ -271,7 +278,7 @@ TEST_F(IndexedDBTest, ForceCloseOpenDatabasesOnCommitFailure) {
callbacks, db_callbacks, 0 /* child_process_id */, transaction_id,
IndexedDBDatabaseMetadata::DEFAULT_VERSION);
factory->Open(base::ASCIIToUTF16("db"), connection,
- NULL /* request_context */, url::Origin(kTestOrigin),
+ NULL /* request_context */, Origin(kTestOrigin),
temp_dir.path());
EXPECT_TRUE(callbacks->connection());
« no previous file with comments | « content/browser/indexed_db/indexed_db_quota_client.cc ('k') | content/browser/indexed_db/mock_indexed_db_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698