summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content/browser/indexed_db/indexed_db_callbacks.cc44
-rw-r--r--content/browser/indexed_db/indexed_db_callbacks.h9
-rw-r--r--content/browser/indexed_db/indexed_db_cursor.cc6
-rw-r--r--content/browser/indexed_db/indexed_db_database.cc15
-rw-r--r--content/browser/indexed_db/indexed_db_return_value.h27
-rw-r--r--content/child/indexed_db/indexed_db_dispatcher.cc29
-rw-r--r--content/child/indexed_db/indexed_db_dispatcher.h3
-rw-r--r--content/common/indexed_db/indexed_db_messages.h20
-rw-r--r--content/content_browser.gypi1
9 files changed, 67 insertions, 87 deletions
diff --git a/content/browser/indexed_db/indexed_db_callbacks.cc b/content/browser/indexed_db/indexed_db_callbacks.cc
index e951c31..aa54973 100644
--- a/content/browser/indexed_db/indexed_db_callbacks.cc
+++ b/content/browser/indexed_db/indexed_db_callbacks.cc
@@ -18,6 +18,7 @@
#include "content/browser/indexed_db/indexed_db_database_callbacks.h"
#include "content/browser/indexed_db/indexed_db_database_error.h"
#include "content/browser/indexed_db/indexed_db_metadata.h"
+#include "content/browser/indexed_db/indexed_db_return_value.h"
#include "content/browser/indexed_db/indexed_db_value.h"
#include "content/common/indexed_db/indexed_db_constants.h"
#include "content/common/indexed_db/indexed_db_messages.h"
@@ -464,45 +465,14 @@ void IndexedDBCallbacks::OnSuccessWithPrefetch(
dispatcher_host_ = NULL;
}
-void IndexedDBCallbacks::OnSuccess(IndexedDBValue* value,
- const IndexedDBKey& key,
- const IndexedDBKeyPath& key_path) {
+void IndexedDBCallbacks::OnSuccess(IndexedDBReturnValue* value) {
DCHECK(dispatcher_host_.get());
- DCHECK_EQ(kNoCursor, ipc_cursor_id_);
- DCHECK_EQ(kNoTransaction, host_transaction_id_);
- DCHECK_EQ(kNoDatabase, ipc_database_id_);
- DCHECK_EQ(kNoDatabaseCallbacks, ipc_database_callbacks_id_);
- DCHECK_EQ(blink::WebIDBDataLossNone, data_loss_);
-
- scoped_ptr<IndexedDBMsg_CallbacksSuccessValueWithKey_Params> params(
- new IndexedDBMsg_CallbacksSuccessValueWithKey_Params());
- params->ipc_thread_id = ipc_thread_id_;
- params->ipc_callbacks_id = ipc_callbacks_id_;
- params->primary_key = key;
- params->key_path = key_path;
- if (value && !value->empty())
- std::swap(params->value.bits, value->bits);
- if (!value || value->blob_info.empty()) {
- dispatcher_host_->Send(
- new IndexedDBMsg_CallbacksSuccessValueWithKey(*params));
+ if (value && value->primary_key.IsValid()) {
+ DCHECK_EQ(kNoCursor, ipc_cursor_id_);
} else {
- IndexedDBMsg_CallbacksSuccessValueWithKey_Params* p = params.get();
- FillInBlobData(value->blob_info, &p->value.blob_or_file_info);
- RegisterBlobsAndSend(
- value->blob_info,
- base::Bind(
- CreateBlobsAndSend<IndexedDBMsg_CallbacksSuccessValueWithKey_Params,
- IndexedDBMsg_CallbacksSuccessValueWithKey>,
- base::Owned(params.release()), dispatcher_host_, value->blob_info,
- base::Unretained(&p->value.blob_or_file_info)));
+ DCHECK(kNoCursor == ipc_cursor_id_ || value == NULL);
}
- dispatcher_host_ = NULL;
-}
-
-void IndexedDBCallbacks::OnSuccess(IndexedDBValue* value) {
- DCHECK(dispatcher_host_.get());
- DCHECK(kNoCursor == ipc_cursor_id_ || value == NULL);
DCHECK_EQ(kNoTransaction, host_transaction_id_);
DCHECK_EQ(kNoDatabase, ipc_database_id_);
DCHECK_EQ(kNoDatabaseCallbacks, ipc_database_callbacks_id_);
@@ -512,6 +482,10 @@ void IndexedDBCallbacks::OnSuccess(IndexedDBValue* value) {
new IndexedDBMsg_CallbacksSuccessValue_Params());
params->ipc_thread_id = ipc_thread_id_;
params->ipc_callbacks_id = ipc_callbacks_id_;
+ if (value && value->primary_key.IsValid()) {
+ params->value.primary_key = value->primary_key;
+ params->value.key_path = value->key_path;
+ }
if (value && !value->empty())
std::swap(params->value.bits, value->bits);
if (!value || value->blob_info.empty()) {
diff --git a/content/browser/indexed_db/indexed_db_callbacks.h b/content/browser/indexed_db/indexed_db_callbacks.h
index 4b8a217..7083bd6 100644
--- a/content/browser/indexed_db/indexed_db_callbacks.h
+++ b/content/browser/indexed_db/indexed_db_callbacks.h
@@ -26,6 +26,7 @@ class IndexedDBCursor;
class IndexedDBDatabase;
class IndexedDBDatabaseCallbacks;
struct IndexedDBDatabaseMetadata;
+struct IndexedDBReturnValue;
struct IndexedDBValue;
class CONTENT_EXPORT IndexedDBCallbacks
@@ -85,13 +86,9 @@ class CONTENT_EXPORT IndexedDBCallbacks
const std::vector<IndexedDBKey>& primary_keys,
std::vector<IndexedDBValue>* values);
- // IndexedDBDatabase::Get (with key injection)
- virtual void OnSuccess(IndexedDBValue* value,
- const IndexedDBKey& key,
- const IndexedDBKeyPath& key_path);
-
// IndexedDBDatabase::Get
- virtual void OnSuccess(IndexedDBValue* value);
+ // IndexedDBCursor::Advance
+ virtual void OnSuccess(IndexedDBReturnValue* value);
// IndexedDBDatabase::Put / IndexedDBCursor::Update
virtual void OnSuccess(const IndexedDBKey& key);
diff --git a/content/browser/indexed_db/indexed_db_cursor.cc b/content/browser/indexed_db/indexed_db_cursor.cc
index 4fc3c0e..63ef949 100644
--- a/content/browser/indexed_db/indexed_db_cursor.cc
+++ b/content/browser/indexed_db/indexed_db_cursor.cc
@@ -68,7 +68,7 @@ void IndexedDBCursor::CursorAdvanceOperation(
// will be ignored.
if (!cursor_ || !cursor_->Advance(count, &s)) {
cursor_.reset();
- callbacks->OnSuccess(static_cast<IndexedDBValue*>(NULL));
+ callbacks->OnSuccess(nullptr);
return;
}
@@ -90,7 +90,7 @@ void IndexedDBCursor::CursorIterationOperation(
IndexedDBBackingStore::Cursor::SEEK,
&s) || !s.ok()) {
cursor_.reset();
- callbacks->OnSuccess(static_cast<IndexedDBValue*>(NULL));
+ callbacks->OnSuccess(nullptr);
return;
}
@@ -165,7 +165,7 @@ void IndexedDBCursor::CursorPrefetchIterationOperation(
}
if (!found_keys.size()) {
- callbacks->OnSuccess(static_cast<IndexedDBValue*>(NULL));
+ callbacks->OnSuccess(nullptr);
return;
}
diff --git a/content/browser/indexed_db/indexed_db_database.cc b/content/browser/indexed_db/indexed_db_database.cc
index 97dc1d7..b72ee73 100644
--- a/content/browser/indexed_db/indexed_db_database.cc
+++ b/content/browser/indexed_db/indexed_db_database.cc
@@ -21,6 +21,7 @@
#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_return_value.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"
@@ -588,7 +589,7 @@ void IndexedDBDatabase::GetOperation(
scoped_ptr<IndexedDBKey> primary_key;
if (index_id == IndexedDBIndexMetadata::kInvalidId) {
// Object Store Retrieval Operation
- IndexedDBValue value;
+ IndexedDBReturnValue value;
s = backing_store_->GetRecord(transaction->BackingStoreTransaction(),
id(),
object_store_id,
@@ -612,8 +613,8 @@ void IndexedDBDatabase::GetOperation(
if (object_store_metadata.auto_increment &&
!object_store_metadata.key_path.IsNull()) {
- callbacks->OnSuccess(&value, *key, object_store_metadata.key_path);
- return;
+ value.primary_key = *key;
+ value.key_path = object_store_metadata.key_path;
}
callbacks->OnSuccess(&value);
@@ -648,7 +649,7 @@ void IndexedDBDatabase::GetOperation(
}
// Index Referenced Value Retrieval Operation
- IndexedDBValue value;
+ IndexedDBReturnValue value;
s = backing_store_->GetRecord(transaction->BackingStoreTransaction(),
id(),
object_store_id,
@@ -670,8 +671,8 @@ void IndexedDBDatabase::GetOperation(
}
if (object_store_metadata.auto_increment &&
!object_store_metadata.key_path.IsNull()) {
- callbacks->OnSuccess(&value, *primary_key, object_store_metadata.key_path);
- return;
+ value.primary_key = *primary_key;
+ value.key_path = object_store_metadata.key_path;
}
callbacks->OnSuccess(&value);
}
@@ -1110,7 +1111,7 @@ void IndexedDBDatabase::OpenCursorOperation(
if (!backing_store_cursor) {
// Why is Success being called?
- params->callbacks->OnSuccess(static_cast<IndexedDBValue*>(NULL));
+ params->callbacks->OnSuccess(nullptr);
return;
}
diff --git a/content/browser/indexed_db/indexed_db_return_value.h b/content/browser/indexed_db/indexed_db_return_value.h
new file mode 100644
index 0000000..6a50a26
--- /dev/null
+++ b/content/browser/indexed_db/indexed_db_return_value.h
@@ -0,0 +1,27 @@
+// Copyright 2015 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_INDEXED_DB_RETURN_VALUE_H_
+#define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_RETURN_VALUE_H_
+
+#include "content/browser/indexed_db/indexed_db_value.h"
+#include "content/common/content_export.h"
+#include "content/common/indexed_db/indexed_db_key.h"
+#include "content/common/indexed_db/indexed_db_key_path.h"
+
+namespace content {
+
+// Values returned to the IDB client may contain a primary key value generated
+// by IDB. This is optional and only done when using a key generator. This key
+// value cannot (at least easily) be amended to the object being written to the
+// database, so they are kept separately, and sent back with the original data
+// so that the render process can amend the returned object.
+struct CONTENT_EXPORT IndexedDBReturnValue : public IndexedDBValue {
+ IndexedDBKey primary_key; // primary key (only when using key generator)
+ IndexedDBKeyPath key_path;
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_RETURN_VALUE_H_
diff --git a/content/child/indexed_db/indexed_db_dispatcher.cc b/content/child/indexed_db/indexed_db_dispatcher.cc
index 7d81450..c0d1fb2 100644
--- a/content/child/indexed_db/indexed_db_dispatcher.cc
+++ b/content/child/indexed_db/indexed_db_dispatcher.cc
@@ -144,8 +144,6 @@ void IndexedDBDispatcher::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessStringList,
OnSuccessStringList)
IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessValue, OnSuccessValue)
- IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessValueWithKey,
- OnSuccessValueWithKey)
IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessInteger, OnSuccessInteger)
IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksSuccessUndefined,
OnSuccessUndefined)
@@ -560,25 +558,14 @@ void IndexedDBDispatcher::OnSuccessValue(
WebData web_value;
WebVector<WebBlobInfo> web_blob_info;
PrepareWebValueAndBlobInfo(params.value, &web_value, &web_blob_info);
- callbacks->onSuccess(web_value, web_blob_info);
- pending_callbacks_.Remove(params.ipc_callbacks_id);
- cursor_transaction_ids_.erase(params.ipc_callbacks_id);
-}
-
-void IndexedDBDispatcher::OnSuccessValueWithKey(
- const IndexedDBMsg_CallbacksSuccessValueWithKey_Params& params) {
- DCHECK_EQ(params.ipc_thread_id, CurrentWorkerId());
- WebIDBCallbacks* callbacks =
- pending_callbacks_.Lookup(params.ipc_callbacks_id);
- if (!callbacks)
- return;
- WebData web_value;
- WebVector<WebBlobInfo> web_blob_info;
- PrepareWebValueAndBlobInfo(params.value, &web_value, &web_blob_info);
- callbacks->onSuccess(web_value,
- web_blob_info,
- WebIDBKeyBuilder::Build(params.primary_key),
- WebIDBKeyPathBuilder::Build(params.key_path));
+ if (params.value.primary_key.IsValid()) {
+ callbacks->onSuccess(web_value, web_blob_info,
+ WebIDBKeyBuilder::Build(params.value.primary_key),
+ WebIDBKeyPathBuilder::Build(params.value.key_path));
+ } else {
+ callbacks->onSuccess(web_value, web_blob_info);
+ cursor_transaction_ids_.erase(params.ipc_callbacks_id);
+ }
pending_callbacks_.Remove(params.ipc_callbacks_id);
}
diff --git a/content/child/indexed_db/indexed_db_dispatcher.h b/content/child/indexed_db/indexed_db_dispatcher.h
index e2df289..92d7972 100644
--- a/content/child/indexed_db/indexed_db_dispatcher.h
+++ b/content/child/indexed_db/indexed_db_dispatcher.h
@@ -26,7 +26,6 @@ struct IndexedDBMsg_CallbacksSuccessCursorContinue_Params;
struct IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params;
struct IndexedDBMsg_CallbacksSuccessIDBCursor_Params;
struct IndexedDBMsg_CallbacksSuccessValue_Params;
-struct IndexedDBMsg_CallbacksSuccessValueWithKey_Params;
struct IndexedDBMsg_CallbacksUpgradeNeeded_Params;
namespace blink {
@@ -210,8 +209,6 @@ class CONTENT_EXPORT IndexedDBDispatcher : public WorkerTaskRunner::Observer {
int32 ipc_callbacks_id,
const std::vector<base::string16>& value);
void OnSuccessValue(const IndexedDBMsg_CallbacksSuccessValue_Params& p);
- void OnSuccessValueWithKey(
- const IndexedDBMsg_CallbacksSuccessValueWithKey_Params& p);
void OnSuccessInteger(int32 ipc_thread_id,
int32 ipc_callbacks_id,
int64 value);
diff --git a/content/common/indexed_db/indexed_db_messages.h b/content/common/indexed_db/indexed_db_messages.h
index 22a89981..57e95cd 100644
--- a/content/common/indexed_db/indexed_db_messages.h
+++ b/content/common/indexed_db/indexed_db_messages.h
@@ -143,6 +143,13 @@ IPC_STRUCT_BEGIN(IndexedDBMsg_Value)
IPC_STRUCT_MEMBER(std::vector<IndexedDBMsg_BlobOrFileInfo>, blob_or_file_info)
IPC_STRUCT_END()
+IPC_STRUCT_BEGIN_WITH_PARENT(IndexedDBMsg_ReturnValue, IndexedDBMsg_Value)
+ IPC_STRUCT_TRAITS_PARENT(IndexedDBMsg_Value)
+ // Optional primary key & path used only when key generator specified.
+ IPC_STRUCT_MEMBER(content::IndexedDBKey, primary_key)
+ IPC_STRUCT_MEMBER(content::IndexedDBKeyPath, key_path)
+IPC_STRUCT_END()
+
// Used to set a value in an object store.
IPC_STRUCT_BEGIN(IndexedDBHostMsg_DatabasePut_Params)
// The id any response should contain.
@@ -283,15 +290,7 @@ IPC_STRUCT_END()
IPC_STRUCT_BEGIN(IndexedDBMsg_CallbacksSuccessValue_Params)
IPC_STRUCT_MEMBER(int32, ipc_thread_id)
IPC_STRUCT_MEMBER(int32, ipc_callbacks_id)
- IPC_STRUCT_MEMBER(IndexedDBMsg_Value, value)
-IPC_STRUCT_END()
-
-IPC_STRUCT_BEGIN(IndexedDBMsg_CallbacksSuccessValueWithKey_Params)
- IPC_STRUCT_MEMBER(int32, ipc_thread_id)
- IPC_STRUCT_MEMBER(int32, ipc_callbacks_id)
- IPC_STRUCT_MEMBER(IndexedDBMsg_Value, value)
- IPC_STRUCT_MEMBER(content::IndexedDBKey, primary_key)
- IPC_STRUCT_MEMBER(content::IndexedDBKeyPath, key_path)
+ IPC_STRUCT_MEMBER(IndexedDBMsg_ReturnValue, value)
IPC_STRUCT_END()
IPC_STRUCT_BEGIN(IndexedDBIndexMetadata)
@@ -364,9 +363,6 @@ IPC_MESSAGE_CONTROL3(IndexedDBMsg_CallbacksSuccessIndexedDBKey,
IPC_MESSAGE_CONTROL1(IndexedDBMsg_CallbacksSuccessValue,
IndexedDBMsg_CallbacksSuccessValue_Params)
-IPC_MESSAGE_CONTROL1(IndexedDBMsg_CallbacksSuccessValueWithKey,
- IndexedDBMsg_CallbacksSuccessValueWithKey_Params)
-
IPC_MESSAGE_CONTROL3(IndexedDBMsg_CallbacksSuccessInteger,
int32 /* ipc_thread_id */,
int32 /* ipc_callbacks_id */,
diff --git a/content/content_browser.gypi b/content/content_browser.gypi
index 3a2c4f6..79a1342 100644
--- a/content/content_browser.gypi
+++ b/content/content_browser.gypi
@@ -872,6 +872,7 @@
'browser/indexed_db/indexed_db_pending_connection.h',
'browser/indexed_db/indexed_db_quota_client.cc',
'browser/indexed_db/indexed_db_quota_client.h',
+ 'browser/indexed_db/indexed_db_response_value.h',
'browser/indexed_db/indexed_db_transaction.cc',
'browser/indexed_db/indexed_db_transaction.h',
'browser/indexed_db/indexed_db_transaction_coordinator.cc',