Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3861)

Unified Diff: chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h

Issue 5680007: Make IndexedDBDispatcherHost be a message filter and move its messages into a... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h
===================================================================
--- chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h (revision 69028)
+++ chrome/browser/in_process_webkit/indexed_db_dispatcher_host.h (working copy)
@@ -8,21 +8,21 @@
#include "base/basictypes.h"
#include "base/id_map.h"
-#include "base/process.h"
-#include "base/ref_counted.h"
+#include "chrome/browser/browser_message_filter.h"
#include "chrome/browser/in_process_webkit/webkit_context.h"
-#include "ipc/ipc_message.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebExceptionCode.h"
class HostContentSettingsMap;
class IndexedDBKey;
+class NullableString16;
class Profile;
class SerializedScriptValue;
-struct ViewHostMsg_IDBDatabaseCreateObjectStore_Params;
-struct ViewHostMsg_IDBFactoryOpen_Params;
-struct ViewHostMsg_IDBIndexOpenCursor_Params;
-struct ViewHostMsg_IDBObjectStoreCreateIndex_Params;
-struct ViewHostMsg_IDBObjectStoreOpenCursor_Params;
-struct ViewHostMsg_IDBObjectStorePut_Params;
+struct IndexedDBHostMsg_DatabaseCreateObjectStore_Params;
+struct IndexedDBHostMsg_FactoryOpen_Params;
+struct IndexedDBHostMsg_IndexOpenCursor_Params;
+struct IndexedDBHostMsg_ObjectStoreCreateIndex_Params;
+struct IndexedDBHostMsg_ObjectStoreOpenCursor_Params;
+struct IndexedDBHostMsg_ObjectStorePut_Params;
namespace WebKit {
class WebIDBCursor;
@@ -33,26 +33,18 @@
}
// Handles all IndexedDB related messages from a particular renderer process.
-class IndexedDBDispatcherHost
- : public base::RefCountedThreadSafe<IndexedDBDispatcherHost> {
+class IndexedDBDispatcherHost : public BrowserMessageFilter {
public:
// Only call the constructor from the UI thread.
- IndexedDBDispatcherHost(IPC::Message::Sender* sender, Profile* profile);
+ IndexedDBDispatcherHost(int process_id, Profile* profile);
- // Only call from ResourceMessageFilter on the IO thread.
- void Init(int process_id, base::ProcessHandle process_handle);
+ // BrowserMessageFilter implementation.
+ virtual void OnChannelClosing();
+ virtual void OverrideThreadForMessage(const IPC::Message& message,
+ BrowserThread::ID* thread);
+ virtual bool OnMessageReceived(const IPC::Message& message,
+ bool* message_was_ok);
- // Only call from ResourceMessageFilter on the IO thread. Calls self on the
- // WebKit thread in some cases.
- void Shutdown();
-
- // Only call from ResourceMessageFilter on the IO thread.
- bool OnMessageReceived(const IPC::Message& message);
-
- // Send a message to the renderer process associated with our sender_ via the
- // IO thread. May be called from any thread.
- void Send(IPC::Message* message);
-
// A shortcut for accessing our context.
IndexedDBContext* Context() {
return webkit_context_->indexed_db_context();
@@ -67,24 +59,22 @@
int32 Add(WebKit::WebIDBTransaction* idb_transaction);
private:
- friend class base::RefCountedThreadSafe<IndexedDBDispatcherHost>;
~IndexedDBDispatcherHost();
// Message processing. Most of the work is delegated to the dispatcher hosts
// below.
- void OnMessageReceivedWebKit(const IPC::Message& message);
- void OnIDBFactoryOpen(const ViewHostMsg_IDBFactoryOpen_Params& p);
+ void OnIDBFactoryOpen(const IndexedDBHostMsg_FactoryOpen_Params& p);
// Helper templates.
template <class ReturnType>
ReturnType* GetOrTerminateProcess(
IDMap<ReturnType, IDMapOwnPointer>* map, int32 return_object_id,
- IPC::Message* reply_msg, uint32 message_type);
+ uint32 message_type);
template <typename ReplyType, typename MessageType,
typename WebObjectType, typename Method>
void SyncGetter(IDMap<WebObjectType, IDMapOwnPointer>* map, int32 object_id,
- IPC::Message* reply_msg, Method method);
+ ReplyType* reply, Method method);
template <typename ObjectType>
void DestroyObject(IDMap<ObjectType, IDMapOwnPointer>* map, int32 object_id,
@@ -98,24 +88,26 @@
bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok);
void Send(IPC::Message* message);
- void OnName(int32 idb_database_id, IPC::Message* reply_msg);
- void OnVersion(int32 idb_database_id, IPC::Message* reply_msg);
- void OnObjectStoreNames(int32 idb_database_id, IPC::Message* reply_msg);
+ void OnName(int32 idb_database_id, string16* name);
+ void OnVersion(int32 idb_database_id, string16* version);
+ void OnObjectStoreNames(int32 idb_database_id,
+ std::vector<string16>* object_stores);
void OnCreateObjectStore(
- const ViewHostMsg_IDBDatabaseCreateObjectStore_Params& params,
- IPC::Message* reply_msg);
+ const IndexedDBHostMsg_DatabaseCreateObjectStore_Params& params,
+ int32* object_store_id, WebKit::WebExceptionCode* ec);
void OnDeleteObjectStore(int32 idb_database_id,
const string16& name,
int32 transaction_id,
- IPC::Message* reply_msg);
+ WebKit::WebExceptionCode* ec);
void OnSetVersion(int32 idb_database_id,
int32 response_id,
const string16& version,
- IPC::Message* reply_msg);
+ WebKit::WebExceptionCode* ec);
void OnTransaction(int32 idb_database_id,
const std::vector<string16>& names,
int32 mode, int32 timeout,
- IPC::Message* reply_msg);
+ int32* idb_transaction_id,
+ WebKit::WebExceptionCode* ec);
void OnDestroyed(int32 idb_database_id);
IndexedDBDispatcherHost* parent_;
@@ -130,25 +122,25 @@
bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok);
void Send(IPC::Message* message);
- void OnName(int32 idb_index_id, IPC::Message* reply_msg);
- void OnStoreName(int32 idb_index_id, IPC::Message* reply_msg);
- void OnKeyPath(int32 idb_index_id, IPC::Message* reply_msg);
- void OnUnique(int32 idb_index_id, IPC::Message* reply_msg);
+ void OnName(int32 idb_index_id, string16* name);
+ void OnStoreName(int32 idb_index_id, string16* store_name);
+ void OnKeyPath(int32 idb_index_id, NullableString16* key_path);
+ void OnUnique(int32 idb_index_id, bool* unique);
void OnOpenObjectCursor(
- const ViewHostMsg_IDBIndexOpenCursor_Params& params,
- IPC::Message* reply_msg);
- void OnOpenKeyCursor(const ViewHostMsg_IDBIndexOpenCursor_Params& params,
- IPC::Message* reply_msg);
+ const IndexedDBHostMsg_IndexOpenCursor_Params& params,
+ WebKit::WebExceptionCode* ec);
+ void OnOpenKeyCursor(const IndexedDBHostMsg_IndexOpenCursor_Params& params,
+ WebKit::WebExceptionCode* ec);
void OnGetObject(int idb_index_id,
int32 response_id,
const IndexedDBKey& key,
int32 transaction_id,
- IPC::Message* reply_msg);
+ WebKit::WebExceptionCode* ec);
void OnGetKey(int idb_index_id,
int32 response_id,
const IndexedDBKey& key,
int32 transaction_id,
- IPC::Message* reply_msg);
+ WebKit::WebExceptionCode* ec);
void OnDestroyed(int32 idb_index_id);
IndexedDBDispatcherHost* parent_;
@@ -163,34 +155,37 @@
bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok);
void Send(IPC::Message* message);
- void OnName(int32 idb_object_store_id, IPC::Message* reply_msg);
- void OnKeyPath(int32 idb_object_store_id, IPC::Message* reply_msg);
- void OnIndexNames(int32 idb_object_store_id, IPC::Message* reply_msg);
+ void OnName(int32 idb_object_store_id, string16* name);
+ void OnKeyPath(int32 idb_object_store_id, NullableString16* keyPath);
+ void OnIndexNames(int32 idb_object_store_id,
+ std::vector<string16>* index_names);
void OnGet(int idb_object_store_id,
int32 response_id,
const IndexedDBKey& key,
int32 transaction_id,
- IPC::Message* reply_msg);
- void OnPut(const ViewHostMsg_IDBObjectStorePut_Params& params,
- IPC::Message* reply_msg);
+ WebKit::WebExceptionCode* ec);
+ void OnPut(const IndexedDBHostMsg_ObjectStorePut_Params& params,
+ WebKit::WebExceptionCode* ec);
void OnDelete(int idb_object_store_id,
int32 response_id,
const IndexedDBKey& key,
int32 transaction_id,
- IPC::Message* reply_msg);
+ WebKit::WebExceptionCode* ec);
void OnCreateIndex(
- const ViewHostMsg_IDBObjectStoreCreateIndex_Params& params,
- IPC::Message* reply_msg);
+ const IndexedDBHostMsg_ObjectStoreCreateIndex_Params& params,
+ int32* index_id,
+ WebKit::WebExceptionCode* ec);
void OnIndex(int32 idb_object_store_id,
const string16& name,
- IPC::Message* reply_msg);
+ int32* idb_index_id,
+ WebKit::WebExceptionCode* ec);
void OnDeleteIndex(int32 idb_object_store_id,
const string16& name,
int32 transaction_id,
- IPC::Message* reply_msg);
+ WebKit::WebExceptionCode* ec);
void OnOpenCursor(
- const ViewHostMsg_IDBObjectStoreOpenCursor_Params& params,
- IPC::Message* reply_msg);
+ const IndexedDBHostMsg_ObjectStoreOpenCursor_Params& params,
+ WebKit::WebExceptionCode* ec);
void OnDestroyed(int32 idb_object_store_id);
IndexedDBDispatcherHost* parent_;
@@ -205,20 +200,22 @@
bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok);
void Send(IPC::Message* message);
- void OnDirection(int32 idb_object_store_id, IPC::Message* reply_msg);
- void OnKey(int32 idb_object_store_id, IPC::Message* reply_msg);
- void OnValue(int32 idb_object_store_id, IPC::Message* reply_msg);
+ void OnDirection(int32 idb_object_store_id, int32* direction);
+ void OnKey(int32 idb_object_store_id, IndexedDBKey* key);
+ void OnValue(int32 idb_object_store_id,
+ SerializedScriptValue* script_value,
+ IndexedDBKey* key);
void OnUpdate(int32 idb_object_store_id,
int32 response_id,
const SerializedScriptValue& value,
- IPC::Message* reply_msg);
+ WebKit::WebExceptionCode* ec);
void OnContinue(int32 idb_object_store_id,
int32 response_id,
const IndexedDBKey& key,
- IPC::Message* reply_msg);
+ WebKit::WebExceptionCode* ec);
void OnDelete(int32 idb_object_store_id,
int32 response_id,
- IPC::Message* reply_msg);
+ WebKit::WebExceptionCode* ec);
void OnDestroyed(int32 idb_cursor_id);
IndexedDBDispatcherHost* parent_;
@@ -235,10 +232,11 @@
// TODO: add the rest of the transaction methods.
void OnAbort(int32 transaction_id);
- void OnMode(int32 transaction_id, IPC::Message* reply_msg);
+ void OnMode(int32 transaction_id, int* mode);
void OnObjectStore(int32 transaction_id,
const string16& name,
- IPC::Message* reply_msg);
+ int32* object_store_id,
+ WebKit::WebExceptionCode* ec);
void OnDidCompleteTaskEvents(int transaction_id);
void OnDestroyed(int32 idb_transaction_id);
@@ -247,9 +245,6 @@
MapType map_;
};
- // Only use on the IO thread.
- IPC::Message::Sender* sender_;
-
// Data shared between renderer processes with the same profile.
scoped_refptr<WebKitContext> webkit_context_;
@@ -263,10 +258,6 @@
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.
- base::ProcessHandle process_handle_;
-
// Used to dispatch messages to the correct view host.
int process_id_;

Powered by Google App Engine
This is Rietveld 408576698