summaryrefslogtreecommitdiffstats
path: root/content/browser/indexed_db
diff options
context:
space:
mode:
authorericu@chromium.org <ericu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-18 01:20:59 +0000
committerericu@chromium.org <ericu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-18 01:20:59 +0000
commitd29650cde71f39cfdf41cf14f8f6eaaddd162f1e (patch)
tree3a60288c48e36ba2cd556ae79f022e5a6d453807 /content/browser/indexed_db
parentad03218bd84c0d3269d6a051ad53446ca5550657 (diff)
downloadchromium_src-d29650cde71f39cfdf41cf14f8f6eaaddd162f1e.zip
chromium_src-d29650cde71f39cfdf41cf14f8f6eaaddd162f1e.tar.gz
chromium_src-d29650cde71f39cfdf41cf14f8f6eaaddd162f1e.tar.bz2
Added IndexedDBPendingConnection to group up a bunch of parameters that get passed around together.
This includes a convenience method CreateConnection in IndexedDBDatabase.cc that's not strictly needed for this change, but makes the merge of other related CLs easier later. BUG=108012 R=cmumford,jsbell Review URL: https://codereview.chromium.org/198223002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257568 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/indexed_db')
-rw-r--r--content/browser/indexed_db/indexed_db_database.cc109
-rw-r--r--content/browser/indexed_db/indexed_db_database.h16
-rw-r--r--content/browser/indexed_db/indexed_db_database_unittest.cc48
-rw-r--r--content/browser/indexed_db/indexed_db_dispatcher_host.cc15
-rw-r--r--content/browser/indexed_db/indexed_db_factory.cc23
-rw-r--r--content/browser/indexed_db/indexed_db_factory.h6
-rw-r--r--content/browser/indexed_db/indexed_db_factory_unittest.cc82
-rw-r--r--content/browser/indexed_db/indexed_db_pending_connection.cc23
-rw-r--r--content/browser/indexed_db/indexed_db_pending_connection.h36
-rw-r--r--content/browser/indexed_db/indexed_db_unittest.cc35
-rw-r--r--content/browser/indexed_db/leveldb/leveldb_transaction.cc6
11 files changed, 228 insertions, 171 deletions
diff --git a/content/browser/indexed_db/indexed_db_database.cc b/content/browser/indexed_db/indexed_db_database.cc
index 83fc7e6..32434ce 100644
--- a/content/browser/indexed_db/indexed_db_database.cc
+++ b/content/browser/indexed_db/indexed_db_database.cc
@@ -17,6 +17,7 @@
#include "content/browser/indexed_db/indexed_db_cursor.h"
#include "content/browser/indexed_db/indexed_db_factory.h"
#include "content/browser/indexed_db/indexed_db_index_writer.h"
+#include "content/browser/indexed_db/indexed_db_pending_connection.h"
#include "content/browser/indexed_db/indexed_db_tracing.h"
#include "content/browser/indexed_db/indexed_db_transaction.h"
#include "content/common/indexed_db/indexed_db_key_path.h"
@@ -29,32 +30,6 @@ using blink::WebIDBKeyTypeNumber;
namespace content {
-// PendingOpenCall has a scoped_refptr<IndexedDBDatabaseCallbacks> because it
-// isn't a connection yet.
-class IndexedDBDatabase::PendingOpenCall {
- public:
- PendingOpenCall(scoped_refptr<IndexedDBCallbacks> callbacks,
- scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks,
- int64 transaction_id,
- int64 version)
- : callbacks_(callbacks),
- database_callbacks_(database_callbacks),
- version_(version),
- transaction_id_(transaction_id) {}
- scoped_refptr<IndexedDBCallbacks> callbacks() const { return callbacks_; }
- scoped_refptr<IndexedDBDatabaseCallbacks> const database_callbacks() {
- return database_callbacks_;
- }
- int64 version() const { return version_; }
- int64 transaction_id() const { return transaction_id_; }
-
- private:
- scoped_refptr<IndexedDBCallbacks> callbacks_;
- scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks_;
- int64 version_;
- const int64 transaction_id_;
-};
-
// PendingUpgradeCall has a scoped_ptr<IndexedDBConnection> because it owns the
// in-progress connection.
class IndexedDBDatabase::PendingUpgradeCall {
@@ -209,6 +184,18 @@ IndexedDBDatabase::~IndexedDBDatabase() {
DCHECK(pending_delete_calls_.empty());
}
+scoped_ptr<IndexedDBConnection> IndexedDBDatabase::CreateConnection(
+ scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks,
+ int child_process_id) {
+ scoped_ptr<IndexedDBConnection> connection(
+ new IndexedDBConnection(this, database_callbacks));
+ connections_.insert(connection.get());
+ /* TODO(ericu): Grant child process permissions here so that the connection
+ * can create Blobs.
+ */
+ return connection.Pass();
+}
+
IndexedDBTransaction* IndexedDBDatabase::GetTransaction(
int64 transaction_id) const {
TransactionMap::const_iterator trans_iterator =
@@ -1348,12 +1335,8 @@ void IndexedDBDatabase::ProcessPendingCalls() {
PendingOpenCallList pending_open_calls;
pending_open_calls_.swap(pending_open_calls);
while (!pending_open_calls.empty()) {
- scoped_ptr<PendingOpenCall> pending_open_call(pending_open_calls.front());
+ OpenConnection(pending_open_calls.front());
pending_open_calls.pop_front();
- OpenConnection(pending_open_call->callbacks(),
- pending_open_call->database_callbacks(),
- pending_open_call->transaction_id(),
- pending_open_call->version());
}
}
}
@@ -1391,10 +1374,7 @@ bool IndexedDBDatabase::IsOpenConnectionBlocked() const {
}
void IndexedDBDatabase::OpenConnection(
- scoped_refptr<IndexedDBCallbacks> callbacks,
- scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks,
- int64 transaction_id,
- int64 version) {
+ const IndexedDBPendingConnection& connection) {
DCHECK(backing_store_);
// TODO(jsbell): Should have a priority queue so that higher version
@@ -1403,9 +1383,8 @@ void IndexedDBDatabase::OpenConnection(
// The backing store only detects data loss when it is first opened. The
// presence of existing connections means we didn't even check for data loss
// so there'd better not be any.
- DCHECK_NE(blink::WebIDBDataLossTotal, callbacks->data_loss());
- pending_open_calls_.push_back(new PendingOpenCall(
- callbacks, database_callbacks, transaction_id, version));
+ DCHECK_NE(blink::WebIDBDataLossTotal, connection.callbacks->data_loss());
+ pending_open_calls_.push_back(connection);
return;
}
@@ -1417,15 +1396,15 @@ void IndexedDBDatabase::OpenConnection(
metadata_.int_version);
} else {
base::string16 message;
- if (version == IndexedDBDatabaseMetadata::NO_INT_VERSION) {
+ if (connection.version == IndexedDBDatabaseMetadata::NO_INT_VERSION) {
message = ASCIIToUTF16(
"Internal error opening database with no version specified.");
} else {
message =
ASCIIToUTF16("Internal error opening database with version ") +
- Int64ToString16(version);
+ Int64ToString16(connection.version);
}
- callbacks->OnError(IndexedDBDatabaseError(
+ connection.callbacks->OnError(IndexedDBDatabaseError(
blink::WebIDBDatabaseExceptionUnknownError, message));
return;
}
@@ -1437,47 +1416,55 @@ void IndexedDBDatabase::OpenConnection(
metadata_.version == kNoStringVersion &&
metadata_.int_version == IndexedDBDatabaseMetadata::NO_INT_VERSION;
- scoped_ptr<IndexedDBConnection> connection(
- new IndexedDBConnection(this, database_callbacks));
-
- if (version == IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION) {
+ if (connection.version == IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION) {
// For unit tests only - skip upgrade steps. Calling from script with
// DEFAULT_INT_VERSION throws exception.
// TODO(jsbell): DCHECK that not in unit tests.
DCHECK(is_new_database);
- connections_.insert(connection.get());
- callbacks->OnSuccess(connection.Pass(), this->metadata());
+ connection.callbacks->OnSuccess(
+ CreateConnection(connection.database_callbacks,
+ connection.child_process_id),
+ this->metadata());
return;
}
- if (version == IndexedDBDatabaseMetadata::NO_INT_VERSION) {
+ // We may need to change the version.
+ int64 local_version = connection.version;
+ if (local_version == IndexedDBDatabaseMetadata::NO_INT_VERSION) {
if (!is_new_database) {
- connections_.insert(connection.get());
- callbacks->OnSuccess(connection.Pass(), this->metadata());
+ connection.callbacks->OnSuccess(
+ CreateConnection(connection.database_callbacks,
+ connection.child_process_id),
+ this->metadata());
return;
}
// Spec says: If no version is specified and no database exists, set
// database version to 1.
- version = 1;
+ local_version = 1;
}
- if (version > metadata_.int_version) {
- connections_.insert(connection.get());
- RunVersionChangeTransaction(
- callbacks, connection.Pass(), transaction_id, version);
+ if (local_version > metadata_.int_version) {
+ RunVersionChangeTransaction(connection.callbacks,
+ CreateConnection(connection.database_callbacks,
+ connection.child_process_id),
+ connection.transaction_id,
+ local_version);
return;
}
- if (version < metadata_.int_version) {
- callbacks->OnError(IndexedDBDatabaseError(
+ if (local_version < metadata_.int_version) {
+ connection.callbacks->OnError(IndexedDBDatabaseError(
blink::WebIDBDatabaseExceptionVersionError,
- ASCIIToUTF16("The requested version (") + Int64ToString16(version) +
+ ASCIIToUTF16("The requested version (") +
+ Int64ToString16(local_version) +
ASCIIToUTF16(") is less than the existing version (") +
Int64ToString16(metadata_.int_version) + ASCIIToUTF16(").")));
return;
}
- DCHECK_EQ(version, metadata_.int_version);
- connections_.insert(connection.get());
- callbacks->OnSuccess(connection.Pass(), this->metadata());
+ DCHECK_EQ(local_version, metadata_.int_version);
+ connection.callbacks->OnSuccess(
+ CreateConnection(connection.database_callbacks,
+ connection.child_process_id),
+ this->metadata());
}
void IndexedDBDatabase::RunVersionChangeTransaction(
diff --git a/content/browser/indexed_db/indexed_db_database.h b/content/browser/indexed_db/indexed_db_database.h
index 902d355..8c766eb 100644
--- a/content/browser/indexed_db/indexed_db_database.h
+++ b/content/browser/indexed_db/indexed_db_database.h
@@ -17,6 +17,7 @@
#include "content/browser/indexed_db/indexed_db_backing_store.h"
#include "content/browser/indexed_db/indexed_db_callbacks.h"
#include "content/browser/indexed_db/indexed_db_metadata.h"
+#include "content/browser/indexed_db/indexed_db_pending_connection.h"
#include "content/browser/indexed_db/indexed_db_transaction_coordinator.h"
#include "content/browser/indexed_db/list_set.h"
#include "url/gurl.h"
@@ -74,11 +75,7 @@ class CONTENT_EXPORT IndexedDBDatabase
int64 new_max_index_id);
void RemoveIndex(int64 object_store_id, int64 index_id);
- void OpenConnection(
- scoped_refptr<IndexedDBCallbacks> callbacks,
- scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks,
- int64 transaction_id,
- int64 version);
+ void OpenConnection(const IndexedDBPendingConnection& connection);
void DeleteDatabase(scoped_refptr<IndexedDBCallbacks> callbacks);
const IndexedDBDatabaseMetadata& metadata() const { return metadata_; }
@@ -256,6 +253,10 @@ class CONTENT_EXPORT IndexedDBDatabase
bool IsDeleteDatabaseBlocked() const;
void DeleteDatabaseFinal(scoped_refptr<IndexedDBCallbacks> callbacks);
+ scoped_ptr<IndexedDBConnection> CreateConnection(
+ scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks,
+ int child_process_id);
+
IndexedDBTransaction* GetTransaction(int64 transaction_id) const;
bool ValidateObjectStoreId(int64 object_store_id) const;
@@ -270,8 +271,6 @@ class CONTENT_EXPORT IndexedDBDatabase
IndexedDBDatabaseMetadata metadata_;
const Identifier identifier_;
- // This might not need to be a scoped_refptr since the factory's lifetime is
- // that of the page group, but it's better to be conservitive than sorry.
scoped_refptr<IndexedDBFactory> factory_;
IndexedDBTransactionCoordinator transaction_coordinator_;
@@ -279,8 +278,7 @@ class CONTENT_EXPORT IndexedDBDatabase
typedef std::map<int64, IndexedDBTransaction*> TransactionMap;
TransactionMap transactions_;
- class PendingOpenCall;
- typedef std::list<PendingOpenCall*> PendingOpenCallList;
+ typedef std::list<IndexedDBPendingConnection> PendingOpenCallList;
PendingOpenCallList pending_open_calls_;
class PendingUpgradeCall;
diff --git a/content/browser/indexed_db/indexed_db_database_unittest.cc b/content/browser/indexed_db/indexed_db_database_unittest.cc
index 902e004..46a26ec 100644
--- a/content/browser/indexed_db/indexed_db_database_unittest.cc
+++ b/content/browser/indexed_db/indexed_db_database_unittest.cc
@@ -23,6 +23,10 @@
using base::ASCIIToUTF16;
+namespace {
+const int FAKE_CHILD_PROCESS_ID = 0;
+}
+
namespace content {
TEST(IndexedDBDatabaseTest, BackingStoreRetention) {
@@ -59,10 +63,13 @@ TEST(IndexedDBDatabaseTest, ConnectionLifecycle) {
scoped_refptr<MockIndexedDBDatabaseCallbacks> callbacks1(
new MockIndexedDBDatabaseCallbacks());
const int64 transaction_id1 = 1;
- db->OpenConnection(request1,
- callbacks1,
- transaction_id1,
- IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION);
+ IndexedDBPendingConnection connection1(
+ request1,
+ callbacks1,
+ FAKE_CHILD_PROCESS_ID,
+ transaction_id1,
+ IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION);
+ db->OpenConnection(connection1);
EXPECT_FALSE(backing_store->HasOneRef()); // db, connection count > 0
@@ -70,10 +77,13 @@ TEST(IndexedDBDatabaseTest, ConnectionLifecycle) {
scoped_refptr<MockIndexedDBDatabaseCallbacks> callbacks2(
new MockIndexedDBDatabaseCallbacks());
const int64 transaction_id2 = 2;
- db->OpenConnection(request2,
- callbacks2,
- transaction_id2,
- IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION);
+ IndexedDBPendingConnection connection2(
+ request2,
+ callbacks2,
+ FAKE_CHILD_PROCESS_ID,
+ transaction_id2,
+ IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION);
+ db->OpenConnection(connection2);
EXPECT_FALSE(backing_store->HasOneRef()); // local and connection
@@ -109,10 +119,13 @@ TEST(IndexedDBDatabaseTest, ForcedClose) {
new MockIndexedDBDatabaseCallbacks());
scoped_refptr<MockIndexedDBCallbacks> request(new MockIndexedDBCallbacks());
const int64 upgrade_transaction_id = 3;
- database->OpenConnection(request,
- callbacks,
- upgrade_transaction_id,
- IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION);
+ IndexedDBPendingConnection connection(
+ request,
+ callbacks,
+ FAKE_CHILD_PROCESS_ID,
+ upgrade_transaction_id,
+ IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION);
+ database->OpenConnection(connection);
EXPECT_EQ(database, request->connection()->database());
const int64 transaction_id = 123;
@@ -167,10 +180,13 @@ TEST(IndexedDBDatabaseTest, PendingDelete) {
scoped_refptr<MockIndexedDBDatabaseCallbacks> callbacks1(
new MockIndexedDBDatabaseCallbacks());
const int64 transaction_id1 = 1;
- db->OpenConnection(request1,
- callbacks1,
- transaction_id1,
- IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION);
+ IndexedDBPendingConnection connection(
+ request1,
+ callbacks1,
+ FAKE_CHILD_PROCESS_ID,
+ transaction_id1,
+ IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION);
+ db->OpenConnection(connection);
EXPECT_FALSE(backing_store->HasOneRef()); // local and db
diff --git a/content/browser/indexed_db/indexed_db_dispatcher_host.cc b/content/browser/indexed_db/indexed_db_dispatcher_host.cc
index c66fc1f..4ec31fc 100644
--- a/content/browser/indexed_db/indexed_db_dispatcher_host.cc
+++ b/content/browser/indexed_db/indexed_db_dispatcher_host.cc
@@ -16,6 +16,7 @@
#include "content/browser/indexed_db/indexed_db_cursor.h"
#include "content/browser/indexed_db/indexed_db_database_callbacks.h"
#include "content/browser/indexed_db/indexed_db_metadata.h"
+#include "content/browser/indexed_db/indexed_db_pending_connection.h"
#include "content/browser/renderer_host/render_message_filter.h"
#include "content/common/indexed_db/indexed_db_messages.h"
#include "content/public/browser/browser_thread.h"
@@ -272,13 +273,13 @@ void IndexedDBDispatcherHost::OnIDBFactoryOpen(
scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks =
new IndexedDBDatabaseCallbacks(
this, params.ipc_thread_id, params.ipc_database_callbacks_id);
- Context()->GetIDBFactory()->Open(params.name,
- params.version,
- host_transaction_id,
- callbacks,
- database_callbacks,
- origin_url,
- indexed_db_path);
+ IndexedDBPendingConnection connection(callbacks,
+ database_callbacks,
+ 0 /* TODO(ericu) ipc_process_id */,
+ host_transaction_id,
+ params.version);
+ Context()->GetIDBFactory()->Open(
+ params.name, connection, origin_url, indexed_db_path);
}
void IndexedDBDispatcherHost::OnIDBFactoryDeleteDatabase(
diff --git a/content/browser/indexed_db/indexed_db_factory.cc b/content/browser/indexed_db/indexed_db_factory.cc
index 5fec2a9..86af571 100644
--- a/content/browser/indexed_db/indexed_db_factory.cc
+++ b/content/browser/indexed_db/indexed_db_factory.cc
@@ -294,14 +294,10 @@ scoped_refptr<IndexedDBBackingStore> IndexedDBFactory::OpenBackingStore(
return 0;
}
-void IndexedDBFactory::Open(
- const base::string16& name,
- int64 version,
- int64 transaction_id,
- scoped_refptr<IndexedDBCallbacks> callbacks,
- scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks,
- const GURL& origin_url,
- const base::FilePath& data_directory) {
+void IndexedDBFactory::Open(const base::string16& name,
+ const IndexedDBPendingConnection& connection,
+ const GURL& origin_url,
+ const base::FilePath& data_directory) {
IDB_TRACE("IndexedDBFactory::Open");
scoped_refptr<IndexedDBDatabase> database;
IndexedDBDatabase::Identifier unique_identifier(origin_url, name);
@@ -320,14 +316,14 @@ void IndexedDBFactory::Open(
&disk_full);
if (!backing_store) {
if (disk_full) {
- callbacks->OnError(
+ connection.callbacks->OnError(
IndexedDBDatabaseError(blink::WebIDBDatabaseExceptionQuotaError,
ASCIIToUTF16(
"Encountered full disk while opening "
"backing store for indexedDB.open.")));
return;
}
- callbacks->OnError(IndexedDBDatabaseError(
+ connection.callbacks->OnError(IndexedDBDatabaseError(
blink::WebIDBDatabaseExceptionUnknownError,
ASCIIToUTF16(
"Internal error opening backing store for indexedDB.open.")));
@@ -337,7 +333,7 @@ void IndexedDBFactory::Open(
database =
IndexedDBDatabase::Create(name, backing_store, this, unique_identifier);
if (!database) {
- callbacks->OnError(IndexedDBDatabaseError(
+ connection.callbacks->OnError(IndexedDBDatabaseError(
blink::WebIDBDatabaseExceptionUnknownError,
ASCIIToUTF16(
"Internal error creating database backend for indexedDB.open.")));
@@ -348,10 +344,9 @@ void IndexedDBFactory::Open(
}
if (data_loss != blink::WebIDBDataLossNone)
- callbacks->OnDataLoss(data_loss, data_loss_message);
+ connection.callbacks->OnDataLoss(data_loss, data_loss_message);
- database->OpenConnection(
- callbacks, database_callbacks, transaction_id, version);
+ database->OpenConnection(connection);
if (!was_open && database->ConnectionCount() > 0) {
database_map_[unique_identifier] = database;
diff --git a/content/browser/indexed_db/indexed_db_factory.h b/content/browser/indexed_db/indexed_db_factory.h
index e42d4fa..af2ba54 100644
--- a/content/browser/indexed_db/indexed_db_factory.h
+++ b/content/browser/indexed_db/indexed_db_factory.h
@@ -22,6 +22,7 @@ namespace content {
class IndexedDBBackingStore;
class IndexedDBContextImpl;
+struct IndexedDBPendingConnection;
class CONTENT_EXPORT IndexedDBFactory
: NON_EXPORTED_BASE(public base::RefCountedThreadSafe<IndexedDBFactory>) {
@@ -39,10 +40,7 @@ class CONTENT_EXPORT IndexedDBFactory
const GURL& origin_url,
const base::FilePath& data_directory);
void Open(const base::string16& name,
- int64 version,
- int64 transaction_id,
- scoped_refptr<IndexedDBCallbacks> callbacks,
- scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks,
+ const IndexedDBPendingConnection& connection,
const GURL& origin_url,
const base::FilePath& data_directory);
diff --git a/content/browser/indexed_db/indexed_db_factory_unittest.cc b/content/browser/indexed_db/indexed_db_factory_unittest.cc
index ef045e5..1038035 100644
--- a/content/browser/indexed_db/indexed_db_factory_unittest.cc
+++ b/content/browser/indexed_db/indexed_db_factory_unittest.cc
@@ -218,13 +218,13 @@ TEST_F(IndexedDBFactoryTest, QuotaErrorOnDiskFull) {
scoped_refptr<IndexedDBDatabaseCallbacks> dummy_database_callbacks =
new IndexedDBDatabaseCallbacks(NULL, 0, 0);
const base::string16 name(ASCIIToUTF16("name"));
- factory->Open(name,
- 1, /* version */
- 2, /* transaction_id */
- callbacks,
- dummy_database_callbacks,
- origin,
- base::FilePath(FILE_PATH_LITERAL("/dummy")));
+ IndexedDBPendingConnection connection(callbacks,
+ dummy_database_callbacks,
+ 0, /* child_process_id */
+ 2, /* transaction_id */
+ 1 /* version */);
+ factory->Open(
+ name, connection, origin, base::FilePath(FILE_PATH_LITERAL("/dummy")));
}
TEST_F(IndexedDBFactoryTest, BackingStoreReleasedOnForcedClose) {
@@ -239,13 +239,13 @@ TEST_F(IndexedDBFactoryTest, BackingStoreReleasedOnForcedClose) {
scoped_refptr<MockIndexedDBDatabaseCallbacks> db_callbacks(
new MockIndexedDBDatabaseCallbacks());
const int64 transaction_id = 1;
- factory->Open(ASCIIToUTF16("db"),
- IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION,
- transaction_id,
- callbacks,
- db_callbacks,
- origin,
- temp_directory.path());
+ IndexedDBPendingConnection connection(
+ callbacks,
+ db_callbacks,
+ 0, /* child_process_id */
+ transaction_id,
+ IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION);
+ factory->Open(ASCIIToUTF16("db"), connection, origin, temp_directory.path());
EXPECT_TRUE(callbacks->connection());
@@ -270,13 +270,13 @@ TEST_F(IndexedDBFactoryTest, BackingStoreReleaseDelayedOnClose) {
scoped_refptr<MockIndexedDBDatabaseCallbacks> db_callbacks(
new MockIndexedDBDatabaseCallbacks());
const int64 transaction_id = 1;
- factory->Open(ASCIIToUTF16("db"),
- IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION,
- transaction_id,
- callbacks,
- db_callbacks,
- origin,
- temp_directory.path());
+ IndexedDBPendingConnection connection(
+ callbacks,
+ db_callbacks,
+ 0, /* child_process_id */
+ transaction_id,
+ IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION);
+ factory->Open(ASCIIToUTF16("db"), connection, origin, temp_directory.path());
EXPECT_TRUE(callbacks->connection());
IndexedDBBackingStore* store =
@@ -365,13 +365,13 @@ TEST_F(IndexedDBFactoryTest, ForceCloseReleasesBackingStore) {
scoped_refptr<MockIndexedDBDatabaseCallbacks> db_callbacks(
new MockIndexedDBDatabaseCallbacks());
const int64 transaction_id = 1;
- factory->Open(ASCIIToUTF16("db"),
- IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION,
- transaction_id,
- callbacks,
- db_callbacks,
- origin,
- temp_directory.path());
+ IndexedDBPendingConnection connection(
+ callbacks,
+ db_callbacks,
+ 0, /* child_process_id */
+ transaction_id,
+ IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION);
+ factory->Open(ASCIIToUTF16("db"), connection, origin, temp_directory.path());
EXPECT_TRUE(callbacks->connection());
EXPECT_TRUE(factory->IsBackingStoreOpen(origin));
@@ -442,13 +442,12 @@ TEST_F(IndexedDBFactoryTest, DatabaseFailedOpen) {
{
scoped_refptr<MockIndexedDBCallbacks> callbacks(
new UpgradeNeededCallbacks());
- factory->Open(db_name,
- db_version,
- transaction_id,
- callbacks,
- db_callbacks,
- origin,
- temp_directory.path());
+ IndexedDBPendingConnection connection(callbacks,
+ db_callbacks,
+ 0, /* child_process_id */
+ transaction_id,
+ db_version);
+ factory->Open(db_name, connection, origin, temp_directory.path());
EXPECT_TRUE(factory->IsDatabaseOpen(origin, db_name));
// Pump the message loop so the upgrade transaction can run.
@@ -464,13 +463,12 @@ TEST_F(IndexedDBFactoryTest, DatabaseFailedOpen) {
// the database object.
{
scoped_refptr<IndexedDBCallbacks> callbacks(new ErrorCallbacks());
- factory->Open(db_name,
- db_version - 1,
- transaction_id,
- callbacks,
- db_callbacks,
- origin,
- temp_directory.path());
+ IndexedDBPendingConnection connection(callbacks,
+ db_callbacks,
+ 0, /* child_process_id */
+ transaction_id,
+ db_version - 1);
+ factory->Open(db_name, connection, origin, temp_directory.path());
EXPECT_FALSE(factory->IsDatabaseOpen(origin, db_name));
}
diff --git a/content/browser/indexed_db/indexed_db_pending_connection.cc b/content/browser/indexed_db/indexed_db_pending_connection.cc
new file mode 100644
index 0000000..b1d6318
--- /dev/null
+++ b/content/browser/indexed_db/indexed_db_pending_connection.cc
@@ -0,0 +1,23 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/indexed_db/indexed_db_pending_connection.h"
+
+namespace content {
+
+IndexedDBPendingConnection::IndexedDBPendingConnection(
+ scoped_refptr<IndexedDBCallbacks> callbacks_in,
+ scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks_in,
+ int child_process_id_in,
+ int64 transaction_id_in,
+ int64 version_in)
+ : callbacks(callbacks_in),
+ database_callbacks(database_callbacks_in),
+ child_process_id(child_process_id_in),
+ transaction_id(transaction_id_in),
+ version(version_in) {}
+
+IndexedDBPendingConnection::~IndexedDBPendingConnection() {}
+
+} // namespace content
diff --git a/content/browser/indexed_db/indexed_db_pending_connection.h b/content/browser/indexed_db/indexed_db_pending_connection.h
new file mode 100644
index 0000000..c16691e
--- /dev/null
+++ b/content/browser/indexed_db/indexed_db_pending_connection.h
@@ -0,0 +1,36 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_INDEXED_DB_PENDING_CONNECTION_H_
+#define CONTENT_BROWSER_INDEXED_DB_PENDING_CONNECTION_H_
+
+#include "base/basictypes.h"
+#include "base/memory/ref_counted.h"
+#include "content/browser/indexed_db/indexed_db_callbacks.h"
+#include "content/browser/indexed_db/indexed_db_database_callbacks.h"
+#include "content/common/content_export.h"
+
+namespace content {
+
+class IndexedDBCallbacks;
+class IndexedDBDatabaseCallbacks;
+
+struct CONTENT_EXPORT IndexedDBPendingConnection {
+ IndexedDBPendingConnection(
+ scoped_refptr<IndexedDBCallbacks> callbacks_in,
+ scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks_in,
+ int child_process_id_in,
+ int64 transaction_id_in,
+ int64 version_in);
+ ~IndexedDBPendingConnection();
+ scoped_refptr<IndexedDBCallbacks> callbacks;
+ scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks;
+ int child_process_id;
+ int64 transaction_id;
+ int64 version;
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_INDEXED_DB_PENDING_CONNECTION_H_
diff --git a/content/browser/indexed_db/indexed_db_unittest.cc b/content/browser/indexed_db/indexed_db_unittest.cc
index c3704b8..5bf1efb 100644
--- a/content/browser/indexed_db/indexed_db_unittest.cc
+++ b/content/browser/indexed_db/indexed_db_unittest.cc
@@ -174,18 +174,22 @@ TEST_F(IndexedDBTest, ForceCloseOpenDatabasesOnDelete) {
test_path = idb_context->GetFilePathForTesting(
webkit_database::GetIdentifierFromOrigin(kTestOrigin));
+ IndexedDBPendingConnection open_connection(open_callbacks,
+ open_db_callbacks,
+ 0 /* child_process_id */,
+ 0 /* host_transaction_id */,
+ 0 /* version */);
factory->Open(base::ASCIIToUTF16("opendb"),
- 0,
- 0,
- open_callbacks,
- open_db_callbacks,
+ open_connection,
kTestOrigin,
idb_context->data_path());
+ IndexedDBPendingConnection closed_connection(closed_callbacks,
+ closed_db_callbacks,
+ 0 /* child_process_id */,
+ 0 /* host_transaction_id */,
+ 0 /* version */);
factory->Open(base::ASCIIToUTF16("closeddb"),
- 0,
- 0,
- closed_callbacks,
- closed_db_callbacks,
+ closed_connection,
kTestOrigin,
idb_context->data_path());
@@ -247,13 +251,14 @@ TEST_F(IndexedDBTest, ForceCloseOpenDatabasesOnCommitFailure) {
scoped_refptr<MockIndexedDBDatabaseCallbacks> db_callbacks(
new MockIndexedDBDatabaseCallbacks());
const int64 transaction_id = 1;
- factory->Open(base::ASCIIToUTF16("db"),
- IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION,
- transaction_id,
- callbacks,
- db_callbacks,
- kTestOrigin,
- temp_dir.path());
+ IndexedDBPendingConnection connection(
+ callbacks,
+ db_callbacks,
+ 0 /* child_process_id */,
+ transaction_id,
+ IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION);
+ factory->Open(
+ base::ASCIIToUTF16("db"), connection, kTestOrigin, temp_dir.path());
EXPECT_TRUE(callbacks->connection());
diff --git a/content/browser/indexed_db/leveldb/leveldb_transaction.cc b/content/browser/indexed_db/leveldb/leveldb_transaction.cc
index fa1c829..88839a5 100644
--- a/content/browser/indexed_db/leveldb/leveldb_transaction.cc
+++ b/content/browser/indexed_db/leveldb/leveldb_transaction.cc
@@ -434,14 +434,14 @@ LevelDBDirectTransaction::~LevelDBDirectTransaction() {
}
void LevelDBDirectTransaction::Put(const StringPiece& key,
- const std::string* value) {
+ const std::string* value) {
DCHECK(!finished_);
write_batch_->Put(key, *value);
}
leveldb::Status LevelDBDirectTransaction::Get(const StringPiece& key,
- std::string* value,
- bool* found) {
+ std::string* value,
+ bool* found) {
*found = false;
DCHECK(!finished_);