| Index: content/browser/in_process_webkit/indexed_db_callbacks.h
|
| diff --git a/content/browser/in_process_webkit/indexed_db_callbacks.h b/content/browser/in_process_webkit/indexed_db_callbacks.h
|
| index 47db78f733387c808417d80a8d7f4869956a31b6..65c57c8f2c4eac366025b8d8cdc074248e190bec 100644
|
| --- a/content/browser/in_process_webkit/indexed_db_callbacks.h
|
| +++ b/content/browser/in_process_webkit/indexed_db_callbacks.h
|
| @@ -17,6 +17,7 @@
|
|
|
| class IndexedDBMsg_CallbacksSuccessIDBDatabase;
|
| class IndexedDBMsg_CallbacksSuccessIDBTransaction;
|
| +class IndexedDBMsg_CallbacksUpgradeNeeded;
|
|
|
| // Template magic to figure out what message to send to the renderer based on
|
| // which (overloaded) onSuccess method we expect to be called.
|
| @@ -28,6 +29,15 @@ template <> struct WebIDBToMsgHelper<WebKit::WebIDBTransaction> {
|
| typedef IndexedDBMsg_CallbacksSuccessIDBTransaction MsgType;
|
| };
|
|
|
| +template <class Type2> struct WebIDBToMsgHelper2 { };
|
| +template <> struct WebIDBToMsgHelper2<WebKit::WebIDBDatabase> {
|
| + typedef IndexedDBMsg_CallbacksUpgradeNeeded MsgType;
|
| +};
|
| +
|
| +template <> struct WebIDBToMsgHelper2<WebKit::WebIDBTransaction> {
|
| + typedef IndexedDBMsg_CallbacksUpgradeNeeded MsgType;
|
| +};
|
| +
|
| // The code the following two classes share.
|
| class IndexedDBCallbacksBase : public WebKit::WebIDBCallbacks {
|
| public:
|
| @@ -39,6 +49,7 @@ class IndexedDBCallbacksBase : public WebKit::WebIDBCallbacks {
|
|
|
| virtual void onError(const WebKit::WebIDBDatabaseError& error);
|
| virtual void onBlocked();
|
| + virtual void onBlocked(int64_t existing_version);
|
|
|
| protected:
|
| IndexedDBDispatcherHost* dispatcher_host() const {
|
| @@ -65,20 +76,41 @@ class IndexedDBCallbacks : public IndexedDBCallbacksBase {
|
| int32 response_id,
|
| const GURL& origin_url)
|
| : IndexedDBCallbacksBase(dispatcher_host, thread_id, response_id),
|
| - origin_url_(origin_url) {
|
| + origin_url_(origin_url),
|
| + database_id_(-1) {
|
| }
|
|
|
| virtual void onSuccess(WebObjectType* idb_object) {
|
| - int32 object_id = dispatcher_host()->Add(idb_object, thread_id(),
|
| - origin_url_);
|
| + int32 object_id = database_id_;
|
| + if (object_id == -1)
|
| + object_id = dispatcher_host()->Add(idb_object, thread_id(), origin_url_);
|
| + else
|
| + delete idb_object;
|
| +
|
| dispatcher_host()->Send(
|
| new typename WebIDBToMsgHelper<WebObjectType>::MsgType(thread_id(),
|
| response_id(),
|
| object_id));
|
| }
|
| + void onUpgradeNeeded(
|
| + int64_t old_version,
|
| + WebKit::WebIDBTransaction* transaction,
|
| + WebKit::WebIDBDatabase* database) {
|
| + int32 transaction_id = dispatcher_host()->Add(transaction, thread_id(),
|
| + origin_url_);
|
| + int32 database_id = dispatcher_host()->Add(database, thread_id(),
|
| + origin_url_);
|
| + database_id_ = database_id;
|
| + dispatcher_host()->Send(
|
| + new typename WebIDBToMsgHelper2<WebObjectType>::MsgType(
|
| + thread_id(), response_id(), transaction_id, database_id,
|
| + old_version));
|
| + }
|
| +
|
|
|
| private:
|
| GURL origin_url_;
|
| + int32 database_id_;
|
| DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks);
|
| };
|
|
|
|
|