Changeset 282230 in webkit


Ignore:
Timestamp:
Sep 9, 2021, 11:25:42 AM (4 years ago)
Author:
commit-queue@webkit.org
Message:

Add PrivateClickMeasurement daemon
https://bugs.webkit.org/show_bug.cgi?id=230052

Patch by Alex Christensen <achristensen@webkit.org> on 2021-09-09
Reviewed by Chris Dumez.

Source/WebKit:

This adds the infrastructure to use a daemon instead of the network process to handle PrivateClickMeasurement.
It does not start using the daemon yet, so there is no change in behavior.
I made a new class PCM::ManagerInterface which can either be a PrivateClickMeasurementManager or a PCM::ManagerProxy,
which would send messages to the daemon instead of doing the work locally.
I implemented the encoding and decoding of parameters using some of the IPC encoding templates.
I have an entry point for an executable but no executable yet.
I have verified that EventAttribution unit tests pass when using the daemon, so the infrastructure is good.

  • NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
  • NetworkProcess/NetworkSession.cpp:

(WebKit::NetworkSession::NetworkSession):
(WebKit::pcmStoreDirectory): Deleted.

  • NetworkProcess/NetworkSession.h:

(WebKit::NetworkSession::privateClickMeasurement):

  • NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementConnection.cpp: Added.

(WebKit::PCM::Connection::connectionToDaemon):
(WebKit::PCM::Connection::send):
(WebKit::PCM::Connection::sendWithReply):

  • NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementConnection.h: Added.
  • NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDaemonClient.cpp: Added.

(WebKit::PCM::DaemonClient::loadFromNetwork):
(WebKit::PCM::DaemonClient::broadcastConsoleMessage):
(WebKit::PCM::DaemonClient::featureEnabled const):
(WebKit::PCM::DaemonClient::debugModeEnabled const):

  • NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDaemonClient.h: Added.
  • NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDecoder.cpp: Added.

(WebKit::PCM::Decoder::bufferIsLargeEnoughToContainBytes const):
(WebKit::PCM::Decoder::decodeFixedLengthData):

  • NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDecoder.h: Added.

(WebKit::PCM::Decoder::Decoder):
(WebKit::PCM::Decoder::operator>>):
(WebKit::PCM::Decoder::bufferIsLargeEnoughToContain const):

  • NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementEncoder.cpp: Added.

(WebKit::PCM::Encoder::encodeFixedLengthData):

  • NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementEncoder.h: Added.

(WebKit::PCM::Encoder::operator<<):
(WebKit::PCM::Encoder::encode):
(WebKit::PCM::Encoder::takeBuffer):

  • NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerInterface.cpp: Added.

(WebKit::PCM::MessageInfo::toStringForTesting::encodeReply):
(WebKit::PCM::manager):
(WebKit::PCM::handlePCMMessage):
(WebKit::PCM::handlePCMMessageWithReply):
(WebKit::PCM::decodeMessageAndSendToManager):

  • NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerInterface.h: Added.
  • NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerProxy.cpp: Added.

(WebKit::PCM::sendMessage):
(WebKit::PCM::ReplyCaller<>::callReply):
(WebKit::PCM::ReplyCaller<String>::callReply):
(WebKit::PCM::sendMessageWithReply):
(WebKit::PCM::ManagerProxy::storeUnattributed):
(WebKit::PCM::ManagerProxy::handleAttribution):
(WebKit::PCM::ManagerProxy::clear):
(WebKit::PCM::ManagerProxy::clearForRegistrableDomain):
(WebKit::PCM::ManagerProxy::migratePrivateClickMeasurementFromLegacyStorage):
(WebKit::PCM::ManagerProxy::toStringForTesting const):
(WebKit::PCM::ManagerProxy::setOverrideTimerForTesting):
(WebKit::PCM::ManagerProxy::setTokenPublicKeyURLForTesting):
(WebKit::PCM::ManagerProxy::setTokenSignatureURLForTesting):
(WebKit::PCM::ManagerProxy::setAttributionReportURLsForTesting):
(WebKit::PCM::ManagerProxy::markAllUnattributedAsExpiredForTesting):
(WebKit::PCM::ManagerProxy::markAttributedPrivateClickMeasurementsAsExpiredForTesting):
(WebKit::PCM::ManagerProxy::setEphemeralMeasurementForTesting):
(WebKit::PCM::ManagerProxy::setPCMFraudPreventionValuesForTesting):
(WebKit::PCM::ManagerProxy::startTimerImmediatelyForTesting):
(WebKit::PCM::ManagerProxy::destroyStoreForTesting):

  • NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerProxy.h: Added.
  • NetworkProcess/PrivateClickMeasurement/cocoa/PrivateClickMeasurementDaemonConnectionCocoa.mm: Added.

(WebKit::PCM::Connection::Connection):
(WebKit::PCM::Connection::connectionToDaemon):
(WebKit::PCM::dictionaryFromMessage):
(WebKit::PCM::Connection::send):
(WebKit::PCM::Connection::sendWithReply):

  • NetworkProcess/PrivateClickMeasurement/cocoa/PrivateClickMeasurementXPCUtilities.h: Added.
  • NetworkProcess/PrivateClickMeasurement/cocoa/PrivateClickMeasurementXPCUtilities.mm: Added.

(WebKit::PCM::addVersionAndEncodedMessageToDictionary):

  • NetworkProcess/mac/com.apple.WebKit.NetworkProcess.sb.in:
  • Platform/IPC/ArgumentCoder.h:
  • Platform/IPC/ArgumentCoders.cpp:

(IPC::decodeStringText):
(IPC::ArgumentCoder<String>::decode):

  • Platform/IPC/ArgumentCoders.h:
  • Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonEntryPoint.h: Added.
  • Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonEntryPoint.mm: Added.

(WebKit::peers):
(WebKit::CompletionHandler<void):
(WebKit::connectionEventHandler):
(WebKit::startListeningForMachServiceConnections):
(WebKit::registerScheduledActivityHandler):
(WebKit::enterSandbox):
(WebKit::PCMDaemonMain):

  • Sources.txt:
  • SourcesCocoa.txt:
  • WebKit.xcodeproj/project.pbxproj:

Source/WTF:

  • wtf/spi/darwin/XPCSPI.h:
Location:
trunk/Source
Files:
7 added
18 edited
11 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r282221 r282230  
     12021-09-09  Alex Christensen  <achristensen@webkit.org>
     2
     3        Add PrivateClickMeasurement daemon
     4        https://bugs.webkit.org/show_bug.cgi?id=230052
     5
     6        Reviewed by Chris Dumez.
     7
     8        * wtf/spi/darwin/XPCSPI.h:
     9
    1102021-09-09  Patrick Angle  <pangle@apple.com>
    211
  • trunk/Source/WTF/wtf/spi/darwin/XPCSPI.h

    r278716 r282230  
    3737typedef xpc_object_t xpc_connection_t;
    3838typedef xpc_object_t xpc_endpoint_t;
     39typedef xpc_object_t xpc_activity_t;
    3940
    4041static ALWAYS_INLINE void _xpc_object_validate(xpc_object_t object)
     
    5152typedef void* xpc_connection_t;
    5253typedef void* xpc_endpoint_t;
     54typedef void* xpc_activity_t;
    5355
    5456#define XPC_GLOBAL_OBJECT(object) (&(object))
     
    5658#endif // OS_OBJECT_USE_OBJC
    5759
     60enum {
     61    XPC_ACTIVITY_STATE_CHECK_IN,
     62    XPC_ACTIVITY_STATE_WAIT,
     63    XPC_ACTIVITY_STATE_RUN,
     64    XPC_ACTIVITY_STATE_DEFER,
     65    XPC_ACTIVITY_STATE_CONTINUE,
     66    XPC_ACTIVITY_STATE_DONE,
     67};
     68typedef long xpc_activity_state_t;
    5869typedef const struct _xpc_type_s* xpc_type_t;
     70extern "C" const xpc_object_t XPC_ACTIVITY_CHECK_IN;
    5971
    6072#if PLATFORM(IOS_FAMILY) && __has_attribute(noescape)
     
    7284#define XPC_ARRAY_APPEND ((size_t)(-1))
    7385#define XPC_CONNECTION_MACH_SERVICE_LISTENER (1 << 0)
     86#define XPC_ERROR_CONNECTION_INTERRUPTED XPC_GLOBAL_OBJECT(_xpc_error_connection_interrupted)
    7487#define XPC_ERROR_CONNECTION_INVALID XPC_GLOBAL_OBJECT(_xpc_error_connection_invalid)
    7588#define XPC_ERROR_KEY_DESCRIPTION _xpc_error_key_description
     
    8598extern const char * const _xpc_error_key_description;
    8699
     100extern "C" void xpc_connection_activate(xpc_connection_t connection);
     101extern "C" const void* xpc_dictionary_get_data(xpc_object_t xdict, const char* key, size_t* length);
     102extern "C" xpc_object_t xpc_data_create_with_dispatch_data(dispatch_data_t ddata);
     103extern "C" xpc_activity_state_t xpc_activity_get_state(xpc_activity_t activity);
     104extern "C" xpc_object_t xpc_activity_copy_criteria(xpc_activity_t activity);
     105extern "C" void xpc_activity_set_criteria(xpc_activity_t activity, xpc_object_t criteria);
     106#if COMPILER_SUPPORTS(BLOCKS)
     107typedef void (^xpc_activity_handler_t)(xpc_activity_t activity);
     108extern "C" void xpc_activity_register(const char *identifier, xpc_object_t criteria,
     109    xpc_activity_handler_t handler);
     110#endif // COMPILER_SUPPORTS(BLOCKS)
     111
    87112#endif // PLATFORM(MAC) || USE(APPLE_INTERNAL_SDK)
    88113
     
    91116#include <xpc/private.h>
    92117#else
     118
     119extern "C" const char * const XPC_ACTIVITY_RANDOM_INITIAL_DELAY;
     120extern "C" const char * const XPC_ACTIVITY_REQUIRE_NETWORK_CONNECTIVITY;
    93121
    94122#if OS_OBJECT_USE_OBJC
     
    109137WTF_EXTERN_C_BEGIN
    110138
     139extern const struct _xpc_dictionary_s _xpc_error_connection_interrupted;
    111140extern const struct _xpc_dictionary_s _xpc_error_connection_invalid;
    112141extern const struct _xpc_dictionary_s _xpc_error_termination_imminent;
  • trunk/Source/WebKit/ChangeLog

    r282222 r282230  
     12021-09-09  Alex Christensen  <achristensen@webkit.org>
     2
     3        Add PrivateClickMeasurement daemon
     4        https://bugs.webkit.org/show_bug.cgi?id=230052
     5
     6        Reviewed by Chris Dumez.
     7
     8        This adds the infrastructure to use a daemon instead of the network process to handle PrivateClickMeasurement.
     9        It does not start using the daemon yet, so there is no change in behavior.
     10        I made a new class PCM::ManagerInterface which can either be a PrivateClickMeasurementManager or a PCM::ManagerProxy,
     11        which would send messages to the daemon instead of doing the work locally.
     12        I implemented the encoding and decoding of parameters using some of the IPC encoding templates.
     13        I have an entry point for an executable but no executable yet.
     14        I have verified that EventAttribution unit tests pass when using the daemon, so the infrastructure is good.
     15
     16        * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
     17        * NetworkProcess/NetworkSession.cpp:
     18        (WebKit::NetworkSession::NetworkSession):
     19        (WebKit::pcmStoreDirectory): Deleted.
     20        * NetworkProcess/NetworkSession.h:
     21        (WebKit::NetworkSession::privateClickMeasurement):
     22        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementConnection.cpp: Added.
     23        (WebKit::PCM::Connection::connectionToDaemon):
     24        (WebKit::PCM::Connection::send):
     25        (WebKit::PCM::Connection::sendWithReply):
     26        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementConnection.h: Added.
     27        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDaemonClient.cpp: Added.
     28        (WebKit::PCM::DaemonClient::loadFromNetwork):
     29        (WebKit::PCM::DaemonClient::broadcastConsoleMessage):
     30        (WebKit::PCM::DaemonClient::featureEnabled const):
     31        (WebKit::PCM::DaemonClient::debugModeEnabled const):
     32        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDaemonClient.h: Added.
     33        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDecoder.cpp: Added.
     34        (WebKit::PCM::Decoder::bufferIsLargeEnoughToContainBytes const):
     35        (WebKit::PCM::Decoder::decodeFixedLengthData):
     36        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDecoder.h: Added.
     37        (WebKit::PCM::Decoder::Decoder):
     38        (WebKit::PCM::Decoder::operator>>):
     39        (WebKit::PCM::Decoder::bufferIsLargeEnoughToContain const):
     40        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementEncoder.cpp: Added.
     41        (WebKit::PCM::Encoder::encodeFixedLengthData):
     42        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementEncoder.h: Added.
     43        (WebKit::PCM::Encoder::operator<<):
     44        (WebKit::PCM::Encoder::encode):
     45        (WebKit::PCM::Encoder::takeBuffer):
     46        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerInterface.cpp: Added.
     47        (WebKit::PCM::MessageInfo::toStringForTesting::encodeReply):
     48        (WebKit::PCM::manager):
     49        (WebKit::PCM::handlePCMMessage):
     50        (WebKit::PCM::handlePCMMessageWithReply):
     51        (WebKit::PCM::decodeMessageAndSendToManager):
     52        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerInterface.h: Added.
     53        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerProxy.cpp: Added.
     54        (WebKit::PCM::sendMessage):
     55        (WebKit::PCM::ReplyCaller<>::callReply):
     56        (WebKit::PCM::ReplyCaller<String>::callReply):
     57        (WebKit::PCM::sendMessageWithReply):
     58        (WebKit::PCM::ManagerProxy::storeUnattributed):
     59        (WebKit::PCM::ManagerProxy::handleAttribution):
     60        (WebKit::PCM::ManagerProxy::clear):
     61        (WebKit::PCM::ManagerProxy::clearForRegistrableDomain):
     62        (WebKit::PCM::ManagerProxy::migratePrivateClickMeasurementFromLegacyStorage):
     63        (WebKit::PCM::ManagerProxy::toStringForTesting const):
     64        (WebKit::PCM::ManagerProxy::setOverrideTimerForTesting):
     65        (WebKit::PCM::ManagerProxy::setTokenPublicKeyURLForTesting):
     66        (WebKit::PCM::ManagerProxy::setTokenSignatureURLForTesting):
     67        (WebKit::PCM::ManagerProxy::setAttributionReportURLsForTesting):
     68        (WebKit::PCM::ManagerProxy::markAllUnattributedAsExpiredForTesting):
     69        (WebKit::PCM::ManagerProxy::markAttributedPrivateClickMeasurementsAsExpiredForTesting):
     70        (WebKit::PCM::ManagerProxy::setEphemeralMeasurementForTesting):
     71        (WebKit::PCM::ManagerProxy::setPCMFraudPreventionValuesForTesting):
     72        (WebKit::PCM::ManagerProxy::startTimerImmediatelyForTesting):
     73        (WebKit::PCM::ManagerProxy::destroyStoreForTesting):
     74        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerProxy.h: Added.
     75        * NetworkProcess/PrivateClickMeasurement/cocoa/PrivateClickMeasurementDaemonConnectionCocoa.mm: Added.
     76        (WebKit::PCM::Connection::Connection):
     77        (WebKit::PCM::Connection::connectionToDaemon):
     78        (WebKit::PCM::dictionaryFromMessage):
     79        (WebKit::PCM::Connection::send):
     80        (WebKit::PCM::Connection::sendWithReply):
     81        * NetworkProcess/PrivateClickMeasurement/cocoa/PrivateClickMeasurementXPCUtilities.h: Added.
     82        * NetworkProcess/PrivateClickMeasurement/cocoa/PrivateClickMeasurementXPCUtilities.mm: Added.
     83        (WebKit::PCM::addVersionAndEncodedMessageToDictionary):
     84        * NetworkProcess/mac/com.apple.WebKit.NetworkProcess.sb.in:
     85        * Platform/IPC/ArgumentCoder.h:
     86        * Platform/IPC/ArgumentCoders.cpp:
     87        (IPC::decodeStringText):
     88        (IPC::ArgumentCoder<String>::decode):
     89        * Platform/IPC/ArgumentCoders.h:
     90        * Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonEntryPoint.h: Added.
     91        * Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonEntryPoint.mm: Added.
     92        (WebKit::peers):
     93        (WebKit::CompletionHandler<void):
     94        (WebKit::connectionEventHandler):
     95        (WebKit::startListeningForMachServiceConnections):
     96        (WebKit::registerScheduledActivityHandler):
     97        (WebKit::enterSandbox):
     98        (WebKit::PCMDaemonMain):
     99        * Sources.txt:
     100        * SourcesCocoa.txt:
     101        * WebKit.xcodeproj/project.pbxproj:
     102
    11032021-09-09  Sihui Liu  <sihui_liu@apple.com>
    2104
  • trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp

    r282006 r282230  
    3434#include "PluginProcessProxy.h"
    3535#include "PrivateClickMeasurementManager.h"
     36#include "PrivateClickMeasurementManagerProxy.h"
    3637#include "ResourceLoadStatisticsMemoryStore.h"
    3738#include "StorageAccessStatus.h"
  • trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp

    r282109 r282230  
    3838#include "PrivateClickMeasurementClientImpl.h"
    3939#include "PrivateClickMeasurementManager.h"
     40#include "PrivateClickMeasurementManagerProxy.h"
    4041#include "WebPageProxy.h"
    4142#include "WebPageProxyMessages.h"
     
    9394}
    9495
     96static UniqueRef<PCM::ManagerInterface> managerOrProxy(NetworkSession& networkSession, NetworkProcess& networkProcess, const NetworkSessionCreationParameters& parameters)
     97{
     98    // FIXME: Turn this on and remove ManagerInterface once rdar://80701098 is closed.
     99    constexpr bool usePCMDaemon = false;
     100
     101    if (usePCMDaemon)
     102        return makeUniqueRef<PCM::ManagerProxy>();
     103    return makeUniqueRef<PrivateClickMeasurementManager>(makeUniqueRef<PCM::ClientImpl>(networkSession, networkProcess), pcmStoreDirectory(networkSession, parameters.resourceLoadStatisticsParameters.directory, parameters.resourceLoadStatisticsParameters.privateClickMeasurementStorageDirectory));
     104}
     105
    95106NetworkSession::NetworkSession(NetworkProcess& networkProcess, const NetworkSessionCreationParameters& parameters)
    96107    : m_sessionID(parameters.sessionID)
    97108    , m_networkProcess(networkProcess)
    98109#if ENABLE(RESOURCE_LOAD_STATISTICS)
    99     , m_privateClickMeasurementStorageDirectory(parameters.resourceLoadStatisticsParameters.privateClickMeasurementStorageDirectory)
    100110    , m_resourceLoadStatisticsDirectory(parameters.resourceLoadStatisticsParameters.directory)
    101111    , m_shouldIncludeLocalhostInResourceLoadStatistics(parameters.resourceLoadStatisticsParameters.shouldIncludeLocalhost ? ShouldIncludeLocalhost::Yes : ShouldIncludeLocalhost::No)
     
    108118    , m_standaloneApplicationDomain(parameters.resourceLoadStatisticsParameters.standaloneApplicationDomain)
    109119#endif
     120    , m_privateClickMeasurement(managerOrProxy(*this, networkProcess, parameters))
    110121    , m_broadcastChannelRegistry(makeUniqueRef<NetworkBroadcastChannelRegistry>())
    111122    , m_testSpeedMultiplier(parameters.testSpeedMultiplier)
     
    142153    setResourceLoadStatisticsEnabled(parameters.resourceLoadStatisticsParameters.enabled);
    143154#endif
    144     m_privateClickMeasurement = makeUnique<PrivateClickMeasurementManager>(makeUniqueRef<PCM::ClientImpl>(*this, networkProcess), pcmStoreDirectory(*this, parameters.resourceLoadStatisticsParameters.directory, parameters.resourceLoadStatisticsParameters.privateClickMeasurementStorageDirectory));
    145155}
    146156
  • trunk/Source/WebKit/NetworkProcess/NetworkSession.h

    r282110 r282230  
    3030#include "NetworkResourceLoadIdentifier.h"
    3131#include "PrefetchCache.h"
     32#include "PrivateClickMeasurementManagerInterface.h"
    3233#include "SandboxExtension.h"
    3334#include "ServiceWorkerSoftUpdateLoader.h"
     
    6162class NetworkBroadcastChannelRegistry;
    6263class NetworkSocketChannel;
    63 class PrivateClickMeasurementManager;
    6464class WebPageNetworkParameters;
    6565class WebResourceLoadStatisticsStore;
     
    168168
    169169    NetworkLoadScheduler& networkLoadScheduler();
    170     PrivateClickMeasurementManager& privateClickMeasurement() { return *m_privateClickMeasurement; }
     170    PCM::ManagerInterface& privateClickMeasurement() { return m_privateClickMeasurement.get(); }
    171171
    172172#if PLATFORM(COCOA)
     
    193193    WeakHashSet<NetworkDataTask> m_dataTaskSet;
    194194#if ENABLE(RESOURCE_LOAD_STATISTICS)
    195     String m_privateClickMeasurementStorageDirectory;
    196195    String m_resourceLoadStatisticsDirectory;
    197196    RefPtr<WebResourceLoadStatisticsStore> m_resourceLoadStatistics;
     
    209208#endif
    210209    bool m_isStaleWhileRevalidateEnabled { false };
    211     std::unique_ptr<PrivateClickMeasurementManager> m_privateClickMeasurement;
     210    UniqueRef<PCM::ManagerInterface> m_privateClickMeasurement;
    212211
    213212    HashSet<Ref<NetworkResourceLoader>> m_keptAliveLoads;
  • trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementConnection.cpp

    r282226 r282230  
    11/*
    2  * Copyright (C) 2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #import "config.h"
    27 #import "LocalStorageDatabaseTracker.h"
     26#include "config.h"
     27#include "PrivateClickMeasurementConnection.h"
    2828
    29 #if PLATFORM(IOS_FAMILY)
    30 
    31 #import <WebCore/VersionChecks.h>
     29#include <WebCore/NotImplemented.h>
    3230
    3331namespace WebKit {
    3432
    35 void LocalStorageDatabaseTracker::platformMaybeExcludeFromBackup() const
     33namespace PCM {
     34
     35#if !PLATFORM(COCOA)
     36
     37Connection Connection::connectionToDaemon()
    3638{
    37     ASSERT(!RunLoop::isMain());
    38     if (m_hasExcludedFromBackup)
    39         return;
    40 
    41     m_hasExcludedFromBackup = true;
    42 
    43     [[NSURL fileURLWithPath:(NSString *)localStorageDirectory() isDirectory:YES] setResourceValue:@YES forKey:NSURLIsExcludedFromBackupKey error:nil];
     39    notImplemented();
     40    return { };
    4441}
    4542
    46 } // namespace WebKit
     43void Connection::send(MessageType, EncodedMessage&&)
     44{
     45    notImplemented();
     46}
     47
     48void Connection::sendWithReply(MessageType, EncodedMessage&&, CompletionHandler<void(EncodedMessage&&)>&& completionHandler)
     49{
     50    notImplemented();
     51    completionHandler({ });
     52}
    4753
    4854#endif
     55
     56} // namespace PCM
     57
     58} // namespace WebKit
  • trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementConnection.h

    r282226 r282230  
    11/*
    2  * Copyright (C) 2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #import "config.h"
    27 #import "LocalStorageDatabaseTracker.h"
     26#pragma once
    2827
    29 #if PLATFORM(IOS_FAMILY)
     28#include <wtf/Vector.h>
    3029
    31 #import <WebCore/VersionChecks.h>
     30#if PLATFORM(COCOA)
     31#include <wtf/OSObjectPtr.h>
     32#include <wtf/spi/darwin/XPCSPI.h>
     33#endif
    3234
    3335namespace WebKit {
    3436
    35 void LocalStorageDatabaseTracker::platformMaybeExcludeFromBackup() const
    36 {
    37     ASSERT(!RunLoop::isMain());
    38     if (m_hasExcludedFromBackup)
    39         return;
     37namespace PCM {
    4038
    41     m_hasExcludedFromBackup = true;
     39enum class MessageType : uint8_t;
     40using EncodedMessage = Vector<uint8_t>;
    4241
    43     [[NSURL fileURLWithPath:(NSString *)localStorageDirectory() isDirectory:YES] setResourceValue:@YES forKey:NSURLIsExcludedFromBackupKey error:nil];
    44 }
     42class Connection {
     43public:
     44    static Connection connectionToDaemon();
     45
     46    void send(MessageType, EncodedMessage&&);
     47    void sendWithReply(MessageType, EncodedMessage&&, CompletionHandler<void(EncodedMessage&&)>&&);
     48
     49private:
     50#if PLATFORM(COCOA)
     51    Connection(OSObjectPtr<xpc_connection_t>&&);
     52
     53    OSObjectPtr<xpc_connection_t> m_connection;
     54#endif
     55};
     56
     57} // namespace PCM
    4558
    4659} // namespace WebKit
    47 
    48 #endif
  • trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDaemonClient.cpp

    r282226 r282230  
    11/*
    2  * Copyright (C) 2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #pragma once
     26#include "config.h"
     27#include "PrivateClickMeasurementDaemonClient.h"
    2728
    28 #include <WebKit/WKBase.h>
    29 #include <WebKit/WKFoundation.h>
     29#include <WebCore/NotImplemented.h>
    3030
    31 #ifdef __cplusplus
    32 extern "C" {
    33 #endif
     31namespace WebKit {
    3432
    35 WK_EXPORT int WKXPCServiceMain(int argc, const char** argv) WK_API_AVAILABLE(macos(10.15), ios(13.0));
     33namespace PCM {
    3634
    37 #ifdef __cplusplus
     35void DaemonClient::broadcastConsoleMessage(JSC::MessageLevel, const String&)
     36{
     37    notImplemented();
    3838}
    39 #endif
     39
     40bool DaemonClient::featureEnabled() const
     41{
     42    return true;
     43}
     44
     45bool DaemonClient::debugModeEnabled() const
     46{
     47    notImplemented();
     48    return false;
     49}
     50
     51} // namespace PCM
     52
     53} // namespace WebKit
  • trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDaemonClient.h

    r282226 r282230  
    11/*
    2  * Copyright (C) 2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626#pragma once
    2727
    28 #include <WebKit/WKBase.h>
    29 #include <WebKit/WKFoundation.h>
     28#include "PrivateClickMeasurementClient.h"
     29#include <wtf/FastMalloc.h>
     30#include <wtf/WeakPtr.h>
    3031
    31 #ifdef __cplusplus
    32 extern "C" {
    33 #endif
     32namespace WebKit {
    3433
    35 WK_EXPORT int WKXPCServiceMain(int argc, const char** argv) WK_API_AVAILABLE(macos(10.15), ios(13.0));
     34namespace PCM {
    3635
    37 #ifdef __cplusplus
    38 }
    39 #endif
     36class DaemonClient : public Client, public CanMakeWeakPtr<DaemonClient> {
     37    WTF_MAKE_FAST_ALLOCATED;
     38    void broadcastConsoleMessage(JSC::MessageLevel, const String&) final;
     39    bool featureEnabled() const final;
     40    bool debugModeEnabled() const final;
     41};
     42
     43} // namespace PCM
     44
     45} // namespace WebKit
  • trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDecoder.cpp

    r282226 r282230  
    11/*
    2  * Copyright (C) 2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #import "config.h"
    27 #import "LocalStorageDatabaseTracker.h"
    28 
    29 #if PLATFORM(IOS_FAMILY)
    30 
    31 #import <WebCore/VersionChecks.h>
     26#include "config.h"
     27#include "PrivateClickMeasurementDecoder.h"
    3228
    3329namespace WebKit {
    3430
    35 void LocalStorageDatabaseTracker::platformMaybeExcludeFromBackup() const
     31namespace PCM {
     32
     33bool Decoder::bufferIsLargeEnoughToContainBytes(size_t bytes) const
    3634{
    37     ASSERT(!RunLoop::isMain());
    38     if (m_hasExcludedFromBackup)
    39         return;
    40 
    41     m_hasExcludedFromBackup = true;
    42 
    43     [[NSURL fileURLWithPath:(NSString *)localStorageDirectory() isDirectory:YES] setResourceValue:@YES forKey:NSURLIsExcludedFromBackupKey error:nil];
     35    return bytes <= m_buffer.size() - m_bufferPosition;
    4436}
    4537
     38bool Decoder::decodeFixedLengthData(uint8_t* data, size_t size, size_t)
     39{
     40    if (!bufferIsLargeEnoughToContainBytes(size))
     41        return false;
     42    memcpy(data, m_buffer.data() + m_bufferPosition, size);
     43    m_bufferPosition += size;
     44    return true;
     45}
     46
     47} // namespace PCM
     48
    4649} // namespace WebKit
    47 
    48 #endif
  • trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDecoder.h

    r282226 r282230  
    11/*
    2  * Copyright (C) 2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #import "config.h"
    27 #import "LocalStorageDatabaseTracker.h"
     26#pragma once
    2827
    29 #if PLATFORM(IOS_FAMILY)
    30 
    31 #import <WebCore/VersionChecks.h>
     28#include "ArgumentCoders.h"
    3229
    3330namespace WebKit {
    3431
    35 void LocalStorageDatabaseTracker::platformMaybeExcludeFromBackup() const
    36 {
    37     ASSERT(!RunLoop::isMain());
    38     if (m_hasExcludedFromBackup)
    39         return;
     32namespace PCM {
    4033
    41     m_hasExcludedFromBackup = true;
     34class Decoder {
     35public:
     36    Decoder(Vector<uint8_t>&& buffer)
     37        : m_buffer(WTFMove(buffer)) { }
     38   
     39    template<typename T>
     40    Decoder& operator>>(std::optional<T>& t)
     41    {
     42        t = IPC::ArgumentCoder<std::remove_const_t<std::remove_reference_t<T>>, void>::decode(*this);
     43        return *this;
     44    }
    4245
    43     [[NSURL fileURLWithPath:(NSString *)localStorageDirectory() isDirectory:YES] setResourceValue:@YES forKey:NSURLIsExcludedFromBackupKey error:nil];
    44 }
     46    template<typename T>
     47    WARN_UNUSED_RETURN bool bufferIsLargeEnoughToContain(size_t numElements) const
     48    {
     49        static_assert(std::is_arithmetic<T>::value, "Type T must have a fixed, known encoded size!");
     50
     51        if (numElements > std::numeric_limits<size_t>::max() / sizeof(T))
     52            return false;
     53
     54        return bufferIsLargeEnoughToContainBytes(numElements * sizeof(T));
     55    }
     56
     57    WARN_UNUSED_RETURN bool decodeFixedLengthData(uint8_t* data, size_t, size_t alignment);
     58   
     59private:
     60    WARN_UNUSED_RETURN bool bufferIsLargeEnoughToContainBytes(size_t) const;
     61
     62    Vector<uint8_t> m_buffer;
     63    size_t m_bufferPosition { 0 };
     64};
     65
     66} // namespace PCM
    4567
    4668} // namespace WebKit
    47 
    48 #endif
  • trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementEncoder.cpp

    r282226 r282230  
    11/*
    2  * Copyright (C) 2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #pragma once
     26#include "config.h"
     27#include "PrivateClickMeasurementEncoder.h"
    2728
    28 #include <WebKit/WKBase.h>
    29 #include <WebKit/WKFoundation.h>
     29namespace WebKit {
    3030
    31 #ifdef __cplusplus
    32 extern "C" {
    33 #endif
     31namespace PCM {
    3432
    35 WK_EXPORT int WKXPCServiceMain(int argc, const char** argv) WK_API_AVAILABLE(macos(10.15), ios(13.0));
     33void Encoder::encodeFixedLengthData(const uint8_t* data, size_t size, size_t)
     34{
     35    m_buffer.append(data, size);
     36}
    3637
    37 #ifdef __cplusplus
    38 }
    39 #endif
     38} // namespace PCM
     39
     40} // namespace WebKit
  • trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementEncoder.h

    r282226 r282230  
    11/*
    2  * Copyright (C) 2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #import "config.h"
    27 #import "LocalStorageDatabaseTracker.h"
     26#pragma once
    2827
    29 #if PLATFORM(IOS_FAMILY)
    30 
    31 #import <WebCore/VersionChecks.h>
     28#include "ArgumentCoders.h"
    3229
    3330namespace WebKit {
    3431
    35 void LocalStorageDatabaseTracker::platformMaybeExcludeFromBackup() const
    36 {
    37     ASSERT(!RunLoop::isMain());
    38     if (m_hasExcludedFromBackup)
    39         return;
     32namespace PCM {
    4033
    41     m_hasExcludedFromBackup = true;
     34class Encoder {
     35public:
     36    template<typename T>
     37    Encoder& operator<<(T&& t)
     38    {
     39        IPC::ArgumentCoder<std::remove_const_t<std::remove_reference_t<T>>>::encode(*this, std::forward<T>(t));
     40        return *this;
     41    }
    4242
    43     [[NSURL fileURLWithPath:(NSString *)localStorageDirectory() isDirectory:YES] setResourceValue:@YES forKey:NSURLIsExcludedFromBackupKey error:nil];
    44 }
     43    template<typename Arg, typename... Args>
     44    void encode(Arg&& arg, Args&&... args)
     45    {
     46        *this << std::forward<Arg>(arg);
     47        encode(std::forward<Args>(args)...);
     48    }
     49    void encode() { }
     50
     51    Vector<uint8_t> takeBuffer() { return std::exchange(m_buffer, { }); }
     52
     53    void encodeFixedLengthData(const uint8_t*, size_t, size_t alignment);
     54
     55private:
     56    Vector<uint8_t> m_buffer;
     57};
     58
     59} // namespace PCM
    4560
    4661} // namespace WebKit
    47 
    48 #endif
  • trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManager.h

    r282109 r282230  
    2929#include "NetworkProcess.h"
    3030#include "PrivateClickMeasurementClient.h"
     31#include "PrivateClickMeasurementManagerInterface.h"
    3132#include "PrivateClickMeasurementStore.h"
    32 #include <WebCore/PrivateClickMeasurement.h>
    33 #include <WebCore/RegistrableDomain.h>
    34 #include <WebCore/ResourceError.h>
    35 #include <WebCore/ResourceResponse.h>
    3633#include <WebCore/Timer.h>
    37 #include <pal/SessionID.h>
    3834#include <wtf/CompletionHandler.h>
    3935#include <wtf/JSONValues.h>
     
    4339namespace WebKit {
    4440
    45 enum class PrivateClickMeasurementAttributionType : bool { Unattributed, Attributed };
    46 
    47 class PrivateClickMeasurementManager : public CanMakeWeakPtr<PrivateClickMeasurementManager> {
     41class PrivateClickMeasurementManager : public PCM::ManagerInterface, public CanMakeWeakPtr<PrivateClickMeasurementManager> {
    4842    WTF_MAKE_FAST_ALLOCATED;
    4943public:
    50 
    51     using AttributionDestinationSite = WebCore::PrivateClickMeasurement::AttributionDestinationSite;
    52     using AttributionTriggerData = WebCore::PrivateClickMeasurement::AttributionTriggerData;
    53     using PrivateClickMeasurement = WebCore::PrivateClickMeasurement;
    54     using RegistrableDomain = WebCore::RegistrableDomain;
    55     using SourceSite = WebCore::PrivateClickMeasurement::SourceSite;
    5644
    5745    explicit PrivateClickMeasurementManager(UniqueRef<PCM::Client>&&, const String& storageDirectory);
    5846    ~PrivateClickMeasurementManager();
    5947
    60     void storeUnattributed(PrivateClickMeasurement&&);
    61     void handleAttribution(AttributionTriggerData&&, const URL& requestURL, WebCore::RegistrableDomain&& redirectDomain, const URL& firstPartyURL);
    62     void clear(CompletionHandler<void()>&&);
    63     void clearForRegistrableDomain(const RegistrableDomain&, CompletionHandler<void()>&&);
    64     void migratePrivateClickMeasurementFromLegacyStorage(PrivateClickMeasurement&&, PrivateClickMeasurementAttributionType);
     48    void storeUnattributed(PrivateClickMeasurement&&) final;
     49    void handleAttribution(AttributionTriggerData&&, const URL& requestURL, WebCore::RegistrableDomain&& redirectDomain, const URL& firstPartyURL) final;
     50    void clear(CompletionHandler<void()>&&) final;
     51    void clearForRegistrableDomain(const RegistrableDomain&, CompletionHandler<void()>&&) final;
     52    void migratePrivateClickMeasurementFromLegacyStorage(PrivateClickMeasurement&&, PrivateClickMeasurementAttributionType) final;
    6553
    66     void toStringForTesting(CompletionHandler<void(String)>&&) const;
    67     void setOverrideTimerForTesting(bool value) { m_isRunningTest = value; }
    68     void setTokenPublicKeyURLForTesting(URL&&);
    69     void setTokenSignatureURLForTesting(URL&&);
    70     void setAttributionReportURLsForTesting(URL&& sourceURL, URL&& destinationURL);
    71     void markAllUnattributedAsExpiredForTesting();
    72     void markAttributedPrivateClickMeasurementsAsExpiredForTesting(CompletionHandler<void()>&&);
    73     void setEphemeralMeasurementForTesting(bool value) { m_isRunningEphemeralMeasurementTest = value; }
    74     void setPCMFraudPreventionValuesForTesting(String&& unlinkableToken, String&& secretToken, String&& signature, String&& keyID);
    75     void startTimerImmediatelyForTesting();
    76     void destroyStoreForTesting(CompletionHandler<void()>&&);
     54    void toStringForTesting(CompletionHandler<void(String)>&&) const final;
     55    void setOverrideTimerForTesting(bool value) final { m_isRunningTest = value; }
     56    void setTokenPublicKeyURLForTesting(URL&&) final;
     57    void setTokenSignatureURLForTesting(URL&&) final;
     58    void setAttributionReportURLsForTesting(URL&& sourceURL, URL&& destinationURL) final;
     59    void markAllUnattributedAsExpiredForTesting() final;
     60    void markAttributedPrivateClickMeasurementsAsExpiredForTesting(CompletionHandler<void()>&&) final;
     61    void setEphemeralMeasurementForTesting(bool value) final { m_isRunningEphemeralMeasurementTest = value; }
     62    void setPCMFraudPreventionValuesForTesting(String&& unlinkableToken, String&& secretToken, String&& signature, String&& keyID) final;
     63    void startTimerImmediatelyForTesting() final;
     64    void destroyStoreForTesting(CompletionHandler<void()>&&) final;
    7765
    7866private:
  • trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/cocoa/PrivateClickMeasurementNetworkLoaderCocoa.mm

    r282121 r282230  
    5353- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler
    5454{
     55    // FIXME: Add plubming so that we can tell the daemon which certificates to accept without using NetworkSessionCocoa.
    5556    if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]
    5657        && NetworkSessionCocoa::allowsSpecificHTTPSCertificateForHost(challenge))
  • trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/cocoa/PrivateClickMeasurementXPCUtilities.h

    r282226 r282230  
    11/*
    2  * Copyright (C) 2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #import "config.h"
    27 #import "WKMain.h"
     26#pragma once
    2827
    29 #import "XPCServiceEntryPoint.h"
     28#include <wtf/spi/darwin/XPCSPI.h>
    3029
    31 int WKXPCServiceMain(int argc, const char** argv)
    32 {
    33     return WebKit::XPCServiceMain(argc, argv);
    34 }
     30namespace WebKit {
     31
     32namespace PCM {
     33
     34void addVersionAndEncodedMessageToDictionary(Vector<uint8_t>&&, xpc_object_t);
     35
     36} // namespace PCM
     37
     38} // namespace WebKit
  • trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/cocoa/PrivateClickMeasurementXPCUtilities.mm

    r282226 r282230  
    11/*
    2  * Copyright (C) 2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2525
    2626#import "config.h"
    27 #import "LocalStorageDatabaseTracker.h"
    28 
    29 #if PLATFORM(IOS_FAMILY)
    30 
    31 #import <WebCore/VersionChecks.h>
     27#import "PrivateClickMeasurementXPCUtilities.h"
    3228
    3329namespace WebKit {
    3430
    35 void LocalStorageDatabaseTracker::platformMaybeExcludeFromBackup() const
     31namespace PCM {
     32
     33void addVersionAndEncodedMessageToDictionary(Vector<uint8_t>&& message, xpc_object_t dictionary)
    3634{
    37     ASSERT(!RunLoop::isMain());
    38     if (m_hasExcludedFromBackup)
    39         return;
     35    ASSERT(xpc_get_type(dictionary) == XPC_TYPE_DICTIONARY);
     36    xpc_dictionary_set_uint64(dictionary, PCM::protocolVersionKey, PCM::protocolVersionValue);
    4037
    41     m_hasExcludedFromBackup = true;
     38    auto bufferSize = message.size();
     39    auto rawPointer = message.releaseBuffer().leakPtr();
     40    auto dispatchData = adoptNS(dispatch_data_create(rawPointer, bufferSize, dispatch_get_main_queue(), ^{
     41        fastFree(rawPointer);
     42    }));
     43    auto xpcData = adoptOSObject(xpc_data_create_with_dispatch_data(dispatchData.get()));
     44    xpc_dictionary_set_value(dictionary, PCM::protocolEncodedMessageKey, xpcData.get());
    4245
    43     [[NSURL fileURLWithPath:(NSString *)localStorageDirectory() isDirectory:YES] setResourceValue:@YES forKey:NSURLIsExcludedFromBackupKey error:nil];
    4446}
    4547
     48} // namespace PCM
     49
    4650} // namespace WebKit
    47 
    48 #endif
  • trunk/Source/WebKit/NetworkProcess/WebStorage/ios/LocalStorageDatabaseTrackerIOS.mm

    r267966 r282230  
    3030
    3131#import <WebCore/VersionChecks.h>
     32#import <wtf/RunLoop.h>
    3233
    3334namespace WebKit {
  • trunk/Source/WebKit/NetworkProcess/mac/com.apple.WebKit.NetworkProcess.sb.in

    r278952 r282230  
    358358)
    359359
     360(allow mach-lookup (global-name "com.apple.webkit.adattributiond.service"))
     361
    360362(with-filter (uid 0)
    361363    (allow mach-lookup
  • trunk/Source/WebKit/Platform/IPC/ArgumentCoder.h

    r278458 r282230  
    4949    }
    5050
     51    template<typename Decoder>
    5152    static std::optional<T> decode(Decoder& decoder)
    5253    {
     
    8384    }
    8485
     86    template<typename Decoder>
    8587    static std::optional<T> decode(Decoder& decoder)
    8688    {
     
    101103    }
    102104
     105    template<typename Decoder>
    103106    static std::optional<T> decode(Decoder& decoder)
    104107    {
  • trunk/Source/WebKit/Platform/IPC/ArgumentCoders.cpp

    r278619 r282230  
    2828
    2929#include "DataReference.h"
     30#include "PrivateClickMeasurementDecoder.h"
     31#include "PrivateClickMeasurementEncoder.h"
    3032#include "StreamConnectionEncoder.h"
    3133#include <wtf/text/CString.h>
     
    3436namespace IPC {
    3537
     38template<typename Encoder>
    3639void ArgumentCoder<WallTime>::encode(Encoder& encoder, const WallTime& time)
    3740{
    3841    encoder << time.secondsSinceEpoch().value();
    3942}
     43template
     44void ArgumentCoder<WallTime>::encode<Encoder>(Encoder&, const WallTime&);
     45template
     46void ArgumentCoder<WallTime>::encode<WebKit::PCM::Encoder>(WebKit::PCM::Encoder&, const WallTime&);
    4047
    4148WARN_UNUSED_RETURN bool ArgumentCoder<WallTime>::decode(Decoder& decoder, WallTime& time)
     
    4956}
    5057
     58template<typename Decoder>
    5159WARN_UNUSED_RETURN std::optional<WallTime> ArgumentCoder<WallTime>::decode(Decoder& decoder)
    5260{
     
    5765    return WallTime::fromRawSeconds(*time);
    5866}
     67template
     68std::optional<WallTime> ArgumentCoder<WallTime>::decode<Decoder>(Decoder&);
     69template
     70std::optional<WallTime> ArgumentCoder<WallTime>::decode<WebKit::PCM::Decoder>(WebKit::PCM::Decoder&);
    5971
    6072void ArgumentCoder<AtomString>::encode(Encoder& encoder, const AtomString& atomString)
     
    134146template
    135147void ArgumentCoder<String>::encode<StreamConnectionEncoder>(StreamConnectionEncoder&, const String&);
    136 
    137 template <typename CharacterType>
     148template
     149void ArgumentCoder<String>::encode<WebKit::PCM::Encoder>(WebKit::PCM::Encoder&, const String&);
     150
     151template<typename CharacterType, typename Decoder>
    138152static inline std::optional<String> decodeStringText(Decoder& decoder, uint32_t length)
    139153{
    140154    // Before allocating the string, make sure that the decoder buffer is big enough.
    141     if (!decoder.bufferIsLargeEnoughToContain<CharacterType>(length))
     155    if (!decoder.template bufferIsLargeEnoughToContain<CharacterType>(length))
    142156        return std::nullopt;
    143157   
     
    150164}
    151165
     166template<typename Decoder>
    152167WARN_UNUSED_RETURN std::optional<String> ArgumentCoder<String>::decode(Decoder& decoder)
    153168{
    154     uint32_t length;
    155     if (!decoder.decode(length))
    156         return std::nullopt;
    157    
    158     if (length == std::numeric_limits<uint32_t>::max()) {
     169    std::optional<uint32_t> length;
     170    decoder >> length;
     171    if (!length)
     172        return std::nullopt;
     173   
     174    if (*length == std::numeric_limits<uint32_t>::max()) {
    159175        // This is the null string.
    160176        return String();
    161177    }
    162178   
    163     bool is8Bit;
    164     if (!decoder.decode(is8Bit))
    165         return std::nullopt;
    166    
    167     if (is8Bit)
    168         return decodeStringText<LChar>(decoder, length);
    169     return decodeStringText<UChar>(decoder, length);
    170 }
     179    std::optional<bool> is8Bit;
     180    decoder >> is8Bit;
     181    if (!is8Bit)
     182        return std::nullopt;
     183   
     184    if (*is8Bit)
     185        return decodeStringText<LChar>(decoder, *length);
     186    return decodeStringText<UChar>(decoder, *length);
     187}
     188template
     189std::optional<String> ArgumentCoder<String>::decode<Decoder>(Decoder&);
     190template
     191std::optional<String> ArgumentCoder<String>::decode<WebKit::PCM::Decoder>(WebKit::PCM::Decoder&);
    171192
    172193WARN_UNUSED_RETURN bool ArgumentCoder<String>::decode(Decoder& decoder, String& result)
  • trunk/Source/WebKit/Platform/IPC/ArgumentCoders.h

    r278338 r282230  
    301301template<typename Type, typename... Types>
    302302struct TupleDecoderImpl {
     303    template<typename Decoder>
    303304    static std::optional<std::tuple<Type, Types...>> decode(Decoder& decoder)
    304305    {
     
    318319template<typename Type>
    319320struct TupleDecoderImpl<Type> {
     321    template<typename Decoder>
    320322    static std::optional<std::tuple<Type>> decode(Decoder& decoder)
    321323    {
     
    330332template<size_t size, typename... Elements>
    331333struct TupleDecoder {
     334    template<typename Decoder>
    332335    static std::optional<std::tuple<Elements...>> decode(Decoder& decoder)
    333336    {
     
    338341template<>
    339342struct TupleDecoder<0> {
     343    template<typename Decoder>
    340344    static std::optional<std::tuple<>> decode(Decoder&)
    341345    {
     
    351355    }
    352356
     357    template<typename Decoder>
    353358    static std::optional<std::tuple<Elements...>> decode(Decoder& decoder)
    354359    {
     
    722727   
    723728template<> struct ArgumentCoder<WallTime> {
     729    template<typename Encoder>
    724730    static void encode(Encoder&, const WallTime&);
    725731    static WARN_UNUSED_RETURN bool decode(Decoder&, WallTime&);
     732    template<typename Decoder>
    726733    static std::optional<WallTime> decode(Decoder&);
    727734};
     
    741748    static void encode(Encoder&, const String&);
    742749    static WARN_UNUSED_RETURN bool decode(Decoder&, String&);
     750    template<typename Decoder>
    743751    static std::optional<String> decode(Decoder&);
    744752};
  • trunk/Source/WebKit/Shared/API/Cocoa/WKMain.h

    r252174 r282230  
    3434
    3535WK_EXPORT int WKXPCServiceMain(int argc, const char** argv) WK_API_AVAILABLE(macos(10.15), ios(13.0));
     36WK_EXPORT int WKPCMDaemonMain(int argc, const char** argv) WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
    3637
    3738#ifdef __cplusplus
  • trunk/Source/WebKit/Shared/API/Cocoa/WKMain.mm

    r260366 r282230  
    2727#import "WKMain.h"
    2828
     29#import "PCMDaemonEntryPoint.h"
    2930#import "XPCServiceEntryPoint.h"
    3031
     
    3334    return WebKit::XPCServiceMain(argc, argv);
    3435}
     36
     37int WKPCMDaemonMain(int argc, const char** argv)
     38{
     39    return WebKit::PCMDaemonMain(argc, argv);
     40}
  • trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonEntryPoint.h

    r282226 r282230  
    11/*
    2  * Copyright (C) 2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #import "config.h"
    27 #import "WKMain.h"
     26#pragma once
    2827
    29 #import "XPCServiceEntryPoint.h"
     28namespace WebKit {
    3029
    31 int WKXPCServiceMain(int argc, const char** argv)
    32 {
    33     return WebKit::XPCServiceMain(argc, argv);
    34 }
     30int PCMDaemonMain(int, const char**);
     31
     32} // namespace WebKit
  • trunk/Source/WebKit/Sources.txt

    r282130 r282230  
    102102NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDebugInfo.cpp
    103103NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManager.cpp
     104NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerInterface.cpp
    104105NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementNetworkLoader.cpp
    105106NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementStore.cpp
     107NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementConnection.cpp
     108NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDaemonClient.cpp
     109NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDecoder.cpp
     110NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementEncoder.cpp
     111NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementManagerProxy.cpp
    106112
    107113NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp @no-unify
  • trunk/Source/WebKit/SourcesCocoa.txt

    r282110 r282230  
    4242NetworkProcess/EntryPoint/Cocoa/XPCService/NetworkServiceEntryPoint.mm
    4343
     44NetworkProcess/PrivateClickMeasurement/cocoa/PrivateClickMeasurementDaemonConnectionCocoa.mm
    4445NetworkProcess/PrivateClickMeasurement/cocoa/PrivateClickMeasurementNetworkLoaderCocoa.mm
     46NetworkProcess/PrivateClickMeasurement/cocoa/PrivateClickMeasurementXPCUtilities.mm
    4547
    4648NetworkProcess/WebStorage/ios/LocalStorageDatabaseTrackerIOS.mm
     
    191193Shared/Cocoa/WKObject.mm
    192194Shared/Cocoa/WebPreferencesDefaultValuesCocoa.mm
     195
     196Shared/EntryPointUtilities/Cocoa/Daemon/PCMDaemonEntryPoint.mm
    193197
    194198Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.mm
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r282189 r282230  
    12921292                5CB7AFE723C6820700E49CF3 /* ResourceLoadInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CB7AFE623C681B000E49CF3 /* ResourceLoadInfo.h */; };
    12931293                5CB7AFE823C69B6100E49CF3 /* _WKResourceLoadInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CB7AFE323C67D3700E49CF3 /* _WKResourceLoadInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1294                5CB9310926E8439A0032B1C0 /* PrivateClickMeasurementXPCUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CB9310726E841CB0032B1C0 /* PrivateClickMeasurementXPCUtilities.h */; };
    12941295                5CBC9B8E1C652CA000A8FDCF /* NetworkDataTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CBC9B891C6524A500A8FDCF /* NetworkDataTask.h */; };
    12951296                5CBD595C2280EDF4002B22AA /* _WKCustomHeaderFields.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C5D2388227A1892000B9BDA /* _WKCustomHeaderFields.mm */; };
     
    45654566                5CB930C126E054B80032B1C0 /* PrivateClickMeasurementClientImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrivateClickMeasurementClientImpl.h; sourceTree = "<group>"; };
    45664567                5CB930F226E7EEE00032B1C0 /* PrivateClickMeasurementNetworkLoaderCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PrivateClickMeasurementNetworkLoaderCocoa.mm; sourceTree = "<group>"; };
     4568                5CB930F426E801E80032B1C0 /* PrivateClickMeasurementDaemonConnectionCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PrivateClickMeasurementDaemonConnectionCocoa.mm; sourceTree = "<group>"; };
     4569                5CB930F526E802150032B1C0 /* PrivateClickMeasurementManagerProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrivateClickMeasurementManagerProxy.h; sourceTree = "<group>"; };
     4570                5CB930F626E802150032B1C0 /* PrivateClickMeasurementDaemonClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrivateClickMeasurementDaemonClient.h; sourceTree = "<group>"; };
     4571                5CB930F726E802150032B1C0 /* PrivateClickMeasurementDaemonClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrivateClickMeasurementDaemonClient.cpp; sourceTree = "<group>"; };
     4572                5CB930F826E802150032B1C0 /* PrivateClickMeasurementDecoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrivateClickMeasurementDecoder.cpp; sourceTree = "<group>"; };
     4573                5CB930F926E802150032B1C0 /* PrivateClickMeasurementEncoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrivateClickMeasurementEncoder.cpp; sourceTree = "<group>"; };
     4574                5CB930FA26E802150032B1C0 /* PrivateClickMeasurementManagerInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrivateClickMeasurementManagerInterface.h; sourceTree = "<group>"; };
     4575                5CB930FB26E802150032B1C0 /* PrivateClickMeasurementManagerProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrivateClickMeasurementManagerProxy.cpp; sourceTree = "<group>"; };
     4576                5CB930FC26E802160032B1C0 /* PrivateClickMeasurementConnection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrivateClickMeasurementConnection.cpp; sourceTree = "<group>"; };
     4577                5CB930FD26E802160032B1C0 /* PrivateClickMeasurementDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrivateClickMeasurementDecoder.h; sourceTree = "<group>"; };
     4578                5CB930FE26E802160032B1C0 /* PrivateClickMeasurementConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrivateClickMeasurementConnection.h; sourceTree = "<group>"; };
     4579                5CB930FF26E802160032B1C0 /* PrivateClickMeasurementEncoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrivateClickMeasurementEncoder.h; sourceTree = "<group>"; };
     4580                5CB9310426E837FC0032B1C0 /* PCMDaemonEntryPoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PCMDaemonEntryPoint.h; sourceTree = "<group>"; };
     4581                5CB9310526E837FD0032B1C0 /* PCMDaemonEntryPoint.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PCMDaemonEntryPoint.mm; sourceTree = "<group>"; };
     4582                5CB9310626E839A90032B1C0 /* PrivateClickMeasurementManagerInterface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrivateClickMeasurementManagerInterface.cpp; sourceTree = "<group>"; };
     4583                5CB9310726E841CB0032B1C0 /* PrivateClickMeasurementXPCUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrivateClickMeasurementXPCUtilities.h; sourceTree = "<group>"; };
     4584                5CB9310826E841CB0032B1C0 /* PrivateClickMeasurementXPCUtilities.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PrivateClickMeasurementXPCUtilities.mm; sourceTree = "<group>"; };
    45674585                5CBC9B891C6524A500A8FDCF /* NetworkDataTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkDataTask.h; sourceTree = "<group>"; };
    45684586                5CBC9B8B1C65257300A8FDCF /* NetworkDataTaskCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NetworkDataTaskCocoa.mm; sourceTree = "<group>"; };
     
    92849302                                5CB930C026E0542F0032B1C0 /* PrivateClickMeasurementClientImpl.cpp */,
    92859303                                5CB930C126E054B80032B1C0 /* PrivateClickMeasurementClientImpl.h */,
     9304                                5CB930FC26E802160032B1C0 /* PrivateClickMeasurementConnection.cpp */,
     9305                                5CB930FE26E802160032B1C0 /* PrivateClickMeasurementConnection.h */,
     9306                                5CB930F726E802150032B1C0 /* PrivateClickMeasurementDaemonClient.cpp */,
     9307                                5CB930F626E802150032B1C0 /* PrivateClickMeasurementDaemonClient.h */,
    92869308                                5C826D6A26D482EA008AEC91 /* PrivateClickMeasurementDatabase.cpp */,
    92879309                                5C826D6926D482EA008AEC91 /* PrivateClickMeasurementDatabase.h */,
    92889310                                5CBE909026D7FB7C005A2E95 /* PrivateClickMeasurementDebugInfo.cpp */,
    92899311                                5CBE908F26D7FB62005A2E95 /* PrivateClickMeasurementDebugInfo.h */,
     9312                                5CB930F826E802150032B1C0 /* PrivateClickMeasurementDecoder.cpp */,
     9313                                5CB930FD26E802160032B1C0 /* PrivateClickMeasurementDecoder.h */,
     9314                                5CB930F926E802150032B1C0 /* PrivateClickMeasurementEncoder.cpp */,
     9315                                5CB930FF26E802160032B1C0 /* PrivateClickMeasurementEncoder.h */,
    92909316                                6BD05864220CE8C2000BED5C /* PrivateClickMeasurementManager.cpp */,
    92919317                                6BD05863220CE8C2000BED5C /* PrivateClickMeasurementManager.h */,
     9318                                5CB9310626E839A90032B1C0 /* PrivateClickMeasurementManagerInterface.cpp */,
     9319                                5CB930FA26E802150032B1C0 /* PrivateClickMeasurementManagerInterface.h */,
     9320                                5CB930FB26E802150032B1C0 /* PrivateClickMeasurementManagerProxy.cpp */,
     9321                                5CB930F526E802150032B1C0 /* PrivateClickMeasurementManagerProxy.h */,
    92929322                                57FE688B260ABB3D00BF45E4 /* PrivateClickMeasurementNetworkLoader.cpp */,
    92939323                                57FE688A260ABB3D00BF45E4 /* PrivateClickMeasurementNetworkLoader.h */,
     
    93779407                        isa = PBXGroup;
    93789408                        children = (
     9409                                5CB930F426E801E80032B1C0 /* PrivateClickMeasurementDaemonConnectionCocoa.mm */,
    93799410                                5CB930F226E7EEE00032B1C0 /* PrivateClickMeasurementNetworkLoaderCocoa.mm */,
     9411                                5CB9310726E841CB0032B1C0 /* PrivateClickMeasurementXPCUtilities.h */,
     9412                                5CB9310826E841CB0032B1C0 /* PrivateClickMeasurementXPCUtilities.mm */,
    93809413                        );
    93819414                        path = cocoa;
     9415                        sourceTree = "<group>";
     9416                };
     9417                5CB9310326E8375B0032B1C0 /* Daemon */ = {
     9418                        isa = PBXGroup;
     9419                        children = (
     9420                                5CB9310426E837FC0032B1C0 /* PCMDaemonEntryPoint.h */,
     9421                                5CB9310526E837FD0032B1C0 /* PCMDaemonEntryPoint.mm */,
     9422                        );
     9423                        name = Daemon;
     9424                        path = Cocoa/Daemon;
    93829425                        sourceTree = "<group>";
    93839426                };
     
    1084310886                        isa = PBXGroup;
    1084410887                        children = (
     10888                                5CB9310326E8375B0032B1C0 /* Daemon */,
    1084510889                                BC82836B16B3587900A278FE /* XPCService */,
    1084610890                                5CE9120F2293C25F005BEC78 /* AuxiliaryProcessMain.cpp */,
     
    1239612440                                57FE688C260ABB3D00BF45E4 /* PrivateClickMeasurementNetworkLoader.h in Headers */,
    1239712441                                5C826D6B26D482EF008AEC91 /* PrivateClickMeasurementStore.h in Headers */,
     12442                                5CB9310926E8439A0032B1C0 /* PrivateClickMeasurementXPCUtilities.h in Headers */,
    1239812443                                86F9536518FF58F5001DB2EF /* ProcessAssertion.h in Headers */,
    1239912444                                BC1A7C581136E19C00FB7167 /* ProcessLauncher.h in Headers */,
Note: See TracChangeset for help on using the changeset viewer.