Chromium Code Reviews| Index: content/browser/in_process_webkit/dom_storage_message_filter.cc |
| diff --git a/content/browser/in_process_webkit/dom_storage_message_filter.cc b/content/browser/in_process_webkit/dom_storage_message_filter.cc |
| index 8a327131b99001bd5d30d8ddb374605de9c8408c..50b611ea5d4175adbd3407eb32fe729a731aa1dd 100644 |
| --- a/content/browser/in_process_webkit/dom_storage_message_filter.cc |
| +++ b/content/browser/in_process_webkit/dom_storage_message_filter.cc |
| @@ -83,7 +83,8 @@ bool DOMStorageMessageFilter::OnMessageReceived(const IPC::Message& message, |
| bool* message_was_ok) { |
| bool handled = true; |
| IPC_BEGIN_MESSAGE_MAP_EX(DOMStorageMessageFilter, message, *message_was_ok) |
| - IPC_MESSAGE_HANDLER(DOMStorageHostMsg_StorageAreaId, OnStorageAreaId) |
| + IPC_MESSAGE_HANDLER_DELAY_REPLY( |
| + DOMStorageHostMsg_StorageAreaId, OnStorageAreaId) |
| IPC_MESSAGE_HANDLER(DOMStorageHostMsg_Length, OnLength) |
| IPC_MESSAGE_HANDLER(DOMStorageHostMsg_Key, OnKey) |
| IPC_MESSAGE_HANDLER(DOMStorageHostMsg_GetItem, OnGetItem) |
| @@ -100,6 +101,19 @@ void DOMStorageMessageFilter::OnDestruct() const { |
| BrowserThread::DeleteOnIOThread::Destruct(this); |
| } |
| +void DOMStorageMessageFilter::OnGotStorageArea(DOMStorageArea* storage_area, |
| + IPC::Message* reply_msg) { |
| + if (storage_area) { |
| + DOMStorageHostMsg_StorageAreaId::WriteReplyParams(reply_msg, |
| + storage_area->id()); |
| + } else { |
| + DOMStorageHostMsg_StorageAreaId::WriteReplyParams( |
| + reply_msg, |
| + DOMStorageContext::kInvalidStorageId); |
| + } |
| + Send(reply_msg); |
| +} |
| + |
| void DOMStorageMessageFilter::OverrideThreadForMessage( |
|
michaeln
2011/07/30 16:49:24
This additional thread context switching (from IO
marja
2011/08/01 09:41:27
Done.
Thanks for the tip, this made the code a lo
|
| const IPC::Message& message, |
| BrowserThread::ID* thread) { |
| @@ -109,17 +123,22 @@ void DOMStorageMessageFilter::OverrideThreadForMessage( |
| void DOMStorageMessageFilter::OnStorageAreaId(int64 namespace_id, |
| const string16& origin, |
| - int64* storage_area_id) { |
| + IPC::Message* reply_msg) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT)); |
| DOMStorageNamespace* storage_namespace = |
| Context()->GetStorageNamespace(namespace_id, true); |
| if (!storage_namespace) { |
| - *storage_area_id = DOMStorageContext::kInvalidStorageId; |
| + OnGotStorageArea(NULL, reply_msg); |
| return; |
| } |
| - DOMStorageArea* storage_area = storage_namespace->GetStorageArea(origin); |
| - *storage_area_id = storage_area->id(); |
| + DOMStorageArea* storage_area = storage_namespace->GetStorageArea(origin, |
| + this, |
| + reply_msg); |
| + if (storage_area != NULL) { |
| + OnGotStorageArea(storage_area, reply_msg); |
| + } |
| + // Else continues in OnGotStorageArea asynchronously. |
| } |
| void DOMStorageMessageFilter::OnLength(int64 storage_area_id, |