| Differences between
and this patch
- Source/WebKit/ChangeLog +27 lines
Lines 1-3 Source/WebKit/ChangeLog_sec1
1
2019-05-09  Alex Christensen  <achristensen@webkit.org>
2
3
        Remove now-unnecessary Connection::sendMessageWithReply
4
        https://bugs.webkit.org/show_bug.cgi?id=197747
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        The WebProcess messages that use it already do the right thing with CompletionHandlers and can be replaced by sendWithAsyncReply.
9
        The SecItemShim message that uses it can be replaced by sendSync.
10
11
        This patch only increases responsiveness when clearing website data and removes the need for a WorkQueue dedicated entirely to the SecItemShim.
12
13
        * Platform/IPC/Connection.cpp:
14
        (IPC::Connection::sendMessageWithReply): Deleted.
15
        * Platform/IPC/Connection.h:
16
        (IPC::Connection::send):
17
        (IPC::Connection::sendWithReply): Deleted.
18
        * Shared/mac/SecItemResponseData.h:
19
        * Shared/mac/SecItemShim.cpp:
20
        (WebKit::sendSecItemRequest):
21
        (WebKit::workQueue): Deleted.
22
        * UIProcess/WebProcessProxy.cpp:
23
        (WebKit::WebProcessProxy::fetchWebsiteData):
24
        (WebKit::WebProcessProxy::deleteWebsiteData):
25
        (WebKit::WebProcessProxy::deleteWebsiteDataForOrigins):
26
        * WebProcess/WebProcess.messages.in:
27
1
2019-05-09  Daniel Bates  <dabates@apple.com>
28
2019-05-09  Daniel Bates  <dabates@apple.com>
2
29
3
        [iOS] Unable to commit search on MSN.com, qq.com, or sina.com.cn using enter key (hardware or software keyboard)
30
        [iOS] Unable to commit search on MSN.com, qq.com, or sina.com.cn using enter key (hardware or software keyboard)
- Source/WebKit/Platform/IPC/Connection.cpp -19 lines
Lines 437-461 bool Connection::sendMessage(std::unique Source/WebKit/Platform/IPC/Connection.cpp_sec1
437
    return true;
437
    return true;
438
}
438
}
439
439
440
void Connection::sendMessageWithReply(uint64_t requestID, std::unique_ptr<Encoder> encoder, FunctionDispatcher& replyDispatcher, Function<void (std::unique_ptr<Decoder>)>&& replyHandler)
441
{
442
    {
443
        std::lock_guard<Lock> lock(m_replyHandlersLock);
444
445
        if (!isValid()) {
446
            replyDispatcher.dispatch([replyHandler = WTFMove(replyHandler)] {
447
                replyHandler(nullptr);
448
            });
449
            return;
450
        }
451
452
        ASSERT(!m_replyHandlers.contains(requestID));
453
        m_replyHandlers.set(requestID, ReplyHandler { &replyDispatcher, WTFMove(replyHandler) });
454
    }
455
456
    sendMessage(WTFMove(encoder), { });
457
}
458
459
bool Connection::sendSyncReply(std::unique_ptr<Encoder> encoder)
440
bool Connection::sendSyncReply(std::unique_ptr<Encoder> encoder)
460
{
441
{
461
    return sendMessage(WTFMove(encoder), { });
442
    return sendMessage(WTFMove(encoder), { });
- Source/WebKit/Platform/IPC/Connection.h -24 lines
Lines 179-190 public: Source/WebKit/Platform/IPC/Connection.h_sec1
179
179
180
    template<typename T, typename C> void sendWithAsyncReply(T&& message, C&& completionHandler, uint64_t destinationID = 0);
180
    template<typename T, typename C> void sendWithAsyncReply(T&& message, C&& completionHandler, uint64_t destinationID = 0);
181
    template<typename T> bool send(T&& message, uint64_t destinationID, OptionSet<SendOption> sendOptions = { });
181
    template<typename T> bool send(T&& message, uint64_t destinationID, OptionSet<SendOption> sendOptions = { });
182
    template<typename T> void sendWithReply(T&& message, uint64_t destinationID, FunctionDispatcher& replyDispatcher, Function<void(Optional<typename CodingType<typename T::Reply>::Type>)>&& replyHandler);
183
    template<typename T> bool sendSync(T&& message, typename T::Reply&& reply, uint64_t destinationID, Seconds timeout = Seconds::infinity(), OptionSet<SendSyncOption> sendSyncOptions = { });
182
    template<typename T> bool sendSync(T&& message, typename T::Reply&& reply, uint64_t destinationID, Seconds timeout = Seconds::infinity(), OptionSet<SendSyncOption> sendSyncOptions = { });
184
    template<typename T> bool waitForAndDispatchImmediately(uint64_t destinationID, Seconds timeout, OptionSet<WaitForOption> waitForOptions = { });
183
    template<typename T> bool waitForAndDispatchImmediately(uint64_t destinationID, Seconds timeout, OptionSet<WaitForOption> waitForOptions = { });
185
184
186
    bool sendMessage(std::unique_ptr<Encoder>, OptionSet<SendOption> sendOptions);
185
    bool sendMessage(std::unique_ptr<Encoder>, OptionSet<SendOption> sendOptions);
187
    void sendMessageWithReply(uint64_t requestID, std::unique_ptr<Encoder>, FunctionDispatcher& replyDispatcher, Function<void(std::unique_ptr<Decoder>)>&& replyHandler);
188
    std::unique_ptr<Encoder> createSyncMessageEncoder(StringReference messageReceiverName, StringReference messageName, uint64_t destinationID, uint64_t& syncRequestID);
186
    std::unique_ptr<Encoder> createSyncMessageEncoder(StringReference messageReceiverName, StringReference messageName, uint64_t destinationID, uint64_t& syncRequestID);
189
    std::unique_ptr<Decoder> sendSyncMessage(uint64_t syncRequestID, std::unique_ptr<Encoder>, Seconds timeout, OptionSet<SendSyncOption> sendSyncOptions);
187
    std::unique_ptr<Decoder> sendSyncMessage(uint64_t syncRequestID, std::unique_ptr<Encoder>, Seconds timeout, OptionSet<SendSyncOption> sendSyncOptions);
190
    bool sendSyncReply(std::unique_ptr<Encoder>);
188
    bool sendSyncReply(std::unique_ptr<Encoder>);
Lines 434-461 void Connection::sendWithAsyncReply(T&& Source/WebKit/Platform/IPC/Connection.h_sec2
434
    });
432
    });
435
}
433
}
436
434
437
template<typename T>
438
void Connection::sendWithReply(T&& message, uint64_t destinationID, FunctionDispatcher& replyDispatcher, Function<void(Optional<typename CodingType<typename T::Reply>::Type>)>&& replyHandler)
439
{
440
    uint64_t requestID = 0;
441
    std::unique_ptr<Encoder> encoder = createSyncMessageEncoder(T::receiverName(), T::name(), destinationID, requestID);
442
443
    encoder->encode(message.arguments());
444
445
    sendMessageWithReply(requestID, WTFMove(encoder), replyDispatcher, [replyHandler = WTFMove(replyHandler)](std::unique_ptr<Decoder> decoder) {
446
        if (decoder) {
447
            Optional<typename CodingType<typename T::Reply>::Type> reply;
448
            *decoder >> reply;
449
            if (reply) {
450
                replyHandler(WTFMove(*reply));
451
                return;
452
            }
453
        }
454
455
        replyHandler(WTF::nullopt);
456
    });
457
}
458
459
template<size_t i, typename A, typename B> struct TupleMover {
435
template<size_t i, typename A, typename B> struct TupleMover {
460
    static void move(A&& a, B& b)
436
    static void move(A&& a, B& b)
461
    {
437
    {
- Source/WebKit/Shared/mac/SecItemResponseData.h -4 / +2 lines
Lines 23-30 Source/WebKit/Shared/mac/SecItemResponseData.h_sec1
23
 * THE POSSIBILITY OF SUCH DAMAGE.
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
24
 */
25
25
26
#ifndef SecItemResponseData_h
26
#pragma once
27
#define SecItemResponseData_h
28
27
29
#include <wtf/RetainPtr.h>
28
#include <wtf/RetainPtr.h>
30
29
Lines 37-42 namespace WebKit { Source/WebKit/Shared/mac/SecItemResponseData.h_sec2
37
    
36
    
38
class SecItemResponseData {
37
class SecItemResponseData {
39
public:
38
public:
39
    SecItemResponseData() = default;
40
    SecItemResponseData(OSStatus, RetainPtr<CFTypeRef>&& result);
40
    SecItemResponseData(OSStatus, RetainPtr<CFTypeRef>&& result);
41
41
42
    void encode(IPC::Encoder&) const;
42
    void encode(IPC::Encoder&) const;
Lines 51-55 private: Source/WebKit/Shared/mac/SecItemResponseData.h_sec3
51
};
51
};
52
    
52
    
53
} // namespace WebKit
53
} // namespace WebKit
54
55
#endif // SecItemResponseData_h
- Source/WebKit/Shared/mac/SecItemShim.cpp -25 / +4 lines
Lines 64-100 static WeakPtr<NetworkProcess>& globalNe Source/WebKit/Shared/mac/SecItemShim.cpp_sec1
64
    return networkProcess.get();
64
    return networkProcess.get();
65
}
65
}
66
66
67
static WorkQueue& workQueue()
68
{
69
    static WorkQueue* workQueue;
70
    static dispatch_once_t onceToken;
71
    dispatch_once(&onceToken, ^{
72
        workQueue = &WorkQueue::create("com.apple.WebKit.SecItemShim").leakRef();
73
74
    });
75
76
    return *workQueue;
77
}
78
79
static Optional<SecItemResponseData> sendSecItemRequest(SecItemRequestData::Type requestType, CFDictionaryRef query, CFDictionaryRef attributesToMatch = 0)
67
static Optional<SecItemResponseData> sendSecItemRequest(SecItemRequestData::Type requestType, CFDictionaryRef query, CFDictionaryRef attributesToMatch = 0)
80
{
68
{
81
    if (!globalNetworkProcess())
69
    if (!globalNetworkProcess())
82
        return WTF::nullopt;
70
        return WTF::nullopt;
83
71
84
    Optional<SecItemResponseData> response;
72
    SecItemResponseData response;
85
73
    if (!globalNetworkProcess()->parentProcessConnection()->sendSync(Messages::SecItemShimProxy::SecItemRequest(SecItemRequestData(requestType, query, attributesToMatch)), Messages::SecItemShimProxy::SecItemRequest::Reply(response), 0))
86
    BinarySemaphore semaphore;
74
        return WTF::nullopt;
87
88
    globalNetworkProcess()->parentProcessConnection()->sendWithReply(Messages::SecItemShimProxy::SecItemRequest(SecItemRequestData(requestType, query, attributesToMatch)), 0, workQueue(), [&response, &semaphore](auto reply) {
89
        if (reply)
90
            response = WTFMove(std::get<0>(*reply));
91
92
        semaphore.signal();
93
    });
94
95
    semaphore.wait();
96
75
97
    return response;
76
    return WTFMove(response);
98
}
77
}
99
78
100
static OSStatus webSecItemCopyMatching(CFDictionaryRef query, CFTypeRef* result)
79
static OSStatus webSecItemCopyMatching(CFDictionaryRef query, CFTypeRef* result)
- Source/WebKit/UIProcess/WebProcessProxy.cpp -9 / +4 lines
Lines 936-952 void WebProcessProxy::fetchWebsiteData(P Source/WebKit/UIProcess/WebProcessProxy.cpp_sec1
936
    auto token = throttler().backgroundActivityToken();
936
    auto token = throttler().backgroundActivityToken();
937
    RELEASE_LOG_IF(sessionID.isAlwaysOnLoggingAllowed(), ProcessSuspension, "%p - WebProcessProxy is taking a background assertion because the Web process is fetching Website data", this);
937
    RELEASE_LOG_IF(sessionID.isAlwaysOnLoggingAllowed(), ProcessSuspension, "%p - WebProcessProxy is taking a background assertion because the Web process is fetching Website data", this);
938
938
939
    connection()->sendWithReply(Messages::WebProcess::FetchWebsiteData(sessionID, dataTypes), 0, RunLoop::main(), [this, token, completionHandler = WTFMove(completionHandler), sessionID] (auto reply) mutable {
939
    connection()->sendWithAsyncReply(Messages::WebProcess::FetchWebsiteData(sessionID, dataTypes), [this, protectedThis = makeRef(*this), token, completionHandler = WTFMove(completionHandler), sessionID] (auto reply) mutable {
940
#if RELEASE_LOG_DISABLED
940
#if RELEASE_LOG_DISABLED
941
        UNUSED_PARAM(sessionID);
941
        UNUSED_PARAM(sessionID);
942
        UNUSED_PARAM(this);
942
        UNUSED_PARAM(this);
943
#endif
943
#endif
944
        if (!reply) {
944
        completionHandler(WTFMove(reply));
945
            completionHandler(WebsiteData { });
946
            return;
947
        }
948
949
        completionHandler(WTFMove(std::get<0>(*reply)));
950
        RELEASE_LOG_IF(sessionID.isAlwaysOnLoggingAllowed(), ProcessSuspension, "%p - WebProcessProxy is releasing a background assertion because the Web process is done fetching Website data", this);
945
        RELEASE_LOG_IF(sessionID.isAlwaysOnLoggingAllowed(), ProcessSuspension, "%p - WebProcessProxy is releasing a background assertion because the Web process is done fetching Website data", this);
951
    });
946
    });
952
}
947
}
Lines 958-964 void WebProcessProxy::deleteWebsiteData( Source/WebKit/UIProcess/WebProcessProxy.cpp_sec2
958
    auto token = throttler().backgroundActivityToken();
953
    auto token = throttler().backgroundActivityToken();
959
    RELEASE_LOG_IF(sessionID.isAlwaysOnLoggingAllowed(), ProcessSuspension, "%p - WebProcessProxy is taking a background assertion because the Web process is deleting Website data", this);
954
    RELEASE_LOG_IF(sessionID.isAlwaysOnLoggingAllowed(), ProcessSuspension, "%p - WebProcessProxy is taking a background assertion because the Web process is deleting Website data", this);
960
955
961
    connection()->sendWithReply(Messages::WebProcess::DeleteWebsiteData(sessionID, dataTypes, modifiedSince), 0, RunLoop::main(), [this, token, completionHandler = WTFMove(completionHandler), sessionID] (auto reply) mutable {
956
    connection()->sendWithAsyncReply(Messages::WebProcess::DeleteWebsiteData(sessionID, dataTypes, modifiedSince), [this, protectedThis = makeRef(*this), token, completionHandler = WTFMove(completionHandler), sessionID] () mutable {
962
#if RELEASE_LOG_DISABLED
957
#if RELEASE_LOG_DISABLED
963
        UNUSED_PARAM(this);
958
        UNUSED_PARAM(this);
964
        UNUSED_PARAM(sessionID);
959
        UNUSED_PARAM(sessionID);
Lines 975-981 void WebProcessProxy::deleteWebsiteDataF Source/WebKit/UIProcess/WebProcessProxy.cpp_sec3
975
    auto token = throttler().backgroundActivityToken();
970
    auto token = throttler().backgroundActivityToken();
976
    RELEASE_LOG_IF(sessionID.isAlwaysOnLoggingAllowed(), ProcessSuspension, "%p - WebProcessProxy is taking a background assertion because the Web process is deleting Website data for several origins", this);
971
    RELEASE_LOG_IF(sessionID.isAlwaysOnLoggingAllowed(), ProcessSuspension, "%p - WebProcessProxy is taking a background assertion because the Web process is deleting Website data for several origins", this);
977
972
978
    connection()->sendWithReply(Messages::WebProcess::DeleteWebsiteDataForOrigins(sessionID, dataTypes, origins), 0, RunLoop::main(), [this, token, completionHandler = WTFMove(completionHandler), sessionID] (auto reply) mutable {
973
    connection()->sendWithAsyncReply(Messages::WebProcess::DeleteWebsiteDataForOrigins(sessionID, dataTypes, origins), [this, protectedThis = makeRef(*this), token, completionHandler = WTFMove(completionHandler), sessionID] () mutable {
979
#if RELEASE_LOG_DISABLED
974
#if RELEASE_LOG_DISABLED
980
        UNUSED_PARAM(this);
975
        UNUSED_PARAM(this);
981
        UNUSED_PARAM(sessionID);
976
        UNUSED_PARAM(sessionID);
- Source/WebKit/WebProcess/WebProcess.messages.in -3 / +3 lines
Lines 78-86 messages -> WebProcess LegacyReceiver { Source/WebKit/WebProcess/WebProcess.messages.in_sec1
78
78
79
    ReleasePageCache()
79
    ReleasePageCache()
80
80
81
    FetchWebsiteData(PAL::SessionID sessionID, OptionSet<WebKit::WebsiteDataType> websiteDataTypes) -> (struct WebKit::WebsiteData websiteData) Synchronous
81
    FetchWebsiteData(PAL::SessionID sessionID, OptionSet<WebKit::WebsiteDataType> websiteDataTypes) -> (struct WebKit::WebsiteData websiteData) Async
82
    DeleteWebsiteData(PAL::SessionID sessionID, OptionSet<WebKit::WebsiteDataType> websiteDataTypes, WallTime modifiedSince) -> () Synchronous
82
    DeleteWebsiteData(PAL::SessionID sessionID, OptionSet<WebKit::WebsiteDataType> websiteDataTypes, WallTime modifiedSince) -> () Async
83
    DeleteWebsiteDataForOrigins(PAL::SessionID sessionID, OptionSet<WebKit::WebsiteDataType> websiteDataTypes, Vector<WebCore::SecurityOriginData> origins) -> () Synchronous
83
    DeleteWebsiteDataForOrigins(PAL::SessionID sessionID, OptionSet<WebKit::WebsiteDataType> websiteDataTypes, Vector<WebCore::SecurityOriginData> origins) -> () Async
84
84
85
    SetHiddenPageDOMTimerThrottlingIncreaseLimit(int milliseconds)
85
    SetHiddenPageDOMTimerThrottlingIncreaseLimit(int milliseconds)
86
#if PLATFORM(COCOA)
86
#if PLATFORM(COCOA)

Return to Bug 197747