void NetworkProcessProxy::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageDecoder& decoder, OwnPtr<CoreIPC::MessageEncoder>& replyEncoder)
{
    if (dispatchSyncMessage(connection, decoder, replyEncoder))
        return;

    ASSERT_NOT_REACHED();
}
void NetworkProcessProxy::didReceiveSyncMessage(IPC::Connection& connection, IPC::MessageDecoder& decoder, std::unique_ptr<IPC::MessageEncoder>& replyEncoder)
{
    if (dispatchSyncMessage(connection, decoder, replyEncoder))
        return;

    ASSERT_NOT_REACHED();
}
Exemple #3
0
void Connection::dispatchMessage(std::unique_ptr<MessageDecoder> message)
{
    // If there's no client, return. We do this after calling releaseArguments so that
    // the ArgumentDecoder message will be freed.
    if (!m_client)
        return;

    m_inDispatchMessageCount++;

    if (message->shouldDispatchMessageWhenWaitingForSyncReply())
        m_inDispatchMessageMarkedDispatchWhenWaitingForSyncReplyCount++;

    bool oldDidReceiveInvalidMessage = m_didReceiveInvalidMessage;
    m_didReceiveInvalidMessage = false;

    if (message->isSyncMessage())
        dispatchSyncMessage(*message);
    else
        dispatchMessage(*message);

    m_didReceiveInvalidMessage |= message->isInvalid();
    m_inDispatchMessageCount--;

    if (message->shouldDispatchMessageWhenWaitingForSyncReply())
        m_inDispatchMessageMarkedDispatchWhenWaitingForSyncReplyCount--;

    if (m_didReceiveInvalidMessage && m_client)
        m_client->didReceiveInvalidMessage(this, message->messageReceiverName(), message->messageName());

    m_didReceiveInvalidMessage = oldDidReceiveInvalidMessage;
}
void CookieDatabaseBackingStore::sendChangesToDatabaseSynchronously()
{
    CookieLog("CookieBackingStore - sending to database immediately");
    {
        MutexLocker lock(m_mutex);
        if (m_dbTimer.started())
            m_dbTimer.stop();
    }
    dispatchSyncMessage(createMethodCallMessage(&CookieDatabaseBackingStore::invokeSendChangesToDatabase, this));
}
void WebProcessProxy::didReceiveSyncMessage(IPC::Connection* connection, IPC::MessageDecoder& decoder, std::unique_ptr<IPC::MessageEncoder>& replyEncoder)
{
    if (dispatchSyncMessage(connection, decoder, replyEncoder))
        return;

    if (m_context->dispatchSyncMessage(connection, decoder, replyEncoder))
        return;

    if (decoder.messageReceiverName() == Messages::WebProcessProxy::messageReceiverName()) {
        didReceiveSyncWebProcessProxyMessage(connection, decoder, replyEncoder);
        return;
    }

    // FIXME: Add unhandled message logging.
}
void CookieDatabaseBackingStore::openAndLoadDatabaseSynchronously(const String& cookieJar)
{
    CookieLog("CookieBackingStore - loading database into CookieManager immediately");

    if (m_db.isOpen()) {
        if (isCurrentThread())
            BlackBerry::Platform::webKitThreadMessageClient()->dispatchSyncMessage(createMethodCallMessage(&CookieManager::getBackingStoreCookies, &cookieManager()));
        else
            cookieManager().getBackingStoreCookies();
    } else {
        if (isCurrentThread())
            invokeOpen(cookieJar);
        else
            dispatchSyncMessage(createMethodCallMessage(&CookieDatabaseBackingStore::invokeOpen, this, cookieJar));
    }
}
Exemple #7
0
PassOwnPtr<ArgumentDecoder> Connection::waitForSyncReply(uint64_t syncRequestID, double timeout)
{
    double absoluteTime = currentTime() + timeout;

    bool timedOut = false;
    while (!timedOut) {
        {
            MutexLocker locker(m_syncReplyStateMutex);

            // First, check if we have any incoming sync messages that we need to process.
            Vector<IncomingMessage> syncMessagesReceivedWhileWaitingForSyncReply;
            m_syncMessagesReceivedWhileWaitingForSyncReply.swap(syncMessagesReceivedWhileWaitingForSyncReply);

            if (!syncMessagesReceivedWhileWaitingForSyncReply.isEmpty()) {
                // Make sure to unlock the mutex here because we're calling out to client code which could in turn send
                // another sync message and we don't want that to deadlock.
                m_syncReplyStateMutex.unlock();
                
                for (size_t i = 0; i < syncMessagesReceivedWhileWaitingForSyncReply.size(); ++i) {
                    IncomingMessage& message = syncMessagesReceivedWhileWaitingForSyncReply[i];
                    OwnPtr<ArgumentDecoder> arguments = message.releaseArguments();

                    dispatchSyncMessage(message.messageID(), arguments.get());
                }
                m_syncReplyStateMutex.lock();
            }

            // Second, check if there is a sync reply at the top of the stack.
            ASSERT(!m_pendingSyncReplies.isEmpty());
            
            PendingSyncReply& pendingSyncReply = m_pendingSyncReplies.last();
            ASSERT(pendingSyncReply.syncRequestID == syncRequestID);
            
            // We found the sync reply, or the connection was closed.
            if (pendingSyncReply.didReceiveReply || !m_shouldWaitForSyncReplies)
                return pendingSyncReply.releaseReplyDecoder();
        }

        // We didn't find a sync reply yet, keep waiting.
        timedOut = !m_waitForSyncReplySemaphore.wait(absoluteTime);
    }

    // We timed out.
    return 0;
}
Exemple #8
0
void Connection::dispatchMessages()
{
    Vector<IncomingMessage> incomingMessages;
    
    {
        MutexLocker locker(m_incomingMessagesLock);
        m_incomingMessages.swap(incomingMessages);
    }

    // Dispatch messages.
    for (size_t i = 0; i < incomingMessages.size(); ++i) {
        // If someone calls invalidate while we're invalidating messages, we should stop.
        if (!m_client)
            return;
        
        IncomingMessage& message = incomingMessages[i];
        OwnPtr<ArgumentDecoder> arguments = message.releaseArguments();

        m_inDispatchMessageCount++;

        bool oldDidReceiveInvalidMessage = m_didReceiveInvalidMessage;
        m_didReceiveInvalidMessage = false;

        if (message.messageID().isSync())
            dispatchSyncMessage(message.messageID(), arguments.get());
        else
            m_client->didReceiveMessage(this, message.messageID(), arguments.get());

        m_didReceiveInvalidMessage |= arguments->isInvalid();
        m_inDispatchMessageCount--;

        if (m_didReceiveInvalidMessage)
            m_client->didReceiveInvalidMessage(this, message.messageID());

        m_didReceiveInvalidMessage = oldDidReceiveInvalidMessage;
    }
}