Skip to content
Permalink
Browse files
Add a synchronous GetValues message to StorageManager
https://bugs.webkit.org/show_bug.cgi?id=109968

Reviewed by Sam Weinig.

* Platform/CoreIPC/Connection.cpp:
(CoreIPC::Connection::dispatchWorkQueueMessageReceiverMessage):
Handle synchronous messages.

(CoreIPC::Connection::processIncomingMessage):
Check for work queue message receivers before doing any other processing.

* UIProcess/Storage/StorageManager.cpp:
(WebKit::StorageManager::getValues):
Add empty stub.

* UIProcess/Storage/StorageManager.h:
* UIProcess/Storage/StorageManager.messages.in:
Add GetValues message.

* WebProcess/Storage/StorageAreaProxy.cpp:
(WebKit::StorageAreaProxy::loadValuesIfNeeded):
Send the GetValues message.

Canonical link: https://commits.webkit.org/128263@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@143050 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Anders Carlsson committed Feb 15, 2013
1 parent b27e295 commit 0452802ebe1f58b1c2e1d26d41b2eb802b5b2b6e
Showing 6 changed files with 72 additions and 13 deletions.
@@ -1,3 +1,29 @@
2013-02-15 Anders Carlsson <andersca@apple.com>

Add a synchronous GetValues message to StorageManager
https://bugs.webkit.org/show_bug.cgi?id=109968

Reviewed by Sam Weinig.

* Platform/CoreIPC/Connection.cpp:
(CoreIPC::Connection::dispatchWorkQueueMessageReceiverMessage):
Handle synchronous messages.

(CoreIPC::Connection::processIncomingMessage):
Check for work queue message receivers before doing any other processing.

* UIProcess/Storage/StorageManager.cpp:
(WebKit::StorageManager::getValues):
Add empty stub.

* UIProcess/Storage/StorageManager.h:
* UIProcess/Storage/StorageManager.messages.in:
Add GetValues message.

* WebProcess/Storage/StorageAreaProxy.cpp:
(WebKit::StorageAreaProxy::loadValuesIfNeeded):
Send the GetValues message.

2013-02-15 Anders Carlsson <andersca@apple.com>

A storage area should know its storage type
@@ -285,10 +285,29 @@ void Connection::dispatchWorkQueueMessageReceiverMessage(WorkQueueMessageReceive
{
OwnPtr<MessageDecoder> decoder = adoptPtr(incomingMessageDecoder);

// FIXME: Handle sync messages.
ASSERT(!decoder->isSyncMessage());
if (!decoder->isSyncMessage()) {
workQueueMessageReceiver->didReceiveMessage(this, *decoder);
return;
}

uint64_t syncRequestID = 0;
if (!decoder->decode(syncRequestID) || !syncRequestID) {
// We received an invalid sync message.
// FIXME: Handle this.
decoder->markInvalid();
return;
}

workQueueMessageReceiver->didReceiveMessage(this, *decoder);
OwnPtr<MessageEncoder> replyEncoder = MessageEncoder::create("IPC", "SyncMessageReply", syncRequestID);

// Hand off both the decoder and encoder to the work queue message receiver.
workQueueMessageReceiver->didReceiveSyncMessage(this, *decoder, replyEncoder);

// FIXME: If the message was invalid, we should send back a SyncMessageError.
ASSERT(!decoder->isInvalid());

if (replyEncoder)
sendSyncReply(replyEncoder.release());
}

void Connection::setDidCloseOnConnectionWorkQueueCallback(DidCloseOnConnectionWorkQueueCallback callback)
@@ -593,6 +612,13 @@ void Connection::processIncomingMessage(PassOwnPtr<MessageDecoder> incomingMessa
return;
}

// Check if any work queue message receivers are interested in this message.
HashMap<StringReference, std::pair<RefPtr<WorkQueue>, RefPtr<WorkQueueMessageReceiver> > >::const_iterator it = m_workQueueMessageReceivers.find(message->messageReceiverName());
if (it != m_workQueueMessageReceivers.end()) {
it->value.first->dispatch(bind(&Connection::dispatchWorkQueueMessageReceiverMessage, this, it->value.second, message.release().leakPtr()));
return;
}

// Check if this is a sync message or if it's a message that should be dispatched even when waiting for
// a sync reply. If it is, and we're waiting for a sync reply this message needs to be dispatched.
// If we don't we'll end up with a deadlock where both sync message senders are stuck waiting for a reply.
@@ -613,13 +639,6 @@ void Connection::processIncomingMessage(PassOwnPtr<MessageDecoder> incomingMessa
}
}

// Check if any work queue message receivers are interested in this message.
HashMap<StringReference, std::pair<RefPtr<WorkQueue>, RefPtr<WorkQueueMessageReceiver> > >::const_iterator it = m_workQueueMessageReceivers.find(message->messageReceiverName());
if (it != m_workQueueMessageReceivers.end()) {
it->value.first->dispatch(bind(&Connection::dispatchWorkQueueMessageReceiverMessage, this, it->value.second, message.release().leakPtr()));
return;
}

enqueueIncomingMessage(message.release());
}

@@ -66,4 +66,9 @@ void StorageManager::destroyStorageArea(uint64_t)
{
}

void StorageManager::getValues(uint64_t, HashMap<String, String>&)
{
// FIXME: Implement this.
}

} // namespace WebKit
@@ -29,6 +29,7 @@
#include "Connection.h"
#include <wtf/PassRefPtr.h>
#include <wtf/ThreadSafeRefCounted.h>
#include <wtf/text/StringHash.h>

class WorkQueue;

@@ -50,10 +51,12 @@ class StorageManager : public CoreIPC::Connection::WorkQueueMessageReceiver {

// CoreIPC::Connection::WorkQueueMessageReceiver.
virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&) OVERRIDE;
virtual void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&, OwnPtr<CoreIPC::MessageEncoder>& replyEncoder) OVERRIDE;

// Message handlers.
void createStorageArea(uint64_t storageAreaID, uint64_t storageNamespaceID, const SecurityOriginData&);
void destroyStorageArea(uint64_t storageAreaID);
void getValues(uint64_t storageAreaID, HashMap<String, String>& values);

RefPtr<WorkQueue> m_queue;
};
@@ -23,4 +23,6 @@
messages -> StorageManager {
CreateStorageArea(uint64_t storageAreaID, uint64_t storageNamespaceID, WebKit::SecurityOriginData securityOriginData)
DestroyStorageArea(uint64_t storageAreaID)

GetValues(uint64_t storageAreaID) -> (WTF::HashMap<WTF::String, WTF::String> values)
}
@@ -74,7 +74,6 @@ unsigned StorageAreaProxy::length(ExceptionCode& exceptionCode, Frame* sourceFra
return 0;

loadValuesIfNeeded();

return m_values->size();
}

@@ -160,8 +159,13 @@ void StorageAreaProxy::loadValuesIfNeeded()
if (m_values)
return;

// FIXME: Actually load the values.
m_values = adoptPtr(new HashMap<String, String>());
HashMap<String, String> values;
// FIXME: This should use a special sendSync flag to indicate that we don't want to process incoming messages while waiting for a reply.
// (This flag does not yet exist).
WebProcess::shared().connection()->sendSync(Messages::StorageManager::GetValues(m_storageAreaID), Messages::StorageManager::GetValues::Reply(values), 0);

// FIXME: Don't copy the hash map.
m_values = adoptPtr(new HashMap<String, String>(values));
}

} // namespace WebKit

0 comments on commit 0452802

Please sign in to comment.