| 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..44a426724e6d3fc8cfdc53db3fff55d4f6567eae 100644
|
| --- a/content/browser/in_process_webkit/dom_storage_message_filter.cc
|
| +++ b/content/browser/in_process_webkit/dom_storage_message_filter.cc
|
| @@ -9,6 +9,7 @@
|
| #include "content/browser/in_process_webkit/dom_storage_area.h"
|
| #include "content/browser/in_process_webkit/dom_storage_context.h"
|
| #include "content/browser/in_process_webkit/dom_storage_namespace.h"
|
| +#include "content/browser/resource_context.h"
|
| #include "content/common/dom_storage_messages.h"
|
| #include "googleurl/src/gurl.h"
|
|
|
| @@ -40,8 +41,10 @@ ScopedStorageEventContext::~ScopedStorageEventContext() {
|
| }
|
|
|
| DOMStorageMessageFilter::DOMStorageMessageFilter(
|
| - int process_id, WebKitContext* webkit_context)
|
| + int process_id, WebKitContext* webkit_context,
|
| + const content::ResourceContext::ResourceContext& resource_context)
|
| : webkit_context_(webkit_context),
|
| + resource_context_(resource_context),
|
| process_id_(process_id) {
|
| }
|
|
|
| @@ -83,7 +86,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)
|
| @@ -103,23 +107,58 @@ void DOMStorageMessageFilter::OnDestruct() const {
|
| void DOMStorageMessageFilter::OverrideThreadForMessage(
|
| const IPC::Message& message,
|
| BrowserThread::ID* thread) {
|
| + if (message.type() == DOMStorageHostMsg_StorageAreaId::ID)
|
| + return;
|
| if (IPC_MESSAGE_CLASS(message) == DOMStorageMsgStart)
|
| *thread = BrowserThread::WEBKIT;
|
| }
|
|
|
| void DOMStorageMessageFilter::OnStorageAreaId(int64 namespace_id,
|
| const string16& origin,
|
| - int64* storage_area_id) {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT));
|
| + IPC::Message* reply_msg) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
|
|
| + content::ContentBrowserClient* content_browser_client =
|
| + content::GetContentClient()->browser();
|
| + bool enforce_session_only_storage =
|
| + content_browser_client->EnforceSessionOnlyStorage(
|
| + GURL(origin),
|
| + // TODO(marja): Get the first party URL
|
| + GURL(origin),
|
| + resource_context_);
|
| +
|
| + BrowserThread::PostTask(
|
| + BrowserThread::WEBKIT,
|
| + FROM_HERE,
|
| + NewRunnableMethod(
|
| + this,
|
| + &DOMStorageMessageFilter::OnStorageAreaIdOnWebKitThread,
|
| + namespace_id,
|
| + origin,
|
| + enforce_session_only_storage,
|
| + reply_msg));
|
| +}
|
| +
|
| +void DOMStorageMessageFilter::OnStorageAreaIdOnWebKitThread(
|
| + int64 namespace_id,
|
| + const string16& origin,
|
| + bool enforce_session_only_storage,
|
| + IPC::Message* reply_msg) {
|
| DOMStorageNamespace* storage_namespace =
|
| Context()->GetStorageNamespace(namespace_id, true);
|
| if (!storage_namespace) {
|
| - *storage_area_id = DOMStorageContext::kInvalidStorageId;
|
| - return;
|
| + DOMStorageHostMsg_StorageAreaId::WriteReplyParams(
|
| + reply_msg,
|
| + DOMStorageContext::kInvalidStorageId);
|
| + } else {
|
| + DOMStorageArea* storage_area =
|
| + storage_namespace->GetStorageArea(origin,
|
| + enforce_session_only_storage);
|
| + DCHECK(storage_area != NULL);
|
| + DOMStorageHostMsg_StorageAreaId::WriteReplyParams(reply_msg,
|
| + storage_area->id());
|
| }
|
| - DOMStorageArea* storage_area = storage_namespace->GetStorageArea(origin);
|
| - *storage_area_id = storage_area->id();
|
| + Send(reply_msg);
|
| }
|
|
|
| void DOMStorageMessageFilter::OnLength(int64 storage_area_id,
|
|
|