diff options
author | andreip@chromium.org <andreip@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-24 13:03:26 +0000 |
---|---|---|
committer | andreip@chromium.org <andreip@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-24 13:03:26 +0000 |
commit | 5bbe2929da7a74e7ceeffcfedee1981adcd3a7b2 (patch) | |
tree | 772f86bdb65c898ca728fe35774417a09fe0972d /chrome | |
parent | 507902277eebc76641b21243039865f61fd7f13a (diff) | |
download | chromium_src-5bbe2929da7a74e7ceeffcfedee1981adcd3a7b2.zip chromium_src-5bbe2929da7a74e7ceeffcfedee1981adcd3a7b2.tar.gz chromium_src-5bbe2929da7a74e7ceeffcfedee1981adcd3a7b2.tar.bz2 |
Revert "Revert 60457 - Adds IDBFactory::didCompleteEventsForTransaction plumbing"
This reverts commit b1e231ca824b2fb9a96bffc04f26eae336ff6ed5.
Also disable the transaction_get.html test, added in this CL.
BUG=
TEST=
Review URL: http://codereview.chromium.org/3466018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60460 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
12 files changed, 135 insertions, 28 deletions
diff --git a/chrome/browser/in_process_webkit/indexed_db_browsertest.cc b/chrome/browser/in_process_webkit/indexed_db_browsertest.cc index 451cf09..15f004e 100644 --- a/chrome/browser/in_process_webkit/indexed_db_browsertest.cc +++ b/chrome/browser/in_process_webkit/indexed_db_browsertest.cc @@ -112,3 +112,7 @@ IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, SplitFilename) { test_on_webkit_thread->security_origin().toString().utf8(); EXPECT_EQ("http://host:1", origin_str); } + +IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, DISABLED_TransactionGetTest) { + SimpleTest(testUrl(FilePath(FILE_PATH_LITERAL("transaction_get_test.html")))); +} diff --git a/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.cc b/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.cc index 595a8cb..626416c 100644 --- a/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.cc +++ b/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.cc @@ -111,7 +111,6 @@ bool IndexedDBDispatcherHost::OnMessageReceived(const IPC::Message& message) { case ViewHostMsg_IDBCursorRemove::ID: case ViewHostMsg_IDBCursorDestroyed::ID: case ViewHostMsg_IDBFactoryOpen::ID: - case ViewHostMsg_IDBFactoryAbortPendingTransactions::ID: case ViewHostMsg_IDBDatabaseName::ID: case ViewHostMsg_IDBDatabaseDescription::ID: case ViewHostMsg_IDBDatabaseVersion::ID: @@ -144,6 +143,7 @@ bool IndexedDBDispatcherHost::OnMessageReceived(const IPC::Message& message) { case ViewHostMsg_IDBObjectStoreDestroyed::ID: case ViewHostMsg_IDBTransactionAbort::ID: case ViewHostMsg_IDBTransactionDestroyed::ID: + case ViewHostMsg_IDBTransactionDidCompleteTaskEvents::ID: case ViewHostMsg_IDBTransactionObjectStore::ID: break; default: @@ -198,8 +198,6 @@ void IndexedDBDispatcherHost::OnMessageReceivedWebKit( IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost, message, msg_is_ok) IPC_MESSAGE_HANDLER(ViewHostMsg_IDBFactoryOpen, OnIDBFactoryOpen) - IPC_MESSAGE_HANDLER(ViewHostMsg_IDBFactoryAbortPendingTransactions, - OnIDBFactoryAbortPendingTransactions) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() } @@ -273,12 +271,6 @@ void IndexedDBDispatcherHost::OnIDBFactoryOpen( webkit_glue::FilePathToWebString(indexed_db_path)); } -// TODO(andreip): remove this method entirely once WK rolls to r68143. -void IndexedDBDispatcherHost::OnIDBFactoryAbortPendingTransactions( - const std::vector<int32>& ids) { - DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)); -} - ////////////////////////////////////////////////////////////////////// // Helper templates. // @@ -974,6 +966,8 @@ bool IndexedDBDispatcherHost::TransactionDispatcherHost::OnMessageReceived( IPC_MESSAGE_HANDLER(ViewHostMsg_IDBTransactionAbort, OnAbort) IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBTransactionObjectStore, OnObjectStore) + IPC_MESSAGE_HANDLER(ViewHostMsg_IDBTransactionDidCompleteTaskEvents, + OnDidCompleteTaskEvents) IPC_MESSAGE_HANDLER(ViewHostMsg_IDBTransactionDestroyed, OnDestroyed) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() @@ -1002,17 +996,29 @@ void IndexedDBDispatcherHost::TransactionDispatcherHost::OnObjectStore( int32 transaction_id, const string16& name, IPC::Message* reply_msg) { WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( &map_, transaction_id, reply_msg, - ViewHostMsg_IDBDatabaseObjectStore::ID); + ViewHostMsg_IDBTransactionObjectStore::ID); if (!idb_transaction) return; WebIDBObjectStore* object_store = idb_transaction->objectStore(name); int32 object_id = object_store ? parent_->Add(object_store) : 0; ViewHostMsg_IDBTransactionObjectStore::WriteReplyParams( - reply_msg, object_id); + reply_msg, object_id); parent_->Send(reply_msg); } +void IndexedDBDispatcherHost:: + TransactionDispatcherHost::OnDidCompleteTaskEvents(int transaction_id) { + DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)); + WebIDBTransaction* idb_transaction = parent_->GetOrTerminateProcess( + &map_, transaction_id, 0, + ViewHostMsg_IDBTransactionDidCompleteTaskEvents::ID); + if (!idb_transaction) + return; + + idb_transaction->didCompleteTaskEvents(); +} + void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( int32 object_id) { parent_->DestroyObject( diff --git a/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h b/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h index 982c861..f048cbe 100644 --- a/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h +++ b/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h @@ -74,7 +74,6 @@ class IndexedDBDispatcherHost // below. void OnMessageReceivedWebKit(const IPC::Message& message); void OnIDBFactoryOpen(const ViewHostMsg_IDBFactoryOpen_Params& p); - void OnIDBFactoryAbortPendingTransactions(const std::vector<int32>& ids); // Helper templates. template <class ReturnType> @@ -221,6 +220,7 @@ class IndexedDBDispatcherHost void OnAbort(int32 transaction_id); void OnObjectStore(int32 transaction_id, const string16& name, IPC::Message* reply_msg); + void OnDidCompleteTaskEvents(int transaction_id); void OnDestroyed(int32 idb_transaction_id); IndexedDBDispatcherHost* parent_; diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index 1d6d04a..7b0682f 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -2373,10 +2373,6 @@ IPC_BEGIN_MESSAGES(ViewHost) IPC_MESSAGE_CONTROL1(ViewHostMsg_IDBFactoryOpen, ViewHostMsg_IDBFactoryOpen_Params) - // WebIDBFactory::abortPendingTransactions() message. - IPC_MESSAGE_CONTROL1(ViewHostMsg_IDBFactoryAbortPendingTransactions, - std::vector<int32> /* transaction_ids */) - // WebIDBDatabase::name() message. IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_IDBDatabaseName, int32, /* idb_database_id */ @@ -2555,6 +2551,10 @@ IPC_BEGIN_MESSAGES(ViewHost) IPC_MESSAGE_CONTROL1(ViewHostMsg_IDBTransactionAbort, int32 /* idb_transaction_id */) + // IDBTransaction::DidCompleteTaskEvents() message. + IPC_MESSAGE_CONTROL1(ViewHostMsg_IDBTransactionDidCompleteTaskEvents, + int32 /* idb_transaction_id */) + // WebIDBTransaction::~WebIDBTransaction() message. IPC_MESSAGE_CONTROL1(ViewHostMsg_IDBTransactionDestroyed, int32 /* idb_transaction_id */) diff --git a/chrome/renderer/renderer_webidbfactory_impl.cc b/chrome/renderer/renderer_webidbfactory_impl.cc index f06e190..776c6f1 100644 --- a/chrome/renderer/renderer_webidbfactory_impl.cc +++ b/chrome/renderer/renderer_webidbfactory_impl.cc @@ -33,13 +33,3 @@ void RendererWebIDBFactoryImpl::open( dispatcher->RequestIDBFactoryOpen( name, description, callbacks, origin.databaseIdentifier(), web_frame); } - -void RendererWebIDBFactoryImpl::abortPendingTransactions( - const WebKit::WebVector<int>& pendingIDs) { - std::vector<int> ids; - for (size_t i = 0; i < pendingIDs.size(); ++i) { - ids.push_back(pendingIDs[i]); - } - RenderThread::current()->Send( - new ViewHostMsg_IDBFactoryAbortPendingTransactions(ids)); -} diff --git a/chrome/renderer/renderer_webidbfactory_impl.h b/chrome/renderer/renderer_webidbfactory_impl.h index 3953249..de4d4ee 100644 --- a/chrome/renderer/renderer_webidbfactory_impl.h +++ b/chrome/renderer/renderer_webidbfactory_impl.h @@ -29,8 +29,6 @@ class RendererWebIDBFactoryImpl : public WebKit::WebIDBFactory { WebKit::WebIDBCallbacks* callbacks, const WebKit::WebSecurityOrigin& origin, WebKit::WebFrame* web_frame, const WebKit::WebString& dataDir); - virtual void abortPendingTransactions( - const WebKit::WebVector<int>& pendingIDs); }; #endif // CHROME_RENDERER_RENDERER_WEBIDBFACTORY_IMPL_H_ diff --git a/chrome/renderer/renderer_webidbobjectstore_impl.cc b/chrome/renderer/renderer_webidbobjectstore_impl.cc index 28c14f4..ce456dd1 100644 --- a/chrome/renderer/renderer_webidbobjectstore_impl.cc +++ b/chrome/renderer/renderer_webidbobjectstore_impl.cc @@ -14,6 +14,7 @@ #include "third_party/WebKit/WebKit/chromium/public/WebDOMStringList.h" #include "third_party/WebKit/WebKit/chromium/public/WebIDBKey.h" #include "third_party/WebKit/WebKit/chromium/public/WebIDBKeyRange.h" +#include "third_party/WebKit/WebKit/chromium/public/WebIDBTransaction.h" #include "third_party/WebKit/WebKit/chromium/public/WebSerializedScriptValue.h" #include "third_party/WebKit/WebKit/chromium/public/WebString.h" @@ -23,6 +24,7 @@ using WebKit::WebIDBCallbacks; using WebKit::WebIDBKeyRange; using WebKit::WebIDBIndex; using WebKit::WebIDBKey; +using WebKit::WebIDBTransaction; using WebKit::WebSerializedScriptValue; using WebKit::WebString; diff --git a/chrome/renderer/renderer_webidbtransaction_impl.cc b/chrome/renderer/renderer_webidbtransaction_impl.cc index dddb2d2..3aa2387 100644 --- a/chrome/renderer/renderer_webidbtransaction_impl.cc +++ b/chrome/renderer/renderer_webidbtransaction_impl.cc @@ -40,6 +40,8 @@ WebIDBObjectStore* RendererWebIDBTransactionImpl::objectStore( RenderThread::current()->Send( new ViewHostMsg_IDBTransactionObjectStore( idb_transaction_id_, name, &object_store_id)); + if (!object_store_id) + return NULL; return new RendererWebIDBObjectStoreImpl(object_store_id); } @@ -49,6 +51,13 @@ void RendererWebIDBTransactionImpl::abort() idb_transaction_id_)); } +void RendererWebIDBTransactionImpl::didCompleteTaskEvents() +{ + RenderThread::current()->Send( + new ViewHostMsg_IDBTransactionDidCompleteTaskEvents( + idb_transaction_id_)); +} + int RendererWebIDBTransactionImpl::id() const { return idb_transaction_id_; diff --git a/chrome/renderer/renderer_webidbtransaction_impl.h b/chrome/renderer/renderer_webidbtransaction_impl.h index 4369104..d1f74fb 100644 --- a/chrome/renderer/renderer_webidbtransaction_impl.h +++ b/chrome/renderer/renderer_webidbtransaction_impl.h @@ -23,6 +23,7 @@ class RendererWebIDBTransactionImpl : public WebKit::WebIDBTransaction { virtual int mode() const; virtual WebKit::WebIDBObjectStore* objectStore(const WebKit::WebString& name); virtual void abort(); + virtual void didCompleteTaskEvents(); virtual int id() const; virtual void setCallbacks(WebKit::WebIDBTransactionCallbacks*); diff --git a/chrome/test/data/indexeddb/common.js b/chrome/test/data/indexeddb/common.js index b773fe3..9ebd361 100644 --- a/chrome/test/data/indexeddb/common.js +++ b/chrome/test/data/indexeddb/common.js @@ -22,11 +22,23 @@ function getLog() return "" + document.getElementById('status').innerHTML; } +function unexpectedSuccessCallback() +{ + fail('unexpectedSuccessCallback'); +} + function unexpectedErrorCallback() { fail('unexpectedErrorCallback'); } +function deleteAllObjectStores(db) +{ + objectStores = db.objectStores; + for (var i = 0; i < objectStores.length; ++i) + db.removeObjectStore(objectStores[i]); +} + // The following functions are based on // WebKit/LayoutTests/fast/js/resources/js-test-pre.js // so that the tests will look similar to the existing layout tests. @@ -79,3 +91,8 @@ function shouldBeTrue(_a) { shouldBe(_a, "true"); } function shouldBeFalse(_a) { shouldBe(_a, "false"); } function shouldBeNaN(_a) { shouldBe(_a, "NaN"); } function shouldBeNull(_a) { shouldBe(_a, "null"); } +function shouldBeEqualToString(a, b) +{ + var unevaledString = '"' + b.replace(/\\/g, "\\\\").replace(/"/g, "\"") + '"'; + shouldBe(a, unevaledString); +} diff --git a/chrome/test/data/indexeddb/transaction_get_test.html b/chrome/test/data/indexeddb/transaction_get_test.html new file mode 100644 index 0000000..edc1e0f --- /dev/null +++ b/chrome/test/data/indexeddb/transaction_get_test.html @@ -0,0 +1,10 @@ +<html> + <head> + <title>IndexedDB transaction get test</title> + <script type="text/javascript" src="common.js"></script> + <script type="text/javascript" src="transaction_get_test.js"></script> + </head> + <body onLoad="test()"> + <div id="status">Starting...</div> + </body> +</html> diff --git a/chrome/test/data/indexeddb/transaction_get_test.js b/chrome/test/data/indexeddb/transaction_get_test.js new file mode 100644 index 0000000..e9c992a --- /dev/null +++ b/chrome/test/data/indexeddb/transaction_get_test.js @@ -0,0 +1,70 @@ +function afterCommit() +{ + try { + debug("Accessing a committed transaction should throw"); + var store = transaction.objectStore('storeName'); + } catch (e) { + exc = e; + shouldBe('exc.code', '9'); + } + done(); +} + +function nonExistingKey() +{ + window.setTimeout('afterCommit()', 0); +} + +function gotValue() +{ + value = event.result; + shouldBeEqualToString('value', 'myValue'); +} + +function startTransaction() +{ + debug("Using get in a transaction"); + transaction = db.transaction(); + //transaction.onabort = unexpectedErrorCallback; + store = transaction.objectStore('storeName'); + shouldBeEqualToString("store.name", "storeName"); + result = store.get('myKey'); + result.onsuccess = gotValue; + result.onerror = unexpectedErrorCallback; + + var emptyResult = store.get('nonExistingKey'); + emptyResult.onsuccess = unexpectedSuccessCallback; + emptyResult.onerror = nonExistingKey; +} + +function populateObjectStore(objectStore) +{ + result = objectStore.add('myValue', 'myKey'); + result.onsuccess = startTransaction; +} + +function createObjectStoreSuccess() +{ + var objectStore = event.result; + populateObjectStore(objectStore); +} + +function openSuccess() +{ + db = event.result; + + deleteAllObjectStores(db); + + result = db.createObjectStore('storeName'); + result.onsuccess = createObjectStoreSuccess; + result.onerror = unexpectedErrorCallback; +} + +function test() +{ + result = indexedDB.open('name', 'description'); + result.onsuccess = openSuccess; + result.onerror = unexpectedErrorCallback; +} + +test(); |