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

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

Issue 18023022: Blob support for IDB [Chromium] (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge fixes [builds, untested] Created 7 years, 3 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_database.cc
diff --git a/content/browser/indexed_db/indexed_db_database.cc b/content/browser/indexed_db/indexed_db_database.cc
index 689b2f1e17169c200ab2e0b1f196db48498ccca7..3305e7842f2cef116f01d82879e2c2f097e6727e 100644
--- a/content/browser/indexed_db/indexed_db_database.cc
+++ b/content/browser/indexed_db/indexed_db_database.cc
@@ -6,6 +6,7 @@
#include <math.h>
#include <set>
+#include <vector>
#include "base/auto_reset.h"
#include "base/logging.h"
@@ -13,12 +14,14 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "content/browser/indexed_db/indexed_db_backing_store.h"
+#include "content/browser/indexed_db/indexed_db_blob_info.h"
#include "content/browser/indexed_db/indexed_db_connection.h"
#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_tracing.h"
#include "content/browser/indexed_db/indexed_db_transaction.h"
+#include "content/browser/indexed_db/indexed_db_value.h"
#include "content/common/indexed_db/indexed_db_key_path.h"
#include "content/common/indexed_db/indexed_db_key_range.h"
#include "content/public/browser/browser_thread.h"
@@ -35,22 +38,26 @@ class IndexedDBDatabase::PendingOpenCall {
public:
PendingOpenCall(scoped_refptr<IndexedDBCallbacks> callbacks,
scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks,
+ int child_process_id,
int64 transaction_id,
int64 version)
: callbacks_(callbacks),
database_callbacks_(database_callbacks),
+ child_process_id_(child_process_id),
version_(version),
transaction_id_(transaction_id) {}
scoped_refptr<IndexedDBCallbacks> Callbacks() { return callbacks_; }
scoped_refptr<IndexedDBDatabaseCallbacks> DatabaseCallbacks() {
return database_callbacks_;
}
+ int ChildProcessId() { return child_process_id_; }
int64 Version() { return version_; }
int64 TransactionId() const { return transaction_id_; }
private:
scoped_refptr<IndexedDBCallbacks> callbacks_;
scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks_;
+ int child_process_id_;
int64 version_;
const int64 transaction_id_;
};
@@ -586,7 +593,7 @@ void IndexedDBDatabase::GetOperation(
bool ok;
if (index_id == IndexedDBIndexMetadata::kInvalidId) {
// Object Store Retrieval Operation
- std::string value;
+ IndexedDBValue value;
ok = backing_store_->GetRecord(transaction->BackingStoreTransaction(),
id(),
object_store_id,
@@ -639,7 +646,7 @@ void IndexedDBDatabase::GetOperation(
}
// Index Referenced Value Retrieval Operation
- std::string value;
+ IndexedDBValue value;
ok = backing_store_->GetRecord(transaction->BackingStoreTransaction(),
id(),
object_store_id,
@@ -706,7 +713,7 @@ static bool UpdateKeyGenerator(
struct IndexedDBDatabase::PutOperationParams {
PutOperationParams() {}
int64 object_store_id;
- std::string value;
+ IndexedDBValue value;
scoped_ptr<IndexedDBKey> key;
IndexedDBDatabase::PutMode put_mode;
scoped_refptr<IndexedDBCallbacks> callbacks;
@@ -718,7 +725,7 @@ struct IndexedDBDatabase::PutOperationParams {
void IndexedDBDatabase::Put(int64 transaction_id,
int64 object_store_id,
- std::string* value,
+ IndexedDBValue* value,
scoped_ptr<IndexedDBKey> key,
PutMode put_mode,
scoped_refptr<IndexedDBCallbacks> callbacks,
@@ -734,6 +741,7 @@ void IndexedDBDatabase::Put(int64 transaction_id,
return;
DCHECK(key);
+ DCHECK(value); // TODO(ericu): True?
scoped_ptr<PutOperationParams> params(new PutOperationParams());
params->object_store_id = object_store_id;
params->value.swap(*value);
@@ -1068,7 +1076,7 @@ void IndexedDBDatabase::OpenCursorOperation(
}
if (!backing_store_cursor) {
- params->callbacks->OnSuccess(static_cast<std::string*>(NULL));
+ params->callbacks->OnSuccess(static_cast<IndexedDBValue*>(NULL));
return;
}
@@ -1167,28 +1175,13 @@ void IndexedDBDatabase::DeleteRangeOperation(
scoped_refptr<IndexedDBCallbacks> callbacks,
IndexedDBTransaction* transaction) {
IDB_TRACE("IndexedDBDatabase::DeleteRangeOperation");
- scoped_ptr<IndexedDBBackingStore::Cursor> backing_store_cursor =
- backing_store_->OpenObjectStoreCursor(
- transaction->BackingStoreTransaction(),
- id(),
- object_store_id,
- *key_range,
- indexed_db::CURSOR_NEXT);
- if (backing_store_cursor) {
- do {
- if (!backing_store_->DeleteRecord(
- transaction->BackingStoreTransaction(),
- id(),
- object_store_id,
- backing_store_cursor->record_identifier())) {
- callbacks->OnError(
- IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError,
- "Internal error deleting data in range"));
- return;
- }
- } while (backing_store_cursor->Continue());
+ if (!backing_store_->DeleteRange(transaction->BackingStoreTransaction(),
+ id(), object_store_id, *key_range)) {
+ callbacks->OnError(
+ IndexedDBDatabaseError(WebKit::WebIDBDatabaseExceptionUnknownError,
+ "Internal error deleting data in range"));
+ return;
}
-
callbacks->OnSuccess();
}
@@ -1386,6 +1379,7 @@ void IndexedDBDatabase::ProcessPendingCalls() {
pending_open_calls.pop_front();
OpenConnection(pending_open_call->Callbacks(),
pending_open_call->DatabaseCallbacks(),
+ pending_open_call->ChildProcessId(),
pending_open_call->TransactionId(),
pending_open_call->Version());
}
@@ -1419,17 +1413,20 @@ bool IndexedDBDatabase::IsOpenConnectionBlocked() const {
void IndexedDBDatabase::OpenConnection(
scoped_refptr<IndexedDBCallbacks> callbacks,
scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks,
+ int child_process_id,
int64 transaction_id,
int64 version) {
const WebKit::WebIDBCallbacks::DataLoss kDataLoss =
WebKit::WebIDBCallbacks::DataLossNone;
OpenConnection(
- callbacks, database_callbacks, transaction_id, version, kDataLoss);
+ callbacks, database_callbacks, child_process_id, transaction_id, version,
+ kDataLoss);
}
void IndexedDBDatabase::OpenConnection(
scoped_refptr<IndexedDBCallbacks> callbacks,
scoped_refptr<IndexedDBDatabaseCallbacks> database_callbacks,
+ int child_process_id,
int64 transaction_id,
int64 version,
WebKit::WebIDBCallbacks::DataLoss data_loss) {
@@ -1442,8 +1439,9 @@ void IndexedDBDatabase::OpenConnection(
// presence of existing connections means we didn't even check for data loss
// so there'd better not be any.
DCHECK_NE(WebKit::WebIDBCallbacks::DataLossTotal, data_loss);
- pending_open_calls_.push_back(new PendingOpenCall(
- callbacks, database_callbacks, transaction_id, version));
+ pending_open_calls_.push_back(
+ new PendingOpenCall(callbacks, database_callbacks, child_process_id,
+ transaction_id, version));
return;
}
@@ -1483,6 +1481,7 @@ void IndexedDBDatabase::OpenConnection(
// TODO(jsbell): DCHECK that not in unit tests.
DCHECK(is_new_database);
connections_.insert(connection.get());
+ backing_store_->GrantChildProcessPermissions(child_process_id);
callbacks->OnSuccess(connection.Pass(), this->metadata());
return;
}
@@ -1490,6 +1489,7 @@ void IndexedDBDatabase::OpenConnection(
if (version == IndexedDBDatabaseMetadata::NO_INT_VERSION) {
if (!is_new_database) {
connections_.insert(connection.get());
+ backing_store_->GrantChildProcessPermissions(child_process_id);
callbacks->OnSuccess(connection.Pass(), this->metadata());
return;
}
@@ -1500,6 +1500,7 @@ void IndexedDBDatabase::OpenConnection(
if (version > metadata_.int_version) {
connections_.insert(connection.get());
+ backing_store_->GrantChildProcessPermissions(child_process_id);
RunVersionChangeTransaction(
callbacks, connection.Pass(), transaction_id, version, data_loss);
return;
@@ -1514,6 +1515,7 @@ void IndexedDBDatabase::OpenConnection(
}
DCHECK_EQ(version, metadata_.int_version);
connections_.insert(connection.get());
+ backing_store_->GrantChildProcessPermissions(child_process_id);
callbacks->OnSuccess(connection.Pass(), this->metadata());
}

Powered by Google App Engine
This is Rietveld 408576698