diff options
-rw-r--r-- | chrome/browser/in_process_webkit/indexed_db_callbacks.h | 23 | ||||
-rw-r--r-- | chrome/browser/in_process_webkit/indexed_db_dispatcher_host.cc | 93 | ||||
-rw-r--r-- | chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h | 24 | ||||
-rw-r--r-- | chrome/chrome_renderer.gypi | 6 | ||||
-rw-r--r-- | chrome/common/render_messages_internal.h | 24 | ||||
-rw-r--r-- | chrome/renderer/indexed_db_dispatcher.cc | 15 | ||||
-rw-r--r-- | chrome/renderer/indexed_db_dispatcher.h | 7 | ||||
-rw-r--r-- | chrome/renderer/renderer_webidbdatabase_impl.cc | 17 | ||||
-rw-r--r-- | chrome/renderer/renderer_webidbdatabase_impl.h | 5 | ||||
-rw-r--r-- | chrome/renderer/renderer_webidbfactory_impl.cc | 10 | ||||
-rw-r--r-- | chrome/renderer/renderer_webidbfactory_impl.h | 3 | ||||
-rw-r--r-- | chrome/renderer/renderer_webidbtransaction_impl.cc | 60 | ||||
-rw-r--r-- | chrome/renderer/renderer_webidbtransaction_impl.h | 33 |
13 files changed, 316 insertions, 4 deletions
diff --git a/chrome/browser/in_process_webkit/indexed_db_callbacks.h b/chrome/browser/in_process_webkit/indexed_db_callbacks.h index 5421fc6..09a3bab 100644 --- a/chrome/browser/in_process_webkit/indexed_db_callbacks.h +++ b/chrome/browser/in_process_webkit/indexed_db_callbacks.h @@ -15,6 +15,7 @@ #include "chrome/common/serialized_script_value.h" #include "third_party/WebKit/WebKit/chromium/public/WebIDBCallbacks.h" #include "third_party/WebKit/WebKit/chromium/public/WebIDBCursor.h" +#include "third_party/WebKit/WebKit/chromium/public/WebIDBTransactionCallbacks.h" #include "third_party/WebKit/WebKit/chromium/public/WebIDBDatabaseError.h" // Template magic to figure out what message to send to the renderer based on @@ -158,5 +159,27 @@ class IndexedDBCallbacks<void> : public IndexedDBCallbacksBase { DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks); }; +class IndexedDBTransactionCallbacks + : public WebKit::WebIDBTransactionCallbacks { +public: + IndexedDBTransactionCallbacks( + IndexedDBDispatcherHost* dispatcher_host, int transaction_id) + : dispatcher_host_(dispatcher_host), transaction_id_(transaction_id) { + } + + virtual void onAbort() { + dispatcher_host_->Send(new ViewMsg_IDBTransactionCallbacksAbort( + transaction_id_)); + } + + virtual int id() const { + return transaction_id_; + } + +private: + scoped_refptr<IndexedDBDispatcherHost> dispatcher_host_; + int transaction_id_; +}; + #endif // CHROME_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CALLBACKS_H_ 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 9603530..d0af866 100644 --- a/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.cc +++ b/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.cc @@ -20,7 +20,9 @@ #include "third_party/WebKit/WebKit/chromium/public/WebIDBIndex.h" #include "third_party/WebKit/WebKit/chromium/public/WebIDBFactory.h" #include "third_party/WebKit/WebKit/chromium/public/WebIDBObjectStore.h" +#include "third_party/WebKit/WebKit/chromium/public/WebIDBTransaction.h" #include "third_party/WebKit/WebKit/chromium/public/WebSecurityOrigin.h" +#include "third_party/WebKit/WebKit/chromium/public/WebVector.h" using WebKit::WebDOMStringList; using WebKit::WebIDBCursor; @@ -30,8 +32,10 @@ using WebKit::WebIDBIndex; using WebKit::WebIDBKey; using WebKit::WebIDBKeyRange; using WebKit::WebIDBObjectStore; +using WebKit::WebIDBTransaction; using WebKit::WebSecurityOrigin; using WebKit::WebSerializedScriptValue; +using WebKit::WebVector; IndexedDBDispatcherHost::IndexedDBDispatcherHost( IPC::Message::Sender* sender, WebKitContext* webkit_context) @@ -45,6 +49,8 @@ IndexedDBDispatcherHost::IndexedDBDispatcherHost( new ObjectStoreDispatcherHost(this))), ALLOW_THIS_IN_INITIALIZER_LIST(cursor_dispatcher_host_( new CursorDispatcherHost(this))), + ALLOW_THIS_IN_INITIALIZER_LIST(transaction_dispatcher_host_( + new TransactionDispatcherHost(this))), process_handle_(0) { DCHECK(sender_); DCHECK(webkit_context_.get()); @@ -92,6 +98,7 @@ bool IndexedDBDispatcherHost::OnMessageReceived(const IPC::Message& message) { case ViewHostMsg_IDBCursorKey::ID: case ViewHostMsg_IDBCursorValue::ID: case ViewHostMsg_IDBFactoryOpen::ID: + case ViewHostMsg_IDBFactoryAbortPendingTransactions::ID: case ViewHostMsg_IDBDatabaseName::ID: case ViewHostMsg_IDBDatabaseDescription::ID: case ViewHostMsg_IDBDatabaseVersion::ID: @@ -99,6 +106,7 @@ bool IndexedDBDispatcherHost::OnMessageReceived(const IPC::Message& message) { case ViewHostMsg_IDBDatabaseCreateObjectStore::ID: case ViewHostMsg_IDBDatabaseObjectStore::ID: case ViewHostMsg_IDBDatabaseRemoveObjectStore::ID: + case ViewHostMsg_IDBDatabaseTransaction::ID: case ViewHostMsg_IDBDatabaseDestroyed::ID: case ViewHostMsg_IDBIndexName::ID: case ViewHostMsg_IDBIndexKeyPath::ID: @@ -115,6 +123,7 @@ bool IndexedDBDispatcherHost::OnMessageReceived(const IPC::Message& message) { case ViewHostMsg_IDBObjectStoreIndex::ID: case ViewHostMsg_IDBObjectStoreRemoveIndex::ID: case ViewHostMsg_IDBObjectStoreDestroyed::ID: + case ViewHostMsg_IDBTransactionDestroyed::ID: break; default: return false; @@ -159,7 +168,8 @@ void IndexedDBDispatcherHost::OnMessageReceivedWebKit( database_dispatcher_host_->OnMessageReceived(message, &msg_is_ok) || index_dispatcher_host_->OnMessageReceived(message, &msg_is_ok) || object_store_dispatcher_host_->OnMessageReceived(message, &msg_is_ok) || - cursor_dispatcher_host_->OnMessageReceived(message, &msg_is_ok); + cursor_dispatcher_host_->OnMessageReceived(message, &msg_is_ok) || + transaction_dispatcher_host_->OnMessageReceived(message, &msg_is_ok); if (!handled) { handled = true; @@ -167,6 +177,8 @@ 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() } @@ -194,6 +206,11 @@ int32 IndexedDBDispatcherHost::Add(WebIDBObjectStore* idb_object_store) { return object_store_dispatcher_host_->map_.Add(idb_object_store); } +void IndexedDBDispatcherHost::Add(WebIDBTransaction* idb_transaction) { + transaction_dispatcher_host_->map_.AddWithID( + idb_transaction, idb_transaction->id()); +} + void IndexedDBDispatcherHost::OnIDBFactoryOpen( const ViewHostMsg_IDBFactoryOpen_Params& params) { // TODO(jorlow): Check the content settings map and use params.routing_id_ @@ -206,6 +223,14 @@ void IndexedDBDispatcherHost::OnIDBFactoryOpen( WebSecurityOrigin::createFromDatabaseIdentifier(params.origin_), NULL); } +void IndexedDBDispatcherHost::OnIDBFactoryAbortPendingTransactions( + const std::vector<int32>& ids) { + DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT)); + + WebVector<int32> pendingIDs = ids; + Context()->GetIDBFactory()->abortPendingTransactions(pendingIDs); +} + ////////////////////////////////////////////////////////////////////// // Helper templates. // @@ -277,6 +302,8 @@ bool IndexedDBDispatcherHost::DatabaseDispatcherHost::OnMessageReceived( OnObjectStore) IPC_MESSAGE_HANDLER(ViewHostMsg_IDBDatabaseRemoveObjectStore, OnRemoveObjectStore) + IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBDatabaseTransaction, + OnTransaction) IPC_MESSAGE_HANDLER(ViewHostMsg_IDBDatabaseDestroyed, OnDestroyed) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() @@ -368,6 +395,31 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnRemoveObjectStore( name, new IndexedDBCallbacks<WebIDBObjectStore>(parent_, response_id)); } +void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnTransaction( + int32 idb_database_id, const std::vector<string16>& names, + int32 mode, int32 timeout, IPC::Message* reply_msg) { + WebIDBDatabase* database = parent_->GetOrTerminateProcess( + &map_, idb_database_id, reply_msg, + ViewHostMsg_IDBDatabaseTransaction::ID); + if (!database) + return; + + WebDOMStringList object_stores; + for (std::vector<string16>::const_iterator it = names.begin(); + it != names.end(); ++it) { + object_stores.append(*it); + } + + WebIDBTransaction* transaction = database->transaction( + object_stores, mode, timeout); + transaction->setCallbacks( + new IndexedDBTransactionCallbacks(parent_, transaction->id())); + parent_->Add(transaction); + ViewHostMsg_IDBDatabaseTransaction::WriteReplyParams( + reply_msg, transaction->id()); + parent_->Send(reply_msg); +} + void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDestroyed( int32 object_id) { parent_->DestroyObject(&map_, object_id, @@ -615,6 +667,7 @@ bool IndexedDBDispatcherHost::CursorDispatcherHost::OnMessageReceived( return handled; } + void IndexedDBDispatcherHost::CursorDispatcherHost::Send( IPC::Message* message) { // The macro magic in OnMessageReceived requires this to link, but it should @@ -682,3 +735,41 @@ void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( parent_->DestroyObject( &map_, object_id, ViewHostMsg_IDBCursorDestroyed::ID); } + +////////////////////////////////////////////////////////////////////// +// IndexedDBDispatcherHost::TransactionDispatcherHost +// + +IndexedDBDispatcherHost::TransactionDispatcherHost::TransactionDispatcherHost( + IndexedDBDispatcherHost* parent) + : parent_(parent) { +} + +IndexedDBDispatcherHost:: + TransactionDispatcherHost::~TransactionDispatcherHost() { +} + +bool IndexedDBDispatcherHost::TransactionDispatcherHost::OnMessageReceived( + const IPC::Message& message, bool* msg_is_ok) { + bool handled = true; + IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost::TransactionDispatcherHost, + message, *msg_is_ok) + IPC_MESSAGE_HANDLER(ViewHostMsg_IDBTransactionDestroyed, OnDestroyed) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP() + return handled; +} + +void IndexedDBDispatcherHost::TransactionDispatcherHost::Send( + IPC::Message* message) { + // The macro magic in OnMessageReceived requires this to link, but it should + // never actually be called. + NOTREACHED(); + parent_->Send(message); +} + +void IndexedDBDispatcherHost::TransactionDispatcherHost::OnDestroyed( + int32 object_id) { + parent_->DestroyObject( + &map_, object_id, ViewHostMsg_IDBTransactionDestroyed::ID); +} 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 ff0fad2..ed3357e 100644 --- a/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h +++ b/chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h @@ -25,6 +25,7 @@ class WebIDBCursor; class WebIDBDatabase; class WebIDBIndex; class WebIDBObjectStore; +class WebIDBTransaction; } // Handles all IndexedDB related messages from a particular renderer process. @@ -60,6 +61,7 @@ class IndexedDBDispatcherHost int32 Add(WebKit::WebIDBDatabase* idb_database); int32 Add(WebKit::WebIDBIndex* idb_index); int32 Add(WebKit::WebIDBObjectStore* idb_object_store); + void Add(WebKit::WebIDBTransaction* idb_transaction); private: friend class base::RefCountedThreadSafe<IndexedDBDispatcherHost>; @@ -69,6 +71,7 @@ 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> @@ -103,6 +106,9 @@ class IndexedDBDispatcherHost IPC::Message* reply_msg); void OnRemoveObjectStore(int32 idb_database_id, int32 response_id, const string16& name); + void OnTransaction(int32 idb_database_id, + const std::vector<string16>& names, + int32 mode, int32 timeout, IPC::Message* reply_msg); void OnDestroyed(int32 idb_database_id); IndexedDBDispatcherHost* parent_; @@ -174,6 +180,22 @@ class IndexedDBDispatcherHost IndexedDBDispatcherHost* parent_; IDMap<WebKit::WebIDBCursor, IDMapOwnPointer> map_; }; + + class TransactionDispatcherHost { + public: + explicit TransactionDispatcherHost(IndexedDBDispatcherHost* parent); + ~TransactionDispatcherHost(); + + bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok); + void Send(IPC::Message* message); + + // TODO: add the rest of the transaction methods. + void OnDestroyed(int32 idb_transaction_id); + + IndexedDBDispatcherHost* parent_; + IDMap<WebKit::WebIDBTransaction, IDMapOwnPointer> map_; + }; + // Only use on the IO thread. IPC::Message::Sender* sender_; @@ -185,6 +207,8 @@ class IndexedDBDispatcherHost scoped_ptr<IndexDispatcherHost> index_dispatcher_host_; scoped_ptr<ObjectStoreDispatcherHost> object_store_dispatcher_host_; scoped_ptr<CursorDispatcherHost> cursor_dispatcher_host_; + scoped_ptr<TransactionDispatcherHost> transaction_dispatcher_host_; + // If we get a corrupt message from a renderer, we need to kill it using this // handle. diff --git a/chrome/chrome_renderer.gypi b/chrome/chrome_renderer.gypi index d73af4a..f101c1e 100644 --- a/chrome/chrome_renderer.gypi +++ b/chrome/chrome_renderer.gypi @@ -167,12 +167,14 @@ 'renderer/renderer_webidbcursor_impl.h', 'renderer/renderer_webidbdatabase_impl.cc', 'renderer/renderer_webidbdatabase_impl.h', + 'renderer/renderer_webidbfactory_impl.cc', + 'renderer/renderer_webidbfactory_impl.h', 'renderer/renderer_webidbindex_impl.cc', 'renderer/renderer_webidbindex_impl.h', 'renderer/renderer_webidbobjectstore_impl.cc', 'renderer/renderer_webidbobjectstore_impl.h', - 'renderer/renderer_webidbfactory_impl.cc', - 'renderer/renderer_webidbfactory_impl.h', + 'renderer/renderer_webidbtransaction_impl.cc', + 'renderer/renderer_webidbtransaction_impl.h', 'renderer/renderer_webkitclient_impl.cc', 'renderer/renderer_webkitclient_impl.h', 'renderer/renderer_webstoragearea_impl.cc', diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index 4a15201..5bfb341 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -874,6 +874,10 @@ IPC_BEGIN_MESSAGES(View) int /* code */, string16 /* message */) + // IDBTransactionCallback message handlers. + IPC_MESSAGE_CONTROL1(ViewMsg_IDBTransactionCallbacksAbort, + int /* transaction_id */) + #if defined(IPC_MESSAGE_LOG_ENABLED) // Tell the renderer process to begin or end IPC message logging. IPC_MESSAGE_CONTROL1(ViewMsg_SetIPCLoggingEnabled, @@ -2286,6 +2290,10 @@ 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 */ @@ -2324,6 +2332,18 @@ IPC_BEGIN_MESSAGES(ViewHost) int32, /* response_id */ string16 /* name */) + // WebIDBDatabase::transaction() message. + // TODO: make this message async. Have the renderer create a + // temporary ID and keep a map in the browser process of real + // IDs to temporary IDs. We can then update the transaction + // to its real ID asynchronously. + IPC_SYNC_MESSAGE_CONTROL4_1(ViewHostMsg_IDBDatabaseTransaction, + int32, /* idb_database_id */ + std::vector<string16>, /* object_stores */ + int32, /* mode */ + int32, /* timeout */ + int32 /* idb_transaction_id */) + // WebIDBDatabase::~WebIDBDatabase() message. IPC_MESSAGE_CONTROL1(ViewHostMsg_IDBDatabaseDestroyed, int32 /* idb_database_id */) @@ -2411,6 +2431,10 @@ IPC_BEGIN_MESSAGES(ViewHost) IPC_MESSAGE_CONTROL1(ViewHostMsg_IDBCursorDestroyed, int32 /* idb_cursor_id */) + // WebIDBTransaction::~WebIDBTransaction() message. + IPC_MESSAGE_CONTROL1(ViewHostMsg_IDBTransactionDestroyed, + int32 /* idb_index_id */) + // Get file size in bytes. Set result to -1 if failed to get the file size. IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_GetFileSize, FilePath /* path */, diff --git a/chrome/renderer/indexed_db_dispatcher.cc b/chrome/renderer/indexed_db_dispatcher.cc index 1087eec..65336da 100644 --- a/chrome/renderer/indexed_db_dispatcher.cc +++ b/chrome/renderer/indexed_db_dispatcher.cc @@ -51,6 +51,8 @@ bool IndexedDBDispatcher::OnMessageReceived(const IPC::Message& msg) { OnSuccessSerializedScriptValue) IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbacksError, OnError) + IPC_MESSAGE_HANDLER(ViewMsg_IDBTransactionCallbacksAbort, + OnAbort) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; @@ -177,6 +179,11 @@ void IndexedDBDispatcher::RequestIDBObjectStoreOpenCursor( new ViewHostMsg_IDBObjectStoreOpenCursor(params)); } +void IndexedDBDispatcher::RequestIDBTransactionSetCallbacks( + WebKit::WebIDBTransactionCallbacks* callbacks) { + pending_transaction_callbacks_.AddWithID(callbacks, callbacks->id()); +} + void IndexedDBDispatcher::OnSuccessNull(int32 response_id) { WebKit::WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); callbacks->onSuccess(); @@ -232,3 +239,11 @@ void IndexedDBDispatcher::OnError(int32 response_id, int code, callbacks->onError(WebIDBDatabaseError(code, message)); pending_callbacks_.Remove(response_id); } + +void IndexedDBDispatcher::OnAbort(int transaction_id) { + WebKit::WebIDBTransactionCallbacks* callbacks = + pending_transaction_callbacks_.Lookup(transaction_id); + DCHECK(callbacks); + callbacks->onAbort(); + pending_transaction_callbacks_.Remove(transaction_id); +} diff --git a/chrome/renderer/indexed_db_dispatcher.h b/chrome/renderer/indexed_db_dispatcher.h index 5c04180..c2602e0 100644 --- a/chrome/renderer/indexed_db_dispatcher.h +++ b/chrome/renderer/indexed_db_dispatcher.h @@ -11,6 +11,7 @@ #include "ipc/ipc_message.h" #include "third_party/WebKit/WebKit/chromium/public/WebIDBCallbacks.h" #include "third_party/WebKit/WebKit/chromium/public/WebIDBDatabase.h" +#include "third_party/WebKit/WebKit/chromium/public/WebIDBTransactionCallbacks.h" class IndexedDBKey; class SerializedScriptValue; @@ -69,6 +70,9 @@ class IndexedDBDispatcher { const WebKit::WebIDBKeyRange& idb_key_range, unsigned short direction, WebKit::WebIDBCallbacks* callbacks, int32 idb_object_store_id); + void RequestIDBTransactionSetCallbacks( + WebKit::WebIDBTransactionCallbacks* callbacks); + private: // IDBCallback message handlers. void OnSuccessNull(int32 response_id); @@ -80,10 +84,13 @@ class IndexedDBDispatcher { void OnSuccessSerializedScriptValue(int32 response_id, const SerializedScriptValue& value); void OnError(int32 response_id, int code, const string16& message); + void OnAbort(int transaction_id); // Careful! WebIDBCallbacks wraps non-threadsafe data types. It must be // destroyed and used on the same thread it was created on. IDMap<WebKit::WebIDBCallbacks, IDMapOwnPointer> pending_callbacks_; + IDMap<WebKit::WebIDBTransactionCallbacks, IDMapOwnPointer> + pending_transaction_callbacks_; DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcher); }; diff --git a/chrome/renderer/renderer_webidbdatabase_impl.cc b/chrome/renderer/renderer_webidbdatabase_impl.cc index 0f07369..7bfaf5c 100644 --- a/chrome/renderer/renderer_webidbdatabase_impl.cc +++ b/chrome/renderer/renderer_webidbdatabase_impl.cc @@ -7,11 +7,13 @@ #include "chrome/common/render_messages.h" #include "chrome/renderer/render_thread.h" #include "chrome/renderer/indexed_db_dispatcher.h" +#include "chrome/renderer/renderer_webidbtransaction_impl.h" #include "third_party/WebKit/WebKit/chromium/public/WebString.h" using WebKit::WebDOMStringList; using WebKit::WebFrame; using WebKit::WebIDBCallbacks; +using WebKit::WebIDBTransaction; using WebKit::WebString; using WebKit::WebVector; @@ -67,3 +69,18 @@ void RendererWebIDBDatabaseImpl::createObjectStore( dispatcher->RequestIDBDatabaseCreateObjectStore( name, key_path, auto_increment, callbacks, idb_database_id_); } + +WebKit::WebIDBTransaction* RendererWebIDBDatabaseImpl::transaction( + const WebDOMStringList& names, unsigned short mode, + unsigned long timeout) { + std::vector<string16> object_stores(names.length()); + for (unsigned int i = 0; i < names.length(); ++i) { + object_stores.push_back(names.item(i)); + } + + int transaction_id; + RenderThread::current()->Send( + new ViewHostMsg_IDBDatabaseTransaction( + idb_database_id_, object_stores, mode, timeout, &transaction_id)); + return new RendererWebIDBTransactionImpl(transaction_id); +} diff --git a/chrome/renderer/renderer_webidbdatabase_impl.h b/chrome/renderer/renderer_webidbdatabase_impl.h index 2105d3b..2ce55b1 100644 --- a/chrome/renderer/renderer_webidbdatabase_impl.h +++ b/chrome/renderer/renderer_webidbdatabase_impl.h @@ -14,6 +14,7 @@ namespace WebKit { class WebFrame; class WebIDBCallbacks; class WebString; +class WebIDBTransaction; } class RendererWebIDBDatabaseImpl : public WebKit::WebIDBDatabase { @@ -29,7 +30,9 @@ class RendererWebIDBDatabaseImpl : public WebKit::WebIDBDatabase { virtual void createObjectStore( const WebKit::WebString& name, const WebKit::WebString& key_path, bool auto_increment, WebKit::WebIDBCallbacks* callbacks); - + virtual WebKit::WebIDBTransaction* transaction( + const WebKit::WebDOMStringList& names, + unsigned short mode, unsigned long timeout); private: int32 idb_database_id_; }; diff --git a/chrome/renderer/renderer_webidbfactory_impl.cc b/chrome/renderer/renderer_webidbfactory_impl.cc index 2ccf84a..f1dd4dd 100644 --- a/chrome/renderer/renderer_webidbfactory_impl.cc +++ b/chrome/renderer/renderer_webidbfactory_impl.cc @@ -32,3 +32,13 @@ 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 de71220..e2f2b47 100644 --- a/chrome/renderer/renderer_webidbfactory_impl.h +++ b/chrome/renderer/renderer_webidbfactory_impl.h @@ -8,6 +8,7 @@ #include "third_party/WebKit/WebKit/chromium/public/WebIDBCallbacks.h" #include "third_party/WebKit/WebKit/chromium/public/WebIDBFactory.h" +#include "third_party/WebKit/WebKit/chromium/public/WebVector.h" namespace WebKit { class WebDOMStringList; @@ -27,6 +28,8 @@ class RendererWebIDBFactoryImpl : public WebKit::WebIDBFactory { const WebKit::WebString& name, const WebKit::WebString& description, WebKit::WebIDBCallbacks* callbacks, const WebKit::WebSecurityOrigin& origin, WebKit::WebFrame* web_frame); + virtual void abortPendingTransactions( + const WebKit::WebVector<int>& pendingIDs); }; #endif // CHROME_RENDERER_RENDERER_WEBIDBFACTORY_IMPL_H_ diff --git a/chrome/renderer/renderer_webidbtransaction_impl.cc b/chrome/renderer/renderer_webidbtransaction_impl.cc new file mode 100644 index 0000000..8faf9a1 --- /dev/null +++ b/chrome/renderer/renderer_webidbtransaction_impl.cc @@ -0,0 +1,60 @@ +// Copyright (c) 2010 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. + +#include "chrome/renderer/renderer_webidbtransaction_impl.h" + +#include "chrome/common/render_messages.h" +#include "chrome/renderer/render_thread.h" +#include "chrome/renderer/indexed_db_dispatcher.h" +#include "third_party/WebKit/WebKit/chromium/public/WebIDBObjectStore.h" +#include "third_party/WebKit/WebKit/chromium/public/WebIDBTransactionCallbacks.h" +#include "third_party/WebKit/WebKit/chromium/public/WebString.h" + +using WebKit::WebIDBObjectStore; +using WebKit::WebIDBTransactionCallbacks; +using WebKit::WebString; + +RendererWebIDBTransactionImpl::RendererWebIDBTransactionImpl( + int32 idb_transaction_id) + : idb_transaction_id_(idb_transaction_id) { +} + +RendererWebIDBTransactionImpl::~RendererWebIDBTransactionImpl() { + RenderThread::current()->Send(new ViewHostMsg_IDBTransactionDestroyed( + idb_transaction_id_)); +} + +int RendererWebIDBTransactionImpl::mode() const +{ + // TODO: implement + DCHECK(false); + return 0; +} + +WebIDBObjectStore* RendererWebIDBTransactionImpl::objectStore( + const WebString& name) +{ + // TODO: implement + DCHECK(false); + return 0; +} + +void RendererWebIDBTransactionImpl::abort() +{ + // TODO: implement + DCHECK(false); +} + +int RendererWebIDBTransactionImpl::id() const +{ + return idb_transaction_id_; +} + +void RendererWebIDBTransactionImpl::setCallbacks( + WebIDBTransactionCallbacks* callbacks) +{ + IndexedDBDispatcher* dispatcher = + RenderThread::current()->indexed_db_dispatcher(); + dispatcher->RequestIDBTransactionSetCallbacks(callbacks); +} diff --git a/chrome/renderer/renderer_webidbtransaction_impl.h b/chrome/renderer/renderer_webidbtransaction_impl.h new file mode 100644 index 0000000..4369104 --- /dev/null +++ b/chrome/renderer/renderer_webidbtransaction_impl.h @@ -0,0 +1,33 @@ +// Copyright (c) 2010 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 CHROME_RENDERER_RENDERER_WEBIDBTRANSACTION_IMPL_H_ +#define CHROME_RENDERER_RENDERER_WEBIDBTRANSACTION_IMPL_H_ +#pragma once + +#include "base/basictypes.h" +#include "third_party/WebKit/WebKit/chromium/public/WebIDBTransaction.h" + +namespace WebKit { +class WebIDBObjectStore; +class WebIDBTransactionCallbacks; +class WebString; +} + +class RendererWebIDBTransactionImpl : public WebKit::WebIDBTransaction { + public: + explicit RendererWebIDBTransactionImpl(int32 idb_transaction_id); + virtual ~RendererWebIDBTransactionImpl(); + + virtual int mode() const; + virtual WebKit::WebIDBObjectStore* objectStore(const WebKit::WebString& name); + virtual void abort(); + virtual int id() const; + virtual void setCallbacks(WebKit::WebIDBTransactionCallbacks*); + + private: + int32 idb_transaction_id_; +}; + +#endif // CHROME_RENDERER_RENDERER_WEBIDBTRANSACTION_IMPL_H_ |