Changeset 228967 in webkit


Ignore:
Timestamp:
Feb 23, 2018 3:26:40 PM (6 years ago)
Author:
wilander@apple.com
Message:

Introduce ITP debug logging as an opt-in developer feature
https://bugs.webkit.org/show_bug.cgi?id=183065
<rdar://problem/37803761>

Reviewed by Brent Fulgham.

Source/WebKit:

  • Platform/Logging.h:

Added a dedicated channel for Resource Load Statistics debug logging
since this will be part of a developer-facing feature and should not
be mixed with general Resource Load Statistics logging.

  • UIProcess/Cocoa/WebResourceLoadStatisticsStoreCocoa.mm:

(WebKit::WebResourceLoadStatisticsStore::registerUserDefaultsIfNeeded):

Now picks up the user default setting for
ResourceLoadStatisticsDebugLoggingEnabled.

  • UIProcess/WebResourceLoadStatisticsStore.cpp:

(WebKit::WebResourceLoadStatisticsStore::removeDataRecords):

Now logs for which domains it purges website data if
ResourceLoadStatisticsDebugLoggingEnabled is set.

(WebKit::WebResourceLoadStatisticsStore::updateCookiePartitioning):

Now logs for which domains it partitions and blocks cookies
in third-party contexts if ResourceLoadStatisticsDebugLoggingEnabled
is set.

  • UIProcess/WebResourceLoadStatisticsStore.h:

Source/WTF:

  • wtf/Assertions.h:

Introduces RELEASE_LOG_INFO() and RELEASE_LOG_INFO_IF().

Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r228953 r228967  
     12018-02-23  John Wilander  <wilander@apple.com>
     2
     3        Introduce ITP debug logging as an opt-in developer feature
     4        https://bugs.webkit.org/show_bug.cgi?id=183065
     5        <rdar://problem/37803761>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        * wtf/Assertions.h:
     10            Introduces RELEASE_LOG_INFO() and RELEASE_LOG_INFO_IF().
     11
    1122018-02-23  Fujii Hironori  <Hironori.Fujii@sony.com>
    213
  • trunk/Source/WTF/wtf/Assertions.h

    r225958 r228967  
    457457#define RELEASE_LOG(      channel, format, ...) os_log(      LOG_CHANNEL(channel).osLogChannel, format, ##__VA_ARGS__)
    458458#define RELEASE_LOG_ERROR(channel, format, ...) os_log_error(LOG_CHANNEL(channel).osLogChannel, format, ##__VA_ARGS__)
     459#define RELEASE_LOG_INFO(channel, format, ...) os_log_info(LOG_CHANNEL(channel).osLogChannel, format, ##__VA_ARGS__)
    459460
    460461#define RELEASE_LOG_IF(      isAllowed, channel, format, ...) do { if (isAllowed) RELEASE_LOG(      channel, format, ##__VA_ARGS__); } while (0)
    461462#define RELEASE_LOG_ERROR_IF(isAllowed, channel, format, ...) do { if (isAllowed) RELEASE_LOG_ERROR(channel, format, ##__VA_ARGS__); } while (0)
     463#define RELEASE_LOG_INFO_IF(isAllowed, channel, format, ...) do { if (isAllowed) RELEASE_LOG_INFO(channel, format, ##__VA_ARGS__); } while (0)
    462464
    463465#define RELEASE_LOG_WITH_LEVEL(channel, logLevel, format, ...) do { \
  • trunk/Source/WebKit/ChangeLog

    r228964 r228967  
     12018-02-23  John Wilander  <wilander@apple.com>
     2
     3        Introduce ITP debug logging as an opt-in developer feature
     4        https://bugs.webkit.org/show_bug.cgi?id=183065
     5        <rdar://problem/37803761>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        * Platform/Logging.h:
     10            Added a dedicated channel for Resource Load Statistics debug logging
     11            since this will be part of a developer-facing feature and should not
     12            be mixed with general Resource Load Statistics logging.
     13        * UIProcess/Cocoa/WebResourceLoadStatisticsStoreCocoa.mm:
     14        (WebKit::WebResourceLoadStatisticsStore::registerUserDefaultsIfNeeded):
     15            Now picks up the user default setting for
     16            ResourceLoadStatisticsDebugLoggingEnabled.
     17        * UIProcess/WebResourceLoadStatisticsStore.cpp:
     18        (WebKit::WebResourceLoadStatisticsStore::removeDataRecords):
     19            Now logs for which domains it purges website data if
     20            ResourceLoadStatisticsDebugLoggingEnabled is set.
     21        (WebKit::WebResourceLoadStatisticsStore::updateCookiePartitioning):
     22            Now logs for which domains it partitions and blocks cookies
     23            in third-party contexts if ResourceLoadStatisticsDebugLoggingEnabled
     24            is set.
     25        * UIProcess/WebResourceLoadStatisticsStore.h:
     26
    1272018-02-23  Brent Fulgham  <bfulgham@apple.com>
    228
  • trunk/Source/WebKit/Platform/Logging.h

    r228116 r228967  
    6565    M(Resize) \
    6666    M(ResourceLoadStatistics) \
     67    M(ResourceLoadStatisticsDebug) \
    6768    M(Selection) \
    6869    M(ServiceWorker) \
  • trunk/Source/WebKit/UIProcess/Cocoa/WebResourceLoadStatisticsStoreCocoa.mm

    r219855 r228967  
    4949        if (grandfatheringTime > 0_s && grandfatheringTime <= 24_h * 7)
    5050            setGrandfatheringTime(grandfatheringTime);
     51
     52        setDebugLogggingEnabled([[NSUserDefaults standardUserDefaults] boolForKey:@"ResourceLoadStatisticsDebugLoggingEnabled"]);
    5153    });
    5254}
  • trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp

    r228828 r228967  
    4242#include <wtf/MathExtras.h>
    4343#include <wtf/NeverDestroyed.h>
     44#if !RELEASE_LOG_DISABLED
     45#include <wtf/text/StringBuilder.h>
     46#endif
    4447
    4548namespace WebKit {
     
    185188    m_persistentStorage.finishAllPendingWorkSynchronously();
    186189}
    187    
     190
     191#if !RELEASE_LOG_DISABLED
     192static void appendWithDelimiter(StringBuilder& builder, const String& domain, bool isFirstItem)
     193{
     194    if (!isFirstItem)
     195        builder.appendLiteral(", ");
     196    builder.append(domain);
     197}
     198#endif
     199
    188200void WebResourceLoadStatisticsStore::removeDataRecords(CompletionHandler<void()>&& callback)
    189201{
     
    206218        return;
    207219    }
     220
     221#if !RELEASE_LOG_DISABLED
     222    if (m_debugLoggingEnabled) {
     223        StringBuilder domainsToRemoveDataRecordsForBuilder;
     224        bool isFirstItem = true;
     225        for (auto& domain : prevalentResourceDomains) {
     226            appendWithDelimiter(domainsToRemoveDataRecordsForBuilder, domain, isFirstItem);
     227            isFirstItem = false;
     228        }
     229        RELEASE_LOG_INFO(ResourceLoadStatisticsDebug, "About to remove data records for %{public}s.", domainsToRemoveDataRecordsForBuilder.toString().utf8().data());
     230    }
     231#endif
    208232
    209233    setDataRecordsBeingRemoved(true);
     
    218242                setDataRecordsBeingRemoved(false);
    219243                callback();
     244#if !RELEASE_LOG_DISABLED
     245                RELEASE_LOG_INFO_IF(m_debugLoggingEnabled, ResourceLoadStatisticsDebug, "Done removing data records.");
     246#endif
    220247            });
    221248        });
     
    930957    }
    931958
     959#if !RELEASE_LOG_DISABLED
     960    if (m_debugLoggingEnabled) {
     961        if (!domainsToPartition.isEmpty()) {
     962            StringBuilder domainsToPartitionBuilder;
     963            bool isFirstDomain = true;
     964            for (auto& domain : domainsToPartition) {
     965                appendWithDelimiter(domainsToPartitionBuilder, domain, isFirstDomain);
     966                isFirstDomain = false;
     967            }
     968            RELEASE_LOG_INFO(ResourceLoadStatisticsDebug, "About to partition cookies in third-party contexts for %{public}s.", domainsToPartitionBuilder.toString().utf8().data());
     969            RELEASE_LOG_INFO(ResourceLoadStatisticsDebug, "About to partition cookies in third-party contexts for %s.", domainsToPartitionBuilder.toString().utf8().data());
     970        }
     971
     972        if (!domainsToBlock.isEmpty()) {
     973            StringBuilder domainsToBlockBuilder;
     974            bool isFirstDomain = true;
     975            for (auto& domain : domainsToBlock) {
     976                appendWithDelimiter(domainsToBlockBuilder, domain, isFirstDomain);
     977                isFirstDomain = false;
     978            }
     979            RELEASE_LOG_INFO(ResourceLoadStatisticsDebug, "About to block cookies in third-party contexts for %{public}s.", domainsToBlockBuilder.toString().utf8().data());
     980        }
     981
     982        if (!domainsToNeitherPartitionNorBlock.isEmpty()) {
     983            StringBuilder domainsToNeitherPartitionNorBlockBuilder;
     984            bool isFirstDomain = true;
     985            for (auto& domain : domainsToNeitherPartitionNorBlock) {
     986                appendWithDelimiter(domainsToNeitherPartitionNorBlockBuilder, domain, isFirstDomain);
     987                isFirstDomain = false;
     988            }
     989            RELEASE_LOG_INFO(ResourceLoadStatisticsDebug, "About to neither partition nor block cookies in third-party contexts for %{public}s.", domainsToNeitherPartitionNorBlockBuilder.toString().utf8().data());
     990        }
     991    }
     992#endif
     993
    932994    RunLoop::main().dispatch([this, protectedThis = makeRef(*this), domainsToPartition = crossThreadCopy(domainsToPartition), domainsToBlock = crossThreadCopy(domainsToBlock), domainsToNeitherPartitionNorBlock = crossThreadCopy(domainsToNeitherPartitionNorBlock), callback = WTFMove(callback)] () {
    933995        m_updatePrevalentDomainsToPartitionOrBlockCookiesHandler(domainsToPartition, domainsToBlock, domainsToNeitherPartitionNorBlock, ShouldClearFirst::No);
    934996        callback();
     997#if !RELEASE_LOG_DISABLED
     998        RELEASE_LOG_INFO_IF(m_debugLoggingEnabled, ResourceLoadStatisticsDebug, "Done updating cookie partitioning and blocking.");
     999#endif
    9351000    });
    9361001}
  • trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h

    r228951 r228967  
    177177    void resetCookiePartitioningState();
    178178
     179    void setDebugLogggingEnabled(bool enabled) { m_debugLoggingEnabled  = enabled; }
     180
    179181#if PLATFORM(COCOA)
    180182    void registerUserDefaultsIfNeeded();
     
    221223    bool m_dataRecordsBeingRemoved { false };
    222224
     225    bool m_debugLoggingEnabled { false };
     226
    223227    Function<void (const String&)> m_statisticsTestingCallback;
    224228};
Note: See TracChangeset for help on using the changeset viewer.