summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authoralecflett@chromium.org <alecflett@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-09 04:39:56 +0000
committeralecflett@chromium.org <alecflett@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-09 04:39:56 +0000
commit33b12f1babeba2db715f3c9f80111dc3fe355c40 (patch)
treec3365b56466c2a37de75ce204f7d58a05e67b37e /content
parentf838bbf77b3e5d6544819fd7f98a07d052ebd26f (diff)
downloadchromium_src-33b12f1babeba2db715f3c9f80111dc3fe355c40.zip
chromium_src-33b12f1babeba2db715f3c9f80111dc3fe355c40.tar.gz
chromium_src-33b12f1babeba2db715f3c9f80111dc3fe355c40.tar.bz2
IPC implementation for create/delete ObjectStore/Index
R=jsbell,dgrogan,Tom Sepez BUG=161958 Review URL: https://chromiumcodereview.appspot.com/11791009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175703 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/in_process_webkit/indexed_db_dispatcher_host.cc88
-rw-r--r--content/browser/in_process_webkit/indexed_db_dispatcher_host.h24
-rw-r--r--content/common/indexed_db/indexed_db_messages.h70
-rw-r--r--content/common/indexed_db/proxy_webidbdatabase_impl.cc69
-rw-r--r--content/common/indexed_db/proxy_webidbdatabase_impl.h20
5 files changed, 251 insertions, 20 deletions
diff --git a/content/browser/in_process_webkit/indexed_db_dispatcher_host.cc b/content/browser/in_process_webkit/indexed_db_dispatcher_host.cc
index 338ca80..a4ec82d 100644
--- a/content/browser/in_process_webkit/indexed_db_dispatcher_host.cc
+++ b/content/browser/in_process_webkit/indexed_db_dispatcher_host.cc
@@ -353,10 +353,14 @@ bool IndexedDBDispatcherHost::DatabaseDispatcherHost::OnMessageReceived(
IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::DatabaseDispatcherHost,
message, *msg_is_ok)
IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseMetadata, OnMetadata)
+ IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateObjectStoreOld,
+ OnCreateObjectStoreOld)
IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateObjectStore,
OnCreateObjectStore)
IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteObjectStore,
OnDeleteObjectStore)
+ IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteObjectStoreOld,
+ OnDeleteObjectStoreOld)
IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateTransaction,
OnCreateTransaction)
IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClose, OnClose)
@@ -371,6 +375,10 @@ bool IndexedDBDispatcherHost::DatabaseDispatcherHost::OnMessageReceived(
IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCount, OnCount)
IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteRange, OnDeleteRange)
IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseClear, OnClear)
+ IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseCreateIndex,
+ OnCreateIndex)
+ IPC_MESSAGE_HANDLER(IndexedDBHostMsg_DatabaseDeleteIndex,
+ OnDeleteIndex)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
@@ -420,8 +428,8 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnMetadata(
}
}
-void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateObjectStore(
- const IndexedDBHostMsg_DatabaseCreateObjectStore_Params& params,
+void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateObjectStoreOld(
+ const IndexedDBHostMsg_DatabaseCreateObjectStoreOld_Params& params,
int32* object_store_id, WebKit::WebExceptionCode* ec) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
WebIDBDatabase* idb_database = parent_->GetOrTerminateProcess(
@@ -442,9 +450,27 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateObjectStore(
}
}
-void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteObjectStore(
+void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateObjectStore(
+ const IndexedDBHostMsg_DatabaseCreateObjectStore_Params& params) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
+ WebIDBDatabase* database = parent_->GetOrTerminateProcess(
+ &map_, params.ipc_database_id);
+ if (!database)
+ return;
+
+ database->createObjectStore(
+ parent_->HostTransactionId(params.transaction_id),
+ params.object_store_id,
+ params.name, params.key_path, params.auto_increment);
+ if (parent_->Context()->IsOverQuota(
+ database_url_map_[params.ipc_database_id])) {
+ database->abort(params.transaction_id);
+ }
+}
+
+void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteObjectStoreOld(
int32 ipc_database_id,
- int64 index_id,
+ int64 object_store_id,
int32 ipc_transaction_id,
WebKit::WebExceptionCode* ec) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
@@ -456,7 +482,21 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteObjectStore(
return;
*ec = 0;
- idb_database->deleteObjectStore(index_id, *idb_transaction, *ec);
+ idb_database->deleteObjectStore(object_store_id, *idb_transaction, *ec);
+}
+
+void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteObjectStore(
+ int32 ipc_database_id,
+ int64 transaction_id,
+ int64 object_store_id) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
+ WebIDBDatabase* database = parent_->GetOrTerminateProcess(
+ &map_, ipc_database_id);
+ if (!database)
+ return;
+
+ database->deleteObjectStore(parent_->HostTransactionId(transaction_id),
+ object_store_id);
}
void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateTransaction(
@@ -650,6 +690,44 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnClear(
object_store_id, callbacks.release());
}
+void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnCreateIndex(
+ const IndexedDBHostMsg_DatabaseCreateIndex_Params& params) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
+ WebIDBDatabase* database = parent_->GetOrTerminateProcess(
+ &map_, params.ipc_database_id);
+ if (!database)
+ return;
+
+ database->createIndex(
+ parent_->HostTransactionId(params.transaction_id),
+ params.object_store_id,
+ params.index_id,
+ params.name,
+ params.key_path,
+ params.unique,
+ params.multi_entry);
+ if (parent_->Context()->IsOverQuota(
+ database_url_map_[params.ipc_database_id])) {
+ database->abort(params.transaction_id);
+ }
+}
+
+void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDeleteIndex(
+ int32 ipc_database_id,
+ int64 transaction_id,
+ int64 object_store_id,
+ int64 index_id) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED));
+ WebIDBDatabase* database = parent_->GetOrTerminateProcess(
+ &map_, ipc_database_id);
+ if (!database)
+ return;
+
+ database->deleteIndex(parent_->HostTransactionId(transaction_id),
+ object_store_id, index_id);
+}
+
+
//////////////////////////////////////////////////////////////////////
// IndexedDBDispatcherHost::IndexDispatcherHost
//
diff --git a/content/browser/in_process_webkit/indexed_db_dispatcher_host.h b/content/browser/in_process_webkit/indexed_db_dispatcher_host.h
index 41e03d8..daf7e14 100644
--- a/content/browser/in_process_webkit/indexed_db_dispatcher_host.h
+++ b/content/browser/in_process_webkit/indexed_db_dispatcher_host.h
@@ -16,6 +16,8 @@
class GURL;
struct IndexedDBDatabaseMetadata;
struct IndexedDBHostMsg_DatabaseCount_Params;
+struct IndexedDBHostMsg_DatabaseCreateIndex_Params;
+struct IndexedDBHostMsg_DatabaseCreateObjectStoreOld_Params;
struct IndexedDBHostMsg_DatabaseCreateObjectStore_Params;
struct IndexedDBHostMsg_DatabaseDeleteRange_Params;
struct IndexedDBHostMsg_DatabaseGet_Params;
@@ -124,13 +126,18 @@ class IndexedDBDispatcherHost : public BrowserMessageFilter {
void OnMetadata(int32 ipc_database_id,
IndexedDBDatabaseMetadata* metadata);
- void OnCreateObjectStore(
- const IndexedDBHostMsg_DatabaseCreateObjectStore_Params& params,
+ void OnCreateObjectStoreOld(
+ const IndexedDBHostMsg_DatabaseCreateObjectStoreOld_Params& params,
int32* object_store_id, WebKit::WebExceptionCode* ec);
+ void OnCreateObjectStore(
+ const IndexedDBHostMsg_DatabaseCreateObjectStore_Params& params);
+ void OnDeleteObjectStoreOld(int32 ipc_database_id,
+ int64 object_store_id,
+ int32 ipc_transaction_id,
+ WebKit::WebExceptionCode* ec);
void OnDeleteObjectStore(int32 ipc_database_id,
- int64 object_store_id,
- int32 ipc_transaction_id,
- WebKit::WebExceptionCode* ec);
+ int64 transaction_id,
+ int64 object_store_id);
void OnCreateTransaction(int32 ipc_thread_id,
int32 ipc_database_id,
int64 transaction_id,
@@ -161,6 +168,13 @@ class IndexedDBDispatcherHost : public BrowserMessageFilter {
int32 ipc_database_id,
int64 transaction_id,
int64 object_store_id);
+ void OnCreateIndex(
+ const IndexedDBHostMsg_DatabaseCreateIndex_Params& params);
+ void OnDeleteIndex(int32 ipc_database_id,
+ int64 transaction_id,
+ int64 object_store_id,
+ int64 index_id);
+
IndexedDBDispatcherHost* parent_;
IDMap<WebKit::WebIDBDatabase, IDMapOwnPointer> map_;
WebIDBObjectIDToURLMap database_url_map_;
diff --git a/content/common/indexed_db/indexed_db_messages.h b/content/common/indexed_db/indexed_db_messages.h
index 20c6fd8..634b3fe 100644
--- a/content/common/indexed_db/indexed_db_messages.h
+++ b/content/common/indexed_db/indexed_db_messages.h
@@ -69,7 +69,7 @@ IPC_STRUCT_BEGIN(IndexedDBHostMsg_FactoryDeleteDatabase_Params)
IPC_STRUCT_END()
// Used to create an object store.
-IPC_STRUCT_BEGIN(IndexedDBHostMsg_DatabaseCreateObjectStore_Params)
+IPC_STRUCT_BEGIN(IndexedDBHostMsg_DatabaseCreateObjectStoreOld_Params)
// The storage id of the object store.
IPC_STRUCT_MEMBER(int64, id)
// The name of the object store.
@@ -84,6 +84,22 @@ IPC_STRUCT_BEGIN(IndexedDBHostMsg_DatabaseCreateObjectStore_Params)
IPC_STRUCT_MEMBER(int32, ipc_database_id)
IPC_STRUCT_END()
+// Used to create an object store.
+IPC_STRUCT_BEGIN(IndexedDBHostMsg_DatabaseCreateObjectStore_Params)
+ // The database the object store belongs to.
+ IPC_STRUCT_MEMBER(int32, ipc_database_id)
+ // The transaction its associated with.
+ IPC_STRUCT_MEMBER(int64, transaction_id)
+ // The storage id of the object store.
+ IPC_STRUCT_MEMBER(int64, object_store_id)
+ // The name of the object store.
+ IPC_STRUCT_MEMBER(string16, name)
+ // The keyPath of the object store.
+ IPC_STRUCT_MEMBER(content::IndexedDBKeyPath, key_path)
+ // Whether the object store created should have a key generator.
+ IPC_STRUCT_MEMBER(bool, auto_increment)
+IPC_STRUCT_END()
+
IPC_STRUCT_BEGIN(IndexedDBHostMsg_DatabaseGet_Params)
IPC_STRUCT_MEMBER(int32, ipc_thread_id)
// The id any response should contain.
@@ -251,6 +267,26 @@ IPC_STRUCT_BEGIN(IndexedDBHostMsg_DatabaseSetIndexKeys_Params)
IPC_STRUCT_END()
// Used to create an index.
+IPC_STRUCT_BEGIN(IndexedDBHostMsg_DatabaseCreateIndex_Params)
+ // The transaction this is associated with.
+ IPC_STRUCT_MEMBER(int64, transaction_id)
+ // The database being used.
+ IPC_STRUCT_MEMBER(int32, ipc_database_id)
+ // The object store the index belongs to.
+ IPC_STRUCT_MEMBER(int64, object_store_id)
+ // The storage id of the index.
+ IPC_STRUCT_MEMBER(int64, index_id)
+ // The name of the index.
+ IPC_STRUCT_MEMBER(string16, name)
+ // The keyPath of the index.
+ IPC_STRUCT_MEMBER(content::IndexedDBKeyPath, key_path)
+ // Whether the index created has unique keys.
+ IPC_STRUCT_MEMBER(bool, unique)
+ // Whether the index created produces keys for each array entry.
+ IPC_STRUCT_MEMBER(bool, multi_entry)
+IPC_STRUCT_END()
+
+// Used to create an index.
IPC_STRUCT_BEGIN(IndexedDBHostMsg_ObjectStoreCreateIndex_Params)
// The storage id of the index.
IPC_STRUCT_MEMBER(int64, id)
@@ -501,18 +537,29 @@ IPC_SYNC_MESSAGE_CONTROL1_1(IndexedDBHostMsg_DatabaseMetadata,
IndexedDBDatabaseMetadata /* metadata */)
// WebIDBDatabase::createObjectStore() message.
-IPC_SYNC_MESSAGE_CONTROL1_2(IndexedDBHostMsg_DatabaseCreateObjectStore,
- IndexedDBHostMsg_DatabaseCreateObjectStore_Params,
- int32, /* ipc_object_store_id */
- WebKit::WebExceptionCode /* ec */)
+IPC_SYNC_MESSAGE_CONTROL1_2(
+ IndexedDBHostMsg_DatabaseCreateObjectStoreOld,
+ IndexedDBHostMsg_DatabaseCreateObjectStoreOld_Params,
+ int32, /* ipc_object_store_id */
+ WebKit::WebExceptionCode /* ec */)
+
+// WebIDBDatabase::createObjectStore() message.
+IPC_MESSAGE_CONTROL1(IndexedDBHostMsg_DatabaseCreateObjectStore,
+ IndexedDBHostMsg_DatabaseCreateObjectStore_Params)
// WebIDBDatabase::deleteObjectStore() message.
-IPC_SYNC_MESSAGE_CONTROL3_1(IndexedDBHostMsg_DatabaseDeleteObjectStore,
+IPC_SYNC_MESSAGE_CONTROL3_1(IndexedDBHostMsg_DatabaseDeleteObjectStoreOld,
int32, /* ipc_database_id */
int64, /* object_store_id */
int32, /* ipc_transaction_id */
WebKit::WebExceptionCode /* ec */)
+// WebIDBDatabase::deleteObjectStore() message.
+IPC_MESSAGE_CONTROL3(IndexedDBHostMsg_DatabaseDeleteObjectStore,
+ int32, /* ipc_database_id */
+ int64, /* transaction_id */
+ int64) /* object_store_id */
+
// WebIDBDatabase::createTransaction() message.
// TODO: make this message async.
IPC_SYNC_MESSAGE_CONTROL5_1(IndexedDBHostMsg_DatabaseCreateTransaction,
@@ -570,6 +617,17 @@ IPC_MESSAGE_CONTROL5(IndexedDBHostMsg_DatabaseClear,
int64, /* transaction_id */
int64) /* object_store_id */
+// WebIDBDatabase::createIndex() message.
+IPC_MESSAGE_CONTROL1(IndexedDBHostMsg_DatabaseCreateIndex,
+ IndexedDBHostMsg_DatabaseCreateIndex_Params)
+
+// WebIDBDatabase::deleteIndex() message.
+IPC_MESSAGE_CONTROL4(IndexedDBHostMsg_DatabaseDeleteIndex,
+ int32, /* ipc_database_id */
+ int64, /* transaction_id */
+ int64, /* object_store_id */
+ int64) /* index_id */
+
// WebIDBIndex::openObjectCursor() message.
IPC_MESSAGE_CONTROL1(IndexedDBHostMsg_IndexOpenObjectCursor,
IndexedDBHostMsg_IndexOpenCursor_Params)
diff --git a/content/common/indexed_db/proxy_webidbdatabase_impl.cc b/content/common/indexed_db/proxy_webidbdatabase_impl.cc
index 2bf3999..46d6dc5 100644
--- a/content/common/indexed_db/proxy_webidbdatabase_impl.cc
+++ b/content/common/indexed_db/proxy_webidbdatabase_impl.cc
@@ -99,7 +99,7 @@ WebKit::WebIDBObjectStore* RendererWebIDBDatabaseImpl::createObjectStore(
bool auto_increment,
const WebKit::WebIDBTransaction& transaction,
WebExceptionCode& ec) {
- IndexedDBHostMsg_DatabaseCreateObjectStore_Params params;
+ IndexedDBHostMsg_DatabaseCreateObjectStoreOld_Params params;
params.id = id;
params.name = name;
params.key_path = IndexedDBKeyPath(key_path);
@@ -109,23 +109,51 @@ WebKit::WebIDBObjectStore* RendererWebIDBDatabaseImpl::createObjectStore(
int object_store;
IndexedDBDispatcher::Send(
- new IndexedDBHostMsg_DatabaseCreateObjectStore(
+ new IndexedDBHostMsg_DatabaseCreateObjectStoreOld(
params, &object_store, &ec));
if (!object_store)
return NULL;
return new RendererWebIDBObjectStoreImpl(object_store);
}
+void RendererWebIDBDatabaseImpl::createObjectStore(
+ long long transaction_id,
+ long long object_store_id,
+ const WebKit::WebString& name,
+ const WebKit::WebIDBKeyPath& key_path,
+ bool auto_increment) {
+ IndexedDBHostMsg_DatabaseCreateObjectStore_Params params;
+ params.ipc_database_id = ipc_database_id_;
+ params.transaction_id = transaction_id;
+ params.object_store_id = object_store_id;
+ params.name = name;
+ params.key_path = IndexedDBKeyPath(key_path);
+ params.auto_increment = auto_increment;
+
+ IndexedDBDispatcher::Send(
+ new IndexedDBHostMsg_DatabaseCreateObjectStore(params));
+}
+
void RendererWebIDBDatabaseImpl::deleteObjectStore(
long long object_store_id,
const WebIDBTransaction& transaction,
WebExceptionCode& ec) {
IndexedDBDispatcher::Send(
- new IndexedDBHostMsg_DatabaseDeleteObjectStore(
+ new IndexedDBHostMsg_DatabaseDeleteObjectStoreOld(
ipc_database_id_, object_store_id,
IndexedDBDispatcher::TransactionId(transaction), &ec));
}
+void RendererWebIDBDatabaseImpl::deleteObjectStore(
+ long long transaction_id,
+ long long object_store_id) {
+ IndexedDBDispatcher::Send(
+ new IndexedDBHostMsg_DatabaseDeleteObjectStore(
+ ipc_database_id_,
+ transaction_id,
+ object_store_id));
+}
+
WebKit::WebIDBTransaction* RendererWebIDBDatabaseImpl::createTransaction(
long long transaction_id,
const WebVector<long long>& object_store_ids,
@@ -273,4 +301,39 @@ void RendererWebIDBDatabaseImpl::clear(
ipc_database_id_,
transaction_id, object_store_id, callbacks);
}
+
+void RendererWebIDBDatabaseImpl::createIndex(
+ long long transaction_id,
+ long long object_store_id,
+ long long index_id,
+ const WebString& name,
+ const WebIDBKeyPath& key_path,
+ bool unique,
+ bool multi_entry)
+{
+ IndexedDBHostMsg_DatabaseCreateIndex_Params params;
+ params.ipc_database_id = ipc_database_id_;
+ params.transaction_id = transaction_id;
+ params.object_store_id = object_store_id;
+ params.index_id = index_id;
+ params.name = name;
+ params.key_path = IndexedDBKeyPath(key_path);
+ params.unique = unique;
+ params.multi_entry = multi_entry;
+
+ IndexedDBDispatcher::Send(
+ new IndexedDBHostMsg_DatabaseCreateIndex(params));
+}
+
+void RendererWebIDBDatabaseImpl::deleteIndex(
+ long long transaction_id,
+ long long object_store_id,
+ long long index_id)
+{
+ IndexedDBDispatcher::Send(
+ new IndexedDBHostMsg_DatabaseDeleteIndex(
+ ipc_database_id_,
+ transaction_id,
+ object_store_id, index_id));
+}
} // namespace content
diff --git a/content/common/indexed_db/proxy_webidbdatabase_impl.h b/content/common/indexed_db/proxy_webidbdatabase_impl.h
index 3e04297..dcf14eb 100644
--- a/content/common/indexed_db/proxy_webidbdatabase_impl.h
+++ b/content/common/indexed_db/proxy_webidbdatabase_impl.h
@@ -31,10 +31,19 @@ class RendererWebIDBDatabaseImpl : public WebKit::WebIDBDatabase {
bool auto_increment,
const WebKit::WebIDBTransaction& transaction,
WebKit::WebExceptionCode& ec);
+ virtual void createObjectStore(
+ long long transaction_id,
+ long long objectstore_id,
+ const WebKit::WebString& name,
+ const WebKit::WebIDBKeyPath& key_path,
+ bool auto_increment);
virtual void deleteObjectStore(
long long object_store_id,
const WebKit::WebIDBTransaction& transaction,
WebKit::WebExceptionCode& ec);
+ virtual void deleteObjectStore(
+ long long transaction_id,
+ long long object_store_id);
virtual WebKit::WebIDBTransaction* createTransaction(
long long transaction_id,
const WebKit::WebVector<long long>& scope,
@@ -82,7 +91,16 @@ class RendererWebIDBDatabaseImpl : public WebKit::WebIDBDatabase {
virtual void clear(long long transactionId,
long long objectStoreId,
WebKit::WebIDBCallbacks*);
-
+ virtual void createIndex(long long transactionId,
+ long long objectStoreId,
+ long long indexId,
+ const WebKit::WebString& name,
+ const WebKit::WebIDBKeyPath&,
+ bool unique,
+ bool multiEntry);
+ virtual void deleteIndex(long long transactionId, long
+ long objectStoreId,
+ long long indexId);
private:
int32 ipc_database_id_;
};