diff options
author | dgrogan@chromium.org <dgrogan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-27 00:21:02 +0000 |
---|---|---|
committer | dgrogan@chromium.org <dgrogan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-27 00:21:02 +0000 |
commit | 0563ebe449cde8c5930a103f58e6c00554b45ae5 (patch) | |
tree | 24fb6db5514814c31f4e2ce01cad84a792dc2ba2 /content/common/indexed_db | |
parent | fe5195f111c94ba3ebe33719463ba24f6c5930e0 (diff) | |
download | chromium_src-0563ebe449cde8c5930a103f58e6c00554b45ae5.zip chromium_src-0563ebe449cde8c5930a103f58e6c00554b45ae5.tar.gz chromium_src-0563ebe449cde8c5930a103f58e6c00554b45ae5.tar.bz2 |
Chrome side changes for integer versions
BUG=108223
TEST=
Review URL: https://chromiumcodereview.appspot.com/10829013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148673 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/common/indexed_db')
6 files changed, 99 insertions, 4 deletions
diff --git a/content/common/indexed_db/indexed_db_dispatcher.cc b/content/common/indexed_db/indexed_db_dispatcher.cc index be3903d..e689a77 100644 --- a/content/common/indexed_db/indexed_db_dispatcher.cc +++ b/content/common/indexed_db/indexed_db_dispatcher.cc @@ -104,15 +104,20 @@ void IndexedDBDispatcher::OnMessageReceived(const IPC::Message& msg) { OnSuccessSerializedScriptValueWithKey) IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksError, OnError) IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksBlocked, OnBlocked) + IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksIntBlocked, OnIntBlocked) + IPC_MESSAGE_HANDLER(IndexedDBMsg_CallbacksUpgradeNeeded, OnUpgradeNeeded) IPC_MESSAGE_HANDLER(IndexedDBMsg_TransactionCallbacksAbort, OnAbort) IPC_MESSAGE_HANDLER(IndexedDBMsg_TransactionCallbacksComplete, OnComplete) + IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksIntVersionChange, + OnIntVersionChange) IPC_MESSAGE_HANDLER(IndexedDBMsg_DatabaseCallbacksVersionChange, OnVersionChange) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() // If a message gets here, IndexedDBMessageFilter already determined that it // is an IndexedDB message. - DCHECK(handled); + DCHECK(handled) << "Didn't handle a message defined at line " + << IPC_MESSAGE_ID_LINE(msg.type()); } bool IndexedDBDispatcher::Send(IPC::Message* msg) { @@ -216,6 +221,7 @@ void IndexedDBDispatcher::RequestIDBCursorDelete( void IndexedDBDispatcher::RequestIDBFactoryOpen( const string16& name, + int64 version, WebIDBCallbacks* callbacks_ptr, const string16& origin, WebFrame* web_frame) { @@ -231,6 +237,7 @@ void IndexedDBDispatcher::RequestIDBFactoryOpen( params.response_id = pending_callbacks_.Add(callbacks.release()); params.origin = origin; params.name = name; + params.version = version; Send(new IndexedDBHostMsg_FactoryOpen(params)); } @@ -275,7 +282,10 @@ void IndexedDBDispatcher::RequestIDBFactoryDeleteDatabase( void IndexedDBDispatcher::RequestIDBDatabaseClose(int32 idb_database_id) { ResetCursorPrefetchCaches(); Send(new IndexedDBHostMsg_DatabaseClose(idb_database_id)); - pending_database_callbacks_.Remove(idb_database_id); + // There won't be pending database callbacks if the transaction was aborted in + // the initial upgradeneeded event handler. + if (pending_database_callbacks_.Lookup(idb_database_id)) + pending_database_callbacks_.Remove(idb_database_id); } void IndexedDBDispatcher::RequestIDBDatabaseOpen( @@ -542,6 +552,11 @@ void IndexedDBDispatcher::CursorDestroyed(int32 cursor_id) { cursors_.erase(cursor_id); } +void IndexedDBDispatcher::DatabaseDestroyed(int32 database_id) { + DCHECK_EQ(databases_.count(database_id), 1u); + databases_.erase(database_id); +} + int32 IndexedDBDispatcher::TransactionId( const WebIDBTransaction& transaction) { const RendererWebIDBTransactionImpl* impl = @@ -556,7 +571,11 @@ void IndexedDBDispatcher::OnSuccessIDBDatabase(int32 thread_id, WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); if (!callbacks) return; - callbacks->onSuccess(new RendererWebIDBDatabaseImpl(object_id)); + // If an upgrade was performed, count will be non-zero. + if (!databases_.count(object_id)) + databases_[object_id] = new RendererWebIDBDatabaseImpl(object_id); + DCHECK_EQ(databases_.count(object_id), 1u); + callbacks->onSuccess(databases_[object_id]); pending_callbacks_.Remove(response_id); } @@ -689,6 +708,30 @@ void IndexedDBDispatcher::OnBlocked(int32 thread_id, int32 response_id) { callbacks->onBlocked(); } +void IndexedDBDispatcher::OnIntBlocked(int32 thread_id, + int32 response_id, + int64 existing_version) { + DCHECK_EQ(thread_id, CurrentWorkerId()); + WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); + DCHECK(callbacks); + callbacks->onBlocked(existing_version); +} + +void IndexedDBDispatcher::OnUpgradeNeeded(int32 thread_id, + int32 response_id, + int32 transaction_id, + int32 database_id, + int64 old_version) { + DCHECK_EQ(thread_id, CurrentWorkerId()); + WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); + DCHECK(callbacks); + DCHECK(!databases_.count(database_id)); + databases_[database_id] = new RendererWebIDBDatabaseImpl(database_id); + callbacks->onUpgradeNeeded(old_version, + new RendererWebIDBTransactionImpl(transaction_id), + databases_[database_id]); +} + void IndexedDBDispatcher::OnError(int32 thread_id, int32 response_id, int code, const string16& message) { DCHECK_EQ(thread_id, CurrentWorkerId()); @@ -719,6 +762,20 @@ void IndexedDBDispatcher::OnComplete(int32 thread_id, int32 transaction_id) { pending_transaction_callbacks_.Remove(transaction_id); } +void IndexedDBDispatcher::OnIntVersionChange(int32 thread_id, + int32 database_id, + int64 old_version, + int64 new_version) { + DCHECK_EQ(thread_id, CurrentWorkerId()); + WebIDBDatabaseCallbacks* callbacks = + pending_database_callbacks_.Lookup(database_id); + // callbacks would be NULL if a versionchange event is received after close + // has been called. + if (!callbacks) + return; + callbacks->onVersionChange(old_version, new_version); +} + void IndexedDBDispatcher::OnVersionChange(int32 thread_id, int32 database_id, const string16& newVersion) { diff --git a/content/common/indexed_db/indexed_db_dispatcher.h b/content/common/indexed_db/indexed_db_dispatcher.h index 250b1f3..a559dc5 100644 --- a/content/common/indexed_db/indexed_db_dispatcher.h +++ b/content/common/indexed_db/indexed_db_dispatcher.h @@ -24,6 +24,7 @@ struct IndexedDBMsg_CallbacksSuccessCursorContinue_Params; struct IndexedDBMsg_CallbacksSuccessCursorPrefetch_Params; struct IndexedDBMsg_CallbacksSuccessIDBCursor_Params; class RendererWebIDBCursorImpl; +class RendererWebIDBDatabaseImpl; namespace IPC { class Message; @@ -70,6 +71,7 @@ class CONTENT_EXPORT IndexedDBDispatcher void RequestIDBFactoryOpen( const string16& name, + int64 version, WebKit::WebIDBCallbacks* callbacks, const string16& origin, WebKit::WebFrame* web_frame); @@ -213,6 +215,7 @@ class CONTENT_EXPORT IndexedDBDispatcher int32 id); void CursorDestroyed(int32 cursor_id); + void DatabaseDestroyed(int32 database_id); static int32 TransactionId(const WebKit::WebIDBTransaction& transaction); @@ -254,11 +257,21 @@ class CONTENT_EXPORT IndexedDBDispatcher int code, const string16& message); void OnBlocked(int32 thread_id, int32 response_id); + void OnIntBlocked(int32 thread_id, int32 response_id, int64 existing_version); + void OnUpgradeNeeded(int32 thread_id, + int32 response_id, + int32 transaction_id, + int32 database_id, + int64 old_version); void OnAbort(int32 thread_id, int32 transaction_id); void OnComplete(int32 thread_id, int32 transaction_id); void OnVersionChange(int32 thread_id, int32 database_id, const string16& newVersion); + void OnIntVersionChange(int32 thread_id, + int32 database_id, + int64 old_version, + int64 new_version); // Reset cursor prefetch caches for all cursors except exception_cursor_id. void ResetCursorPrefetchCaches(int32 exception_cursor_id = -1); @@ -274,6 +287,8 @@ class CONTENT_EXPORT IndexedDBDispatcher // Map from cursor id to RendererWebIDBCursorImpl. std::map<int32, RendererWebIDBCursorImpl*> cursors_; + std::map<int32, RendererWebIDBDatabaseImpl*> databases_; + DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcher); }; diff --git a/content/common/indexed_db/indexed_db_messages.h b/content/common/indexed_db/indexed_db_messages.h index b265a1f..a84428d 100644 --- a/content/common/indexed_db/indexed_db_messages.h +++ b/content/common/indexed_db/indexed_db_messages.h @@ -42,6 +42,8 @@ IPC_STRUCT_BEGIN(IndexedDBHostMsg_FactoryOpen_Params) IPC_STRUCT_MEMBER(string16, origin) // The name of the database. IPC_STRUCT_MEMBER(string16, name) + // The requested version of the database. + IPC_STRUCT_MEMBER(int64, version) IPC_STRUCT_END() // Used to delete an indexed database. @@ -245,6 +247,16 @@ IPC_MESSAGE_CONTROL4(IndexedDBMsg_CallbacksError, IPC_MESSAGE_CONTROL2(IndexedDBMsg_CallbacksBlocked, int32 /* thread_id */, int32 /* response_id */) +IPC_MESSAGE_CONTROL3(IndexedDBMsg_CallbacksIntBlocked, + int32 /* thread_id */, + int32 /* response_id */, + int64 /* existing_version */) +IPC_MESSAGE_CONTROL5(IndexedDBMsg_CallbacksUpgradeNeeded, + int32, /* thread_id */ + int32, /* response_id */ + int32, /* transaction_id */ + int32, /* database_id */ + int64) /* old_version */ // IDBTransactionCallback message handlers. IPC_MESSAGE_CONTROL2(IndexedDBMsg_TransactionCallbacksAbort, @@ -259,6 +271,12 @@ IPC_MESSAGE_CONTROL3(IndexedDBMsg_DatabaseCallbacksVersionChange, int32, /* database_id */ string16) /* new_version */ +IPC_MESSAGE_CONTROL4(IndexedDBMsg_DatabaseCallbacksIntVersionChange, + int32, /* thread_id */ + int32, /* database_id */ + int64, /* old_version */ + int64) /* new_version */ + // Indexed DB messages sent from the renderer to the browser. // WebIDBCursor::update() message. diff --git a/content/common/indexed_db/proxy_webidbdatabase_impl.cc b/content/common/indexed_db/proxy_webidbdatabase_impl.cc index 4a4c27c..c1e877c 100644 --- a/content/common/indexed_db/proxy_webidbdatabase_impl.cc +++ b/content/common/indexed_db/proxy_webidbdatabase_impl.cc @@ -38,6 +38,9 @@ RendererWebIDBDatabaseImpl::~RendererWebIDBDatabaseImpl() { // any such pointers. IndexedDBDispatcher::Send(new IndexedDBHostMsg_DatabaseDestroyed( idb_database_id_)); + IndexedDBDispatcher* dispatcher = + IndexedDBDispatcher::ThreadSpecificInstance(); + dispatcher->DatabaseDestroyed(idb_database_id_); } WebIDBMetadata RendererWebIDBDatabaseImpl::metadata() const { diff --git a/content/common/indexed_db/proxy_webidbfactory_impl.cc b/content/common/indexed_db/proxy_webidbfactory_impl.cc index 6a55ead..d4bd569 100644 --- a/content/common/indexed_db/proxy_webidbfactory_impl.cc +++ b/content/common/indexed_db/proxy_webidbfactory_impl.cc @@ -35,6 +35,7 @@ void RendererWebIDBFactoryImpl::getDatabaseNames( void RendererWebIDBFactoryImpl::open( const WebString& name, + long long version, WebIDBCallbacks* callbacks, const WebSecurityOrigin& origin, WebFrame* web_frame, @@ -44,7 +45,7 @@ void RendererWebIDBFactoryImpl::open( IndexedDBDispatcher* dispatcher = IndexedDBDispatcher::ThreadSpecificInstance(); dispatcher->RequestIDBFactoryOpen( - name, callbacks, origin.databaseIdentifier(), web_frame); + name, version, callbacks, origin.databaseIdentifier(), web_frame); } void RendererWebIDBFactoryImpl::deleteDatabase( diff --git a/content/common/indexed_db/proxy_webidbfactory_impl.h b/content/common/indexed_db/proxy_webidbfactory_impl.h index 22a8ced..23745dc 100644 --- a/content/common/indexed_db/proxy_webidbfactory_impl.h +++ b/content/common/indexed_db/proxy_webidbfactory_impl.h @@ -29,6 +29,7 @@ class RendererWebIDBFactoryImpl : public WebKit::WebIDBFactory { virtual void open( const WebKit::WebString& name, + long long version, WebKit::WebIDBCallbacks* callbacks, const WebKit::WebSecurityOrigin& origin, WebKit::WebFrame* web_frame, |