Commit ed2aa501 authored by andreip@chromium.org's avatar andreip@chromium.org

Fix compilation errors of 56862 by

- making the include path lower case in renderer_webidbransaction_impl.cc,
- adding a newline at the end of indexed_db_dispatcher.cc
- fixing the initialization order of member variables in
indexed_db_callbacks.h

Revert "Revert 56862 - Add transaction coordinator. Allow idle transactions to be aborted when their parent JS context finishes executing."

This reverts commit 6b25a433481c9127f8dbcbadc7f0685dc643d6de.

Review URL: http://codereview.chromium.org/3163028

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57042 0039d316-1c4b-4281-b951-d872f2087c98
parent 293a8fcd
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "chrome/common/serialized_script_value.h" #include "chrome/common/serialized_script_value.h"
#include "third_party/WebKit/WebKit/chromium/public/WebIDBCallbacks.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/WebIDBCursor.h"
#include "third_party/WebKit/WebKit/chromium/public/WebIDBTransactionCallbacks.h"
#include "third_party/WebKit/WebKit/chromium/public/WebIDBDatabaseError.h" #include "third_party/WebKit/WebKit/chromium/public/WebIDBDatabaseError.h"
// Template magic to figure out what message to send to the renderer based on // Template magic to figure out what message to send to the renderer based on
...@@ -158,5 +159,27 @@ class IndexedDBCallbacks<void> : public IndexedDBCallbacksBase { ...@@ -158,5 +159,27 @@ class IndexedDBCallbacks<void> : public IndexedDBCallbacksBase {
DISALLOW_IMPLICIT_CONSTRUCTORS(IndexedDBCallbacks); 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_ #endif // CHROME_BROWSER_IN_PROCESS_WEBKIT_INDEXED_DB_CALLBACKS_H_
...@@ -20,7 +20,9 @@ ...@@ -20,7 +20,9 @@
#include "third_party/WebKit/WebKit/chromium/public/WebIDBIndex.h" #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/WebIDBFactory.h"
#include "third_party/WebKit/WebKit/chromium/public/WebIDBObjectStore.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/WebSecurityOrigin.h"
#include "third_party/WebKit/WebKit/chromium/public/WebVector.h"
using WebKit::WebDOMStringList; using WebKit::WebDOMStringList;
using WebKit::WebIDBCursor; using WebKit::WebIDBCursor;
...@@ -30,8 +32,10 @@ using WebKit::WebIDBIndex; ...@@ -30,8 +32,10 @@ using WebKit::WebIDBIndex;
using WebKit::WebIDBKey; using WebKit::WebIDBKey;
using WebKit::WebIDBKeyRange; using WebKit::WebIDBKeyRange;
using WebKit::WebIDBObjectStore; using WebKit::WebIDBObjectStore;
using WebKit::WebIDBTransaction;
using WebKit::WebSecurityOrigin; using WebKit::WebSecurityOrigin;
using WebKit::WebSerializedScriptValue; using WebKit::WebSerializedScriptValue;
using WebKit::WebVector;
IndexedDBDispatcherHost::IndexedDBDispatcherHost( IndexedDBDispatcherHost::IndexedDBDispatcherHost(
IPC::Message::Sender* sender, WebKitContext* webkit_context) IPC::Message::Sender* sender, WebKitContext* webkit_context)
...@@ -45,6 +49,8 @@ IndexedDBDispatcherHost::IndexedDBDispatcherHost( ...@@ -45,6 +49,8 @@ IndexedDBDispatcherHost::IndexedDBDispatcherHost(
new ObjectStoreDispatcherHost(this))), new ObjectStoreDispatcherHost(this))),
ALLOW_THIS_IN_INITIALIZER_LIST(cursor_dispatcher_host_( ALLOW_THIS_IN_INITIALIZER_LIST(cursor_dispatcher_host_(
new CursorDispatcherHost(this))), new CursorDispatcherHost(this))),
ALLOW_THIS_IN_INITIALIZER_LIST(transaction_dispatcher_host_(
new TransactionDispatcherHost(this))),
process_handle_(0) { process_handle_(0) {
DCHECK(sender_); DCHECK(sender_);
DCHECK(webkit_context_.get()); DCHECK(webkit_context_.get());
...@@ -92,6 +98,7 @@ bool IndexedDBDispatcherHost::OnMessageReceived(const IPC::Message& message) { ...@@ -92,6 +98,7 @@ bool IndexedDBDispatcherHost::OnMessageReceived(const IPC::Message& message) {
case ViewHostMsg_IDBCursorKey::ID: case ViewHostMsg_IDBCursorKey::ID:
case ViewHostMsg_IDBCursorValue::ID: case ViewHostMsg_IDBCursorValue::ID:
case ViewHostMsg_IDBFactoryOpen::ID: case ViewHostMsg_IDBFactoryOpen::ID:
case ViewHostMsg_IDBFactoryAbortPendingTransactions::ID:
case ViewHostMsg_IDBDatabaseName::ID: case ViewHostMsg_IDBDatabaseName::ID:
case ViewHostMsg_IDBDatabaseDescription::ID: case ViewHostMsg_IDBDatabaseDescription::ID:
case ViewHostMsg_IDBDatabaseVersion::ID: case ViewHostMsg_IDBDatabaseVersion::ID:
...@@ -99,6 +106,7 @@ bool IndexedDBDispatcherHost::OnMessageReceived(const IPC::Message& message) { ...@@ -99,6 +106,7 @@ bool IndexedDBDispatcherHost::OnMessageReceived(const IPC::Message& message) {
case ViewHostMsg_IDBDatabaseCreateObjectStore::ID: case ViewHostMsg_IDBDatabaseCreateObjectStore::ID:
case ViewHostMsg_IDBDatabaseObjectStore::ID: case ViewHostMsg_IDBDatabaseObjectStore::ID:
case ViewHostMsg_IDBDatabaseRemoveObjectStore::ID: case ViewHostMsg_IDBDatabaseRemoveObjectStore::ID:
case ViewHostMsg_IDBDatabaseTransaction::ID:
case ViewHostMsg_IDBDatabaseDestroyed::ID: case ViewHostMsg_IDBDatabaseDestroyed::ID:
case ViewHostMsg_IDBIndexName::ID: case ViewHostMsg_IDBIndexName::ID:
case ViewHostMsg_IDBIndexKeyPath::ID: case ViewHostMsg_IDBIndexKeyPath::ID:
...@@ -115,6 +123,7 @@ bool IndexedDBDispatcherHost::OnMessageReceived(const IPC::Message& message) { ...@@ -115,6 +123,7 @@ bool IndexedDBDispatcherHost::OnMessageReceived(const IPC::Message& message) {
case ViewHostMsg_IDBObjectStoreIndex::ID: case ViewHostMsg_IDBObjectStoreIndex::ID:
case ViewHostMsg_IDBObjectStoreRemoveIndex::ID: case ViewHostMsg_IDBObjectStoreRemoveIndex::ID:
case ViewHostMsg_IDBObjectStoreDestroyed::ID: case ViewHostMsg_IDBObjectStoreDestroyed::ID:
case ViewHostMsg_IDBTransactionDestroyed::ID:
break; break;
default: default:
return false; return false;
...@@ -159,7 +168,8 @@ void IndexedDBDispatcherHost::OnMessageReceivedWebKit( ...@@ -159,7 +168,8 @@ void IndexedDBDispatcherHost::OnMessageReceivedWebKit(
database_dispatcher_host_->OnMessageReceived(message, &msg_is_ok) || database_dispatcher_host_->OnMessageReceived(message, &msg_is_ok) ||
index_dispatcher_host_->OnMessageReceived(message, &msg_is_ok) || index_dispatcher_host_->OnMessageReceived(message, &msg_is_ok) ||
object_store_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) { if (!handled) {
handled = true; handled = true;
...@@ -167,6 +177,8 @@ void IndexedDBDispatcherHost::OnMessageReceivedWebKit( ...@@ -167,6 +177,8 @@ void IndexedDBDispatcherHost::OnMessageReceivedWebKit(
IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost, message, msg_is_ok) IPC_BEGIN_MESSAGE_MAP_EX(IndexedDBDispatcherHost, message, msg_is_ok)
IPC_MESSAGE_HANDLER(ViewHostMsg_IDBFactoryOpen, IPC_MESSAGE_HANDLER(ViewHostMsg_IDBFactoryOpen,
OnIDBFactoryOpen) OnIDBFactoryOpen)
IPC_MESSAGE_HANDLER(ViewHostMsg_IDBFactoryAbortPendingTransactions,
OnIDBFactoryAbortPendingTransactions)
IPC_MESSAGE_UNHANDLED(handled = false) IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP() IPC_END_MESSAGE_MAP()
} }
...@@ -194,6 +206,11 @@ int32 IndexedDBDispatcherHost::Add(WebIDBObjectStore* idb_object_store) { ...@@ -194,6 +206,11 @@ int32 IndexedDBDispatcherHost::Add(WebIDBObjectStore* idb_object_store) {
return object_store_dispatcher_host_->map_.Add(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( void IndexedDBDispatcherHost::OnIDBFactoryOpen(
const ViewHostMsg_IDBFactoryOpen_Params& params) { const ViewHostMsg_IDBFactoryOpen_Params& params) {
// TODO(jorlow): Check the content settings map and use params.routing_id_ // TODO(jorlow): Check the content settings map and use params.routing_id_
...@@ -206,6 +223,14 @@ void IndexedDBDispatcherHost::OnIDBFactoryOpen( ...@@ -206,6 +223,14 @@ void IndexedDBDispatcherHost::OnIDBFactoryOpen(
WebSecurityOrigin::createFromDatabaseIdentifier(params.origin_), NULL); 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. // Helper templates.
// //
...@@ -277,6 +302,8 @@ bool IndexedDBDispatcherHost::DatabaseDispatcherHost::OnMessageReceived( ...@@ -277,6 +302,8 @@ bool IndexedDBDispatcherHost::DatabaseDispatcherHost::OnMessageReceived(
OnObjectStore) OnObjectStore)
IPC_MESSAGE_HANDLER(ViewHostMsg_IDBDatabaseRemoveObjectStore, IPC_MESSAGE_HANDLER(ViewHostMsg_IDBDatabaseRemoveObjectStore,
OnRemoveObjectStore) OnRemoveObjectStore)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_IDBDatabaseTransaction,
OnTransaction)
IPC_MESSAGE_HANDLER(ViewHostMsg_IDBDatabaseDestroyed, OnDestroyed) IPC_MESSAGE_HANDLER(ViewHostMsg_IDBDatabaseDestroyed, OnDestroyed)
IPC_MESSAGE_UNHANDLED(handled = false) IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP() IPC_END_MESSAGE_MAP()
...@@ -368,6 +395,31 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnRemoveObjectStore( ...@@ -368,6 +395,31 @@ void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnRemoveObjectStore(
name, new IndexedDBCallbacks<WebIDBObjectStore>(parent_, response_id)); 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( void IndexedDBDispatcherHost::DatabaseDispatcherHost::OnDestroyed(
int32 object_id) { int32 object_id) {
parent_->DestroyObject(&map_, object_id, parent_->DestroyObject(&map_, object_id,
...@@ -615,6 +667,7 @@ bool IndexedDBDispatcherHost::CursorDispatcherHost::OnMessageReceived( ...@@ -615,6 +667,7 @@ bool IndexedDBDispatcherHost::CursorDispatcherHost::OnMessageReceived(
return handled; return handled;
} }
void IndexedDBDispatcherHost::CursorDispatcherHost::Send( void IndexedDBDispatcherHost::CursorDispatcherHost::Send(
IPC::Message* message) { IPC::Message* message) {
// The macro magic in OnMessageReceived requires this to link, but it should // The macro magic in OnMessageReceived requires this to link, but it should
...@@ -682,3 +735,41 @@ void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed( ...@@ -682,3 +735,41 @@ void IndexedDBDispatcherHost::CursorDispatcherHost::OnDestroyed(
parent_->DestroyObject( parent_->DestroyObject(
&map_, object_id, ViewHostMsg_IDBCursorDestroyed::ID); &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);
}
...@@ -25,6 +25,7 @@ class WebIDBCursor; ...@@ -25,6 +25,7 @@ class WebIDBCursor;
class WebIDBDatabase; class WebIDBDatabase;
class WebIDBIndex; class WebIDBIndex;
class WebIDBObjectStore; class WebIDBObjectStore;
class WebIDBTransaction;
} }
// Handles all IndexedDB related messages from a particular renderer process. // Handles all IndexedDB related messages from a particular renderer process.
...@@ -60,6 +61,7 @@ class IndexedDBDispatcherHost ...@@ -60,6 +61,7 @@ class IndexedDBDispatcherHost
int32 Add(WebKit::WebIDBDatabase* idb_database); int32 Add(WebKit::WebIDBDatabase* idb_database);
int32 Add(WebKit::WebIDBIndex* idb_index); int32 Add(WebKit::WebIDBIndex* idb_index);
int32 Add(WebKit::WebIDBObjectStore* idb_object_store); int32 Add(WebKit::WebIDBObjectStore* idb_object_store);
void Add(WebKit::WebIDBTransaction* idb_transaction);
private: private:
friend class base::RefCountedThreadSafe<IndexedDBDispatcherHost>; friend class base::RefCountedThreadSafe<IndexedDBDispatcherHost>;
...@@ -69,6 +71,7 @@ class IndexedDBDispatcherHost ...@@ -69,6 +71,7 @@ class IndexedDBDispatcherHost
// below. // below.
void OnMessageReceivedWebKit(const IPC::Message& message); void OnMessageReceivedWebKit(const IPC::Message& message);
void OnIDBFactoryOpen(const ViewHostMsg_IDBFactoryOpen_Params& p); void OnIDBFactoryOpen(const ViewHostMsg_IDBFactoryOpen_Params& p);
void OnIDBFactoryAbortPendingTransactions(const std::vector<int32>& ids);
// Helper templates. // Helper templates.
template <class ReturnType> template <class ReturnType>
...@@ -103,6 +106,9 @@ class IndexedDBDispatcherHost ...@@ -103,6 +106,9 @@ class IndexedDBDispatcherHost
IPC::Message* reply_msg); IPC::Message* reply_msg);
void OnRemoveObjectStore(int32 idb_database_id, int32 response_id, void OnRemoveObjectStore(int32 idb_database_id, int32 response_id,
const string16& name); 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); void OnDestroyed(int32 idb_database_id);
IndexedDBDispatcherHost* parent_; IndexedDBDispatcherHost* parent_;
...@@ -174,6 +180,22 @@ class IndexedDBDispatcherHost ...@@ -174,6 +180,22 @@ class IndexedDBDispatcherHost
IndexedDBDispatcherHost* parent_; IndexedDBDispatcherHost* parent_;
IDMap<WebKit::WebIDBCursor, IDMapOwnPointer> map_; 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. // Only use on the IO thread.
IPC::Message::Sender* sender_; IPC::Message::Sender* sender_;
...@@ -185,6 +207,8 @@ class IndexedDBDispatcherHost ...@@ -185,6 +207,8 @@ class IndexedDBDispatcherHost
scoped_ptr<IndexDispatcherHost> index_dispatcher_host_; scoped_ptr<IndexDispatcherHost> index_dispatcher_host_;
scoped_ptr<ObjectStoreDispatcherHost> object_store_dispatcher_host_; scoped_ptr<ObjectStoreDispatcherHost> object_store_dispatcher_host_;
scoped_ptr<CursorDispatcherHost> cursor_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 // If we get a corrupt message from a renderer, we need to kill it using this
// handle. // handle.
......
...@@ -167,12 +167,14 @@ ...@@ -167,12 +167,14 @@
'renderer/renderer_webidbcursor_impl.h', 'renderer/renderer_webidbcursor_impl.h',
'renderer/renderer_webidbdatabase_impl.cc', 'renderer/renderer_webidbdatabase_impl.cc',
'renderer/renderer_webidbdatabase_impl.h', 'renderer/renderer_webidbdatabase_impl.h',
'renderer/renderer_webidbfactory_impl.cc',
'renderer/renderer_webidbfactory_impl.h',
'renderer/renderer_webidbindex_impl.cc', 'renderer/renderer_webidbindex_impl.cc',
'renderer/renderer_webidbindex_impl.h', 'renderer/renderer_webidbindex_impl.h',
'renderer/renderer_webidbobjectstore_impl.cc', 'renderer/renderer_webidbobjectstore_impl.cc',
'renderer/renderer_webidbobjectstore_impl.h', 'renderer/renderer_webidbobjectstore_impl.h',
'renderer/renderer_webidbfactory_impl.cc', 'renderer/renderer_webidbtransaction_impl.cc',
'renderer/renderer_webidbfactory_impl.h', 'renderer/renderer_webidbtransaction_impl.h',
'renderer/renderer_webkitclient_impl.cc', 'renderer/renderer_webkitclient_impl.cc',
'renderer/renderer_webkitclient_impl.h', 'renderer/renderer_webkitclient_impl.h',
'renderer/renderer_webstoragearea_impl.cc', 'renderer/renderer_webstoragearea_impl.cc',
......
...@@ -874,6 +874,10 @@ IPC_BEGIN_MESSAGES(View) ...@@ -874,6 +874,10 @@ IPC_BEGIN_MESSAGES(View)
int /* code */, int /* code */,
string16 /* message */) string16 /* message */)
// IDBTransactionCallback message handlers.
IPC_MESSAGE_CONTROL1(ViewMsg_IDBTransactionCallbacksAbort,
int /* transaction_id */)
#if defined(IPC_MESSAGE_LOG_ENABLED) #if defined(IPC_MESSAGE_LOG_ENABLED)
// Tell the renderer process to begin or end IPC message logging. // Tell the renderer process to begin or end IPC message logging.
IPC_MESSAGE_CONTROL1(ViewMsg_SetIPCLoggingEnabled, IPC_MESSAGE_CONTROL1(ViewMsg_SetIPCLoggingEnabled,
...@@ -2286,6 +2290,10 @@ IPC_BEGIN_MESSAGES(ViewHost) ...@@ -2286,6 +2290,10 @@ IPC_BEGIN_MESSAGES(ViewHost)
IPC_MESSAGE_CONTROL1(ViewHostMsg_IDBFactoryOpen, IPC_MESSAGE_CONTROL1(ViewHostMsg_IDBFactoryOpen,
ViewHostMsg_IDBFactoryOpen_Params) ViewHostMsg_IDBFactoryOpen_Params)
// WebIDBFactory::abortPendingTransactions() message.
IPC_MESSAGE_CONTROL1(ViewHostMsg_IDBFactoryAbortPendingTransactions,
std::vector<int32> /* transaction_ids */)
// WebIDBDatabase::name() message. // WebIDBDatabase::name() message.
IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_IDBDatabaseName, IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_IDBDatabaseName,
int32, /* idb_database_id */ int32, /* idb_database_id */
...@@ -2324,6 +2332,18 @@ IPC_BEGIN_MESSAGES(ViewHost) ...@@ -2324,6 +2332,18 @@ IPC_BEGIN_MESSAGES(ViewHost)
int32, /* response_id */ int32, /* response_id */
string16 /* name */) 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. // WebIDBDatabase::~WebIDBDatabase() message.
IPC_MESSAGE_CONTROL1(ViewHostMsg_IDBDatabaseDestroyed, IPC_MESSAGE_CONTROL1(ViewHostMsg_IDBDatabaseDestroyed,
int32 /* idb_database_id */) int32 /* idb_database_id */)
...@@ -2411,6 +2431,10 @@ IPC_BEGIN_MESSAGES(ViewHost) ...@@ -2411,6 +2431,10 @@ IPC_BEGIN_MESSAGES(ViewHost)
IPC_MESSAGE_CONTROL1(ViewHostMsg_IDBCursorDestroyed, IPC_MESSAGE_CONTROL1(ViewHostMsg_IDBCursorDestroyed,
int32 /* idb_cursor_id */) 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. // Get file size in bytes. Set result to -1 if failed to get the file size.
IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_GetFileSize, IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_GetFileSize,
FilePath /* path */, FilePath /* path */,
......
...@@ -51,6 +51,8 @@ bool IndexedDBDispatcher::OnMessageReceived(const IPC::Message& msg) { ...@@ -51,6 +51,8 @@ bool IndexedDBDispatcher::OnMessageReceived(const IPC::Message& msg) {
OnSuccessSerializedScriptValue) OnSuccessSerializedScriptValue)
IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbacksError, IPC_MESSAGE_HANDLER(ViewMsg_IDBCallbacksError,
OnError) OnError)
IPC_MESSAGE_HANDLER(ViewMsg_IDBTransactionCallbacksAbort,
OnAbort)
IPC_MESSAGE_UNHANDLED(handled = false) IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP() IPC_END_MESSAGE_MAP()
return handled; return handled;
...@@ -177,6 +179,11 @@ void IndexedDBDispatcher::RequestIDBObjectStoreOpenCursor( ...@@ -177,6 +179,11 @@ void IndexedDBDispatcher::RequestIDBObjectStoreOpenCursor(
new ViewHostMsg_IDBObjectStoreOpenCursor(params)); new ViewHostMsg_IDBObjectStoreOpenCursor(params));
} }
void IndexedDBDispatcher::RequestIDBTransactionSetCallbacks(
WebKit::WebIDBTransactionCallbacks* callbacks) {
pending_transaction_callbacks_.AddWithID(callbacks, callbacks->id());
}
void IndexedDBDispatcher::OnSuccessNull(int32 response_id) { void IndexedDBDispatcher::OnSuccessNull(int32 response_id) {
WebKit::WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id); WebKit::WebIDBCallbacks* callbacks = pending_callbacks_.Lookup(response_id);
callbacks->onSuccess(); callbacks->onSuccess();
...@@ -232,3 +239,11 @@ void IndexedDBDispatcher::OnError(int32 response_id, int code, ...@@ -232,3 +239,11 @@ void IndexedDBDispatcher::OnError(int32 response_id, int code,
callbacks->onError(WebIDBDatabaseError(code, message)); callbacks->onError(WebIDBDatabaseError(code, message));
pending_callbacks_.Remove(response_id); 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);
}
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "ipc/ipc_message.h" #include "ipc/ipc_message.h"
#include "third_party/WebKit/WebKit/chromium/public/WebIDBCallbacks.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/WebIDBDatabase.h"
#include "third_party/WebKit/WebKit/chromium/public/WebIDBTransactionCallbacks.h"
class IndexedDBKey; class IndexedDBKey;
class SerializedScriptValue; class SerializedScriptValue;
...@@ -69,6 +70,9 @@ class IndexedDBDispatcher { ...@@ -69,6 +70,9 @@ class IndexedDBDispatcher {
const WebKit::WebIDBKeyRange& idb_key_range, unsigned short direction, const WebKit::WebIDBKeyRange& idb_key_range, unsigned short direction,
WebKit::WebIDBCallbacks* callbacks, int32 idb_object_store_id); WebKit::WebIDBCallbacks* callbacks, int32 idb_object_store_id);
void RequestIDBTransactionSetCallbacks(
WebKit::WebIDBTransactionCallbacks* callbacks);
private: private:
// IDBCallback message handlers. // IDBCallback message handlers.
void OnSuccessNull(int32 response_id); void OnSuccessNull(int32 response_id);
...@@ -80,10 +84,13 @@ class IndexedDBDispatcher { ...@@ -80,10 +84,13 @@ class IndexedDBDispatcher {
void OnSuccessSerializedScriptValue(int32 response_id, void OnSuccessSerializedScriptValue(int32 response_id,
const SerializedScriptValue& value); const SerializedScriptValue& value);
void OnError(int32 response_id, int code, const string16& message); 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 // Careful! WebIDBCallbacks wraps non-threadsafe data types. It must be
// destroyed and used on the same thread it was created on. // destroyed and used on the same thread it was created on.
IDMap<WebKit::WebIDBCallbacks, IDMapOwnPointer> pending_callbacks_; IDMap<WebKit::WebIDBCallbacks, IDMapOwnPointer> pending_callbacks_;
IDMap<WebKit::WebIDBTransactionCallbacks, IDMapOwnPointer>
pending_transaction_callbacks_;
DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcher); DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcher);
}; };
......
...@@ -7,11 +7,13 @@ ...@@ -7,11 +7,13 @@
#include "chrome/common/render_messages.h" #include "chrome/common/render_messages.h"
#include "chrome/renderer/render_thread.h" #include "chrome/renderer/render_thread.h"
#include "chrome/renderer/indexed_db_dispatcher.h" #include "chrome/renderer/indexed_db_dispatcher.h"
#include "chrome/renderer/renderer_webidbtransaction_impl.h"
#include "third_party/WebKit/WebKit/chromium/public/WebString.h" #include "third_party/WebKit/WebKit/chromium/public/WebString.h"
using WebKit::WebDOMStringList; using WebKit::WebDOMStringList;
using WebKit::WebFrame; using WebKit::WebFrame;
using WebKit::WebIDBCallbacks; using WebKit::WebIDBCallbacks;
using WebKit::WebIDBTransaction;
using WebKit::WebString; using WebKit::WebString;
using WebKit::WebVector; using WebKit::WebVector;
...@@ -67,3 +69,18 @@ void RendererWebIDBDatabaseImpl::createObjectStore( ...@@ -67,3 +69,18 @@ void RendererWebIDBDatabaseImpl::createObjectStore(
dispatcher->RequestIDBDatabaseCreateObjectStore( dispatcher->RequestIDBDatabaseCreateObjectStore(
name, key_path, auto_increment, callbacks, idb_database_id_); 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);
}
...@@ -14,6 +14,7 @@ namespace WebKit { ...@@ -14,6 +14,7 @@ namespace WebKit {
class WebFrame; class WebFrame;
class WebIDBCallbacks; class WebIDBCallbacks;
class WebString; class WebString;
class WebIDBTransaction;
} }
class RendererWebIDBDatabaseImpl : public WebKit::WebIDBDatabase { class RendererWebIDBDatabaseImpl : public WebKit::WebIDBDatabase {
...@@ -29,7 +30,9 @@ class RendererWebIDBDatabaseImpl : public WebKit::WebIDBDatabase { ...@@ -29,7 +30,9 @@ class RendererWebIDBDatabaseImpl : public WebKit::WebIDBDatabase {
virtual void createObjectStore( virtual void createObjectStore(
const WebKit::WebString& name, const WebKit::WebString& key_path, const WebKit::WebString& name, const WebKit::WebString& key_path,
bool auto_increment, WebKit::WebIDBCallbacks* callbacks); bool auto_increment, WebKit::WebIDBCallbacks* callbacks);
virtual WebKit::WebIDBTransaction* transaction(
const WebKit::WebDOMStringList& names,
unsigned short mode, unsigned long timeout);
private: private:
int32 idb_database_id_; int32 idb_database_id_;
}; };
......
...@@ -32,3 +32,13 @@ void RendererWebIDBFactoryImpl::open( ...@@ -32,3 +32,13 @@ void RendererWebIDBFactoryImpl::open(
dispatcher->RequestIDBFactoryOpen( dispatcher->RequestIDBFactoryOpen(
name, description, callbacks, origin.databaseIdentifier(), web_frame); 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));
}
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "third_party/WebKit/WebKit/chromium/public/WebIDBCallbacks.h" #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/WebIDBFactory.h"
#include "third_party/WebKit/WebKit/chromium/public/WebVector.h"
namespace WebKit { namespace WebKit {
class WebDOMStringList; class WebDOMStringList;
...@@ -27,6 +28,8 @@ class RendererWebIDBFactoryImpl : public WebKit::WebIDBFactory { ...@@ -27,6 +28,8 @@ class RendererWebIDBFactoryImpl : public WebKit::WebIDBFactory {
const WebKit::WebString& name, const WebKit::WebString& description, const WebKit::WebString& name, const WebKit::WebString& description,
WebKit::WebIDBCallbacks* callbacks, WebKit::WebIDBCallbacks* callbacks,
const WebKit::WebSecurityOrigin& origin, WebKit::WebFrame* web_frame); const WebKit::WebSecurityOrigin& origin, WebKit::WebFrame* web_frame);
virtual void abortPendingTransactions(
const WebKit::WebVector<int>& pendingIDs);
}; };
#endif // CHROME_RENDERER_RENDERER_WEBIDBFACTORY_IMPL_H_ #endif // CHROME_RENDERER_RENDERER_WEBIDBFACTORY_IMPL_H_
// 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);
}
// 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_
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