Commit 61a875bc authored by jsbell@chromium.org's avatar jsbell@chromium.org

IndexedDB: Send cursor data along with success messages

Chromium already behaves like this in the IPC plumbing for IDB,
but the code can be simplified by pushing this into the WebKit
implementation itself.

Full landing sequence is:

(1) WebKit prep: Add new API stubs http://webkit.org/b/92414 
(2) Chromium changes: dispatch to old and new API https://chromiumcodereview.appspot.com/10830028 (this patch)
(3) WebKit changes: use the new API http://webkit.org/b/92278
(4) Chromium cleanup: delete old API usage
(5) WebKit changes: delete old API


Review URL: https://chromiumcodereview.appspot.com/10830028

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150883 0039d316-1c4b-4281-b951-d872f2087c98
parent e3f1f0c0
...@@ -53,6 +53,7 @@ void IndexedDBCallbacks<WebKit::WebIDBDatabase>::onUpgradeNeeded( ...@@ -53,6 +53,7 @@ void IndexedDBCallbacks<WebKit::WebIDBDatabase>::onUpgradeNeeded(
old_version)); old_version));
} }
// TODO(jsbell): Remove this after WK92278 rolls.
void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccess( void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccess(
WebKit::WebIDBCursor* idb_object) { WebKit::WebIDBCursor* idb_object) {
int32 object_id = dispatcher_host()->Add(idb_object); int32 object_id = dispatcher_host()->Add(idb_object);
...@@ -66,6 +67,22 @@ void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccess( ...@@ -66,6 +67,22 @@ void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccess(
dispatcher_host()->Send(new IndexedDBMsg_CallbacksSuccessIDBCursor(params)); dispatcher_host()->Send(new IndexedDBMsg_CallbacksSuccessIDBCursor(params));
} }
void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccess(
WebKit::WebIDBCursor* idb_object,
const WebKit::WebIDBKey& key,
const WebKit::WebIDBKey& primaryKey,
const WebKit::WebSerializedScriptValue& value) {
int32 object_id = dispatcher_host()->Add(idb_object);
IndexedDBMsg_CallbacksSuccessIDBCursor_Params params;
params.thread_id = thread_id();
params.response_id = response_id();
params.cursor_id = object_id;
params.key = IndexedDBKey(key);
params.primary_key = IndexedDBKey(primaryKey);
params.serialized_value = SerializedScriptValue(value);
dispatcher_host()->Send(new IndexedDBMsg_CallbacksSuccessIDBCursor(params));
}
void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccess( void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccess(
const WebKit::WebSerializedScriptValue& value) { const WebKit::WebSerializedScriptValue& value) {
dispatcher_host()->Send( dispatcher_host()->Send(
...@@ -73,6 +90,7 @@ void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccess( ...@@ -73,6 +90,7 @@ void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccess(
thread_id(), response_id(), SerializedScriptValue(value))); thread_id(), response_id(), SerializedScriptValue(value)));
} }
// TODO(jsbell): Remove this after WK92278 rolls.
void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccessWithContinuation() { void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccessWithContinuation() {
DCHECK(cursor_id_ != -1); DCHECK(cursor_id_ != -1);
WebKit::WebIDBCursor* idb_cursor = dispatcher_host()->GetCursorFromId( WebKit::WebIDBCursor* idb_cursor = dispatcher_host()->GetCursorFromId(
...@@ -88,7 +106,28 @@ void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccessWithContinuation() { ...@@ -88,7 +106,28 @@ void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccessWithContinuation() {
params.key = IndexedDBKey(idb_cursor->key()); params.key = IndexedDBKey(idb_cursor->key());
params.primary_key = IndexedDBKey(idb_cursor->primaryKey()); params.primary_key = IndexedDBKey(idb_cursor->primaryKey());
params.serialized_value = SerializedScriptValue(idb_cursor->value()); params.serialized_value = SerializedScriptValue(idb_cursor->value());
dispatcher_host()->Send(
new IndexedDBMsg_CallbacksSuccessCursorContinue(params));
}
void IndexedDBCallbacks<WebKit::WebIDBCursor>::onSuccess(
const WebKit::WebIDBKey& key,
const WebKit::WebIDBKey& primaryKey,
const WebKit::WebSerializedScriptValue& value) {
DCHECK(cursor_id_ != -1);
WebKit::WebIDBCursor* idb_cursor = dispatcher_host()->GetCursorFromId(
cursor_id_);
DCHECK(idb_cursor);
if (!idb_cursor)
return;
IndexedDBMsg_CallbacksSuccessCursorContinue_Params params;
params.thread_id = thread_id();
params.response_id = response_id();
params.cursor_id = cursor_id_;
params.key = IndexedDBKey(key);
params.primary_key = IndexedDBKey(primaryKey);
params.serialized_value = SerializedScriptValue(value);
dispatcher_host()->Send( dispatcher_host()->Send(
new IndexedDBMsg_CallbacksSuccessCursorContinue(params)); new IndexedDBMsg_CallbacksSuccessCursorContinue(params));
} }
......
...@@ -105,11 +105,22 @@ class IndexedDBCallbacks : public IndexedDBCallbacksBase { ...@@ -105,11 +105,22 @@ class IndexedDBCallbacks : public IndexedDBCallbacksBase {
DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks); DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks);
}; };
// TODO(jsbell): Remove this preamble comment after WK92278 rolls.
// Pre WK92278:
// WebIDBCursor uses onSuccess(WebIDBCursor*) when a cursor has been opened, // WebIDBCursor uses onSuccess(WebIDBCursor*) when a cursor has been opened,
// onSuccessWithContinuation() when a continue() call has succeeded, or // onSuccessWithContinuation() when a continue() call has succeeded, or
// onSuccess(SerializedScriptValue::nullValue()) to indicate it does // onSuccess(SerializedScriptValue::nullValue()) to indicate it does
// not contain any data, i.e., there is no key within the key range, // not contain any data, i.e., there is no key within the key range,
// or it has reached the end. // or it has reached the end.
// Post WK92278:
// WebIDBCursor uses:
// * onSuccess(WebIDBCursor*, WebIDBKey, WebIDBKey, SerializedScriptValue)
// when an openCursor()/openKeyCursor() call has succeeded,
// * onSuccess(WebIDBKey, WebIDBKey, SerializedScriptValue)
// when an advance()/continue() call has succeeded, or
// * onSuccess(SerializedScriptValue::nullValue())
// to indicate it does not contain any data, i.e., there is no key within
// the key range, or it has reached the end.
template <> template <>
class IndexedDBCallbacks<WebKit::WebIDBCursor> class IndexedDBCallbacks<WebKit::WebIDBCursor>
: public IndexedDBCallbacksBase { : public IndexedDBCallbacksBase {
...@@ -122,8 +133,17 @@ class IndexedDBCallbacks<WebKit::WebIDBCursor> ...@@ -122,8 +133,17 @@ class IndexedDBCallbacks<WebKit::WebIDBCursor>
: IndexedDBCallbacksBase(dispatcher_host, thread_id, response_id), : IndexedDBCallbacksBase(dispatcher_host, thread_id, response_id),
cursor_id_(cursor_id) { } cursor_id_(cursor_id) { }
// TODO(jsbell): Remove this after WK92278 rolls.
virtual void onSuccess(WebKit::WebIDBCursor* idb_object); virtual void onSuccess(WebKit::WebIDBCursor* idb_object);
virtual void onSuccess(WebKit::WebIDBCursor* idb_object,
const WebKit::WebIDBKey& key,
const WebKit::WebIDBKey& primaryKey,
const WebKit::WebSerializedScriptValue& value);
virtual void onSuccess(const WebKit::WebIDBKey& key,
const WebKit::WebIDBKey& primaryKey,
const WebKit::WebSerializedScriptValue& value);
virtual void onSuccess(const WebKit::WebSerializedScriptValue& value); virtual void onSuccess(const WebKit::WebSerializedScriptValue& value);
// TODO(jsbell): Remove this after WK92278 rolls.
virtual void onSuccessWithContinuation(); virtual void onSuccessWithContinuation();
virtual void onSuccessWithPrefetch( virtual void onSuccessWithPrefetch(
const WebKit::WebVector<WebKit::WebIDBKey>& keys, const WebKit::WebVector<WebKit::WebIDBKey>& keys,
......
...@@ -892,6 +892,7 @@ void IndexedDBDispatcherHost::CursorDispatcherHost::Send( ...@@ -892,6 +892,7 @@ void IndexedDBDispatcherHost::CursorDispatcherHost::Send(
parent_->Send(message); parent_->Send(message);
} }
// TODO(jsbell): Remove this after WK92278 rolls.
void IndexedDBDispatcherHost::CursorDispatcherHost::OnKey( void IndexedDBDispatcherHost::CursorDispatcherHost::OnKey(
int32 object_id, IndexedDBKey* key) { int32 object_id, IndexedDBKey* key) {
WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, object_id); WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, object_id);
...@@ -901,6 +902,7 @@ void IndexedDBDispatcherHost::CursorDispatcherHost::OnKey( ...@@ -901,6 +902,7 @@ void IndexedDBDispatcherHost::CursorDispatcherHost::OnKey(
*key = IndexedDBKey(idb_cursor->key()); *key = IndexedDBKey(idb_cursor->key());
} }
// TODO(jsbell): Remove this after WK92278 rolls.
void IndexedDBDispatcherHost::CursorDispatcherHost::OnPrimaryKey( void IndexedDBDispatcherHost::CursorDispatcherHost::OnPrimaryKey(
int32 object_id, IndexedDBKey* primary_key) { int32 object_id, IndexedDBKey* primary_key) {
WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, object_id); WebIDBCursor* idb_cursor = parent_->GetOrTerminateProcess(&map_, object_id);
...@@ -910,6 +912,7 @@ void IndexedDBDispatcherHost::CursorDispatcherHost::OnPrimaryKey( ...@@ -910,6 +912,7 @@ void IndexedDBDispatcherHost::CursorDispatcherHost::OnPrimaryKey(
*primary_key = IndexedDBKey(idb_cursor->primaryKey()); *primary_key = IndexedDBKey(idb_cursor->primaryKey());
} }
// TODO(jsbell): Remove this after WK92278 rolls.
void IndexedDBDispatcherHost::CursorDispatcherHost::OnValue( void IndexedDBDispatcherHost::CursorDispatcherHost::OnValue(
int32 object_id, int32 object_id,
SerializedScriptValue* script_value) { SerializedScriptValue* script_value) {
......
...@@ -233,6 +233,7 @@ class IndexedDBDispatcherHost : public content::BrowserMessageFilter { ...@@ -233,6 +233,7 @@ class IndexedDBDispatcherHost : public content::BrowserMessageFilter {
bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok); bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok);
void Send(IPC::Message* message); void Send(IPC::Message* message);
// TODO(jsbell): Remove the next three methods after WK92278 rolls.
void OnKey(int32 idb_object_store_id, content::IndexedDBKey* key); void OnKey(int32 idb_object_store_id, content::IndexedDBKey* key);
void OnPrimaryKey(int32 idb_object_store_id, void OnPrimaryKey(int32 idb_object_store_id,
content::IndexedDBKey* primary_key); content::IndexedDBKey* primary_key);
......
...@@ -635,8 +635,10 @@ void IndexedDBDispatcher::OnSuccessOpenCursor( ...@@ -635,8 +635,10 @@ void IndexedDBDispatcher::OnSuccessOpenCursor(
RendererWebIDBCursorImpl* cursor = new RendererWebIDBCursorImpl(object_id); RendererWebIDBCursorImpl* cursor = new RendererWebIDBCursorImpl(object_id);
cursors_[object_id] = cursor; cursors_[object_id] = cursor;
// TODO(jsbell): Remove the next two calls after WK92278 rolls.
cursor->SetKeyAndValue(key, primary_key, value); cursor->SetKeyAndValue(key, primary_key, value);
callbacks->onSuccess(cursor); callbacks->onSuccess(cursor);
callbacks->onSuccess(cursor, key, primary_key, value);
pending_callbacks_.Remove(response_id); pending_callbacks_.Remove(response_id);
} }
...@@ -652,12 +654,16 @@ void IndexedDBDispatcher::OnSuccessCursorContinue( ...@@ -652,12 +654,16 @@ void IndexedDBDispatcher::OnSuccessCursorContinue(
RendererWebIDBCursorImpl* cursor = cursors_[cursor_id]; RendererWebIDBCursorImpl* cursor = cursors_[cursor_id];
DCHECK(cursor); DCHECK(cursor);
// TODO(jsbell): Remove the next call after WK92278·rolls.
cursor->SetKeyAndValue(key, primary_key, value); cursor->SetKeyAndValue(key, primary_key, value);
WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
if (!callbacks) if (!callbacks)
return; return;
// TODO(jsbell): Remove the ...WithContinuation call after WK92278 rolls.
callbacks->onSuccessWithContinuation(); callbacks->onSuccessWithContinuation();
callbacks->onSuccess(key, primary_key, value);
pending_callbacks_.Remove(response_id); pending_callbacks_.Remove(response_id);
} }
......
...@@ -37,14 +37,17 @@ RendererWebIDBCursorImpl::~RendererWebIDBCursorImpl() { ...@@ -37,14 +37,17 @@ RendererWebIDBCursorImpl::~RendererWebIDBCursorImpl() {
dispatcher->CursorDestroyed(idb_cursor_id_); dispatcher->CursorDestroyed(idb_cursor_id_);
} }
// TODO(jsbell): Remove the following method after WK92278 rolls.
WebIDBKey RendererWebIDBCursorImpl::key() const { WebIDBKey RendererWebIDBCursorImpl::key() const {
return key_; return key_;
} }
// TODO(jsbell): Remove the following method after WK92278 rolls.
WebIDBKey RendererWebIDBCursorImpl::primaryKey() const { WebIDBKey RendererWebIDBCursorImpl::primaryKey() const {
return primary_key_; return primary_key_;
} }
// TODO(jsbell): Remove the following method after WK92278 rolls.
WebSerializedScriptValue RendererWebIDBCursorImpl::value() const { WebSerializedScriptValue RendererWebIDBCursorImpl::value() const {
return value_; return value_;
} }
...@@ -120,6 +123,7 @@ void RendererWebIDBCursorImpl::postSuccessHandlerCallback() { ...@@ -120,6 +123,7 @@ void RendererWebIDBCursorImpl::postSuccessHandlerCallback() {
ResetPrefetchCache(); ResetPrefetchCache();
} }
// TODO(jsbell): Remove the following method after WK92278 rolls.
void RendererWebIDBCursorImpl::SetKeyAndValue( void RendererWebIDBCursorImpl::SetKeyAndValue(
const IndexedDBKey& key, const IndexedDBKey& key,
const IndexedDBKey& primary_key, const IndexedDBKey& primary_key,
...@@ -147,6 +151,7 @@ void RendererWebIDBCursorImpl::CachedContinue( ...@@ -147,6 +151,7 @@ void RendererWebIDBCursorImpl::CachedContinue(
DCHECK(prefetch_primary_keys_.size() == prefetch_keys_.size()); DCHECK(prefetch_primary_keys_.size() == prefetch_keys_.size());
DCHECK(prefetch_values_.size() == prefetch_keys_.size()); DCHECK(prefetch_values_.size() == prefetch_keys_.size());
// TODO(jsbell): Turn these three variables into locals after WK92278 rolls.
key_ = prefetch_keys_.front(); key_ = prefetch_keys_.front();
primary_key_ = prefetch_primary_keys_.front(); primary_key_ = prefetch_primary_keys_.front();
value_ = prefetch_values_.front(); value_ = prefetch_values_.front();
...@@ -157,7 +162,10 @@ void RendererWebIDBCursorImpl::CachedContinue( ...@@ -157,7 +162,10 @@ void RendererWebIDBCursorImpl::CachedContinue(
used_prefetches_++; used_prefetches_++;
pending_onsuccess_callbacks_++; pending_onsuccess_callbacks_++;
// TODO(jsbell): Remove the ...WithContinuation call after WK92278 rolls.
callbacks->onSuccessWithContinuation(); callbacks->onSuccessWithContinuation();
callbacks->onSuccess(key_, primary_key_, value_);
} }
void RendererWebIDBCursorImpl::ResetPrefetchCache() { void RendererWebIDBCursorImpl::ResetPrefetchCache() {
......
...@@ -21,6 +21,7 @@ class RendererWebIDBCursorImpl : public WebKit::WebIDBCursor { ...@@ -21,6 +21,7 @@ class RendererWebIDBCursorImpl : public WebKit::WebIDBCursor {
explicit RendererWebIDBCursorImpl(int32 idb_cursor_id); explicit RendererWebIDBCursorImpl(int32 idb_cursor_id);
virtual ~RendererWebIDBCursorImpl(); virtual ~RendererWebIDBCursorImpl();
// TODO(jsbell): Remove the following three methods after WK92278 rolls.
virtual WebKit::WebIDBKey key() const; virtual WebKit::WebIDBKey key() const;
virtual WebKit::WebIDBKey primaryKey() const; virtual WebKit::WebIDBKey primaryKey() const;
virtual WebKit::WebSerializedScriptValue value() const; virtual WebKit::WebSerializedScriptValue value() const;
...@@ -34,6 +35,7 @@ class RendererWebIDBCursorImpl : public WebKit::WebIDBCursor { ...@@ -34,6 +35,7 @@ class RendererWebIDBCursorImpl : public WebKit::WebIDBCursor {
WebKit::WebExceptionCode& ec); WebKit::WebExceptionCode& ec);
virtual void postSuccessHandlerCallback(); virtual void postSuccessHandlerCallback();
// TODO(jsbell): Remove the following method after WK92278 rolls.
void SetKeyAndValue(const content::IndexedDBKey& key, void SetKeyAndValue(const content::IndexedDBKey& key,
const content::IndexedDBKey& primary_key, const content::IndexedDBKey& primary_key,
const content::SerializedScriptValue& value); const content::SerializedScriptValue& value);
...@@ -47,6 +49,8 @@ class RendererWebIDBCursorImpl : public WebKit::WebIDBCursor { ...@@ -47,6 +49,8 @@ class RendererWebIDBCursorImpl : public WebKit::WebIDBCursor {
private: private:
int32 idb_cursor_id_; int32 idb_cursor_id_;
// TODO(jsbell): Remove the following three members after WK92278 rolls.
content::IndexedDBKey key_; content::IndexedDBKey key_;
content::IndexedDBKey primary_key_; content::IndexedDBKey primary_key_;
content::SerializedScriptValue value_; content::SerializedScriptValue value_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment