Changeset 196622 in webkit


Ignore:
Timestamp:
Feb 15, 2016 9:36:38 PM (8 years ago)
Author:
Brent Fulgham
Message:

[Mac] Gather some rudimentary statistics during resource load
https://bugs.webkit.org/show_bug.cgi?id=153575
<rdar://problem/24075254>

Reviewed by Brady Eidson.

Source/WebCore:

Tested by: http/tests/navigation/statistics.html

  • CMakeLists.txt:
  • PlatformWin.cmake:
  • WebCore.xcodeproj/project.pbxproj:
  • dom/Document.cpp:

(WebCore::Document::updateLastHandledUserGestureTimestamp): Log user interaction
with the ResourceLoadObserver.

  • loader/DocumentLoader.cpp:

(WebCore::DocumentLoader::willSendRequest): Track load statistics if the
user interacted with the document.

  • loader/ResourceLoadObserver.cpp: Added.
  • loader/ResourceLoadObserver.h: Added.
  • loader/ResourceLoadStatistics.cpp: Added.
  • loader/ResourceLoadStatistics.h: Added.
  • loader/SubresourceLoader.cpp:

(WebCore::SubresourceLoader::willSendRequestInternal): Track load statistics.

  • page/Settings.cpp:

(WebCore::Settings::setResourceLoadStatisticsEnabled): Added.

  • page/Settings.h:

(WebCore::Settings::resourceLoadStatisticsEnabled): Added.

  • platform/Logging.h:
  • testing/Internals.cpp:

(WebCore::Internals::resourceLoadStatisticsForOrigin):
(WebCore::Internals::setResourceLoadStatisticsEnabled):

  • testing/Internals.h:
  • testing/Internals.idl:

Source/WebKit/mac:

  • Misc/WebKitNSStringExtras.h:
  • Misc/WebKitNSStringExtras.mm:

(+[NSString _webkit_localStorageDirectoryWithBundleIdentifier:]): Added.

  • WebView/WebPreferenceKeysPrivate.h:
  • WebView/WebPreferences.mm:

(+[WebPreferences initialize]):
(-[WebPreferences resourceLoadStatisticsEnabled]): Added.
(-[WebPreferences setResourceLoadStatisticsEnabled:]): Added.

  • WebView/WebPreferencesPrivate.h:
  • WebView/WebView.mm:

(WebKitInitializeApplicationCachePathIfNecessary):
(WebKitInitializeApplicationStatisticsStoragePathIfNecessary): Added.
(-[WebView _commonInitializationWithFrameName:groupName:]): Add call to new
initialization method.
(-[WebView _preferencesChanged:]): Track changes in the user's desire to
monitor resource load statistics.
(+[WebView _applicationWillTerminate]): Write statistics to disk (if preferences
say to do so.)

Tools:

  • MiniBrowser/mac/SettingsController.h:
  • MiniBrowser/mac/SettingsController.m:

(-[SettingsController _populateMenu]): Add menu item for new debug flag.
(-[SettingsController toggleResourceLoadStatisticsEnabled:]): Added.
(-[SettingsController resourceLoadStatisticsEnabled]): Added.

  • MiniBrowser/mac/WK1BrowserWindowController.m:

(-[WK1BrowserWindowController didChangeSettings]): React to changes in
users's desire to track resource load statistics.

LayoutTests:

  • http/tests/navigation/resources/redirect-on-reload-updates-history-item-statistics.php: Added.
  • http/tests/navigation/resources/redirect-updates-history-item-done-statistics.html: Added.
  • http/tests/navigation/statistics-expected.txt: Added.
  • http/tests/navigation/statistics.html: Added.
Location:
trunk
Files:
8 added
27 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r196621 r196622  
     12016-02-15  Brent Fulgham  <bfulgham@apple.com>
     2
     3        [Mac] Gather some rudimentary statistics during resource load
     4        https://bugs.webkit.org/show_bug.cgi?id=153575
     5        <rdar://problem/24075254>
     6
     7        Reviewed by Brady Eidson.
     8
     9        * http/tests/navigation/resources/redirect-on-reload-updates-history-item-statistics.php: Added.
     10        * http/tests/navigation/resources/redirect-updates-history-item-done-statistics.html: Added.
     11        * http/tests/navigation/statistics-expected.txt: Added.
     12        * http/tests/navigation/statistics.html: Added.
     13
    1142016-02-15  Chris Dumez  <cdumez@apple.com>
    215
  • trunk/Source/WebCore/CMakeLists.txt

    r196604 r196622  
    19371937    loader/ProgressTracker.cpp
    19381938    loader/ResourceLoadNotifier.cpp
     1939    loader/ResourceLoadObserver.cpp
     1940    loader/ResourceLoadStatistics.cpp
    19391941    loader/ResourceLoader.cpp
    19401942    loader/SinkDocument.cpp
  • trunk/Source/WebCore/ChangeLog

    r196621 r196622  
     12016-02-15  Brent Fulgham  <bfulgham@apple.com>
     2
     3        [Mac] Gather some rudimentary statistics during resource load
     4        https://bugs.webkit.org/show_bug.cgi?id=153575
     5        <rdar://problem/24075254>
     6
     7        Reviewed by Brady Eidson.
     8
     9        Tested by: http/tests/navigation/statistics.html
     10
     11        * CMakeLists.txt:
     12        * PlatformWin.cmake:
     13        * WebCore.xcodeproj/project.pbxproj:
     14        * dom/Document.cpp:
     15        (WebCore::Document::updateLastHandledUserGestureTimestamp): Log user interaction
     16        with the ResourceLoadObserver.
     17        * loader/DocumentLoader.cpp:
     18        (WebCore::DocumentLoader::willSendRequest): Track load statistics if the
     19        user interacted with the document.
     20        * loader/ResourceLoadObserver.cpp: Added.
     21        * loader/ResourceLoadObserver.h: Added.
     22        * loader/ResourceLoadStatistics.cpp: Added.
     23        * loader/ResourceLoadStatistics.h: Added.
     24        * loader/SubresourceLoader.cpp:
     25        (WebCore::SubresourceLoader::willSendRequestInternal): Track load statistics.
     26        * page/Settings.cpp:
     27        (WebCore::Settings::setResourceLoadStatisticsEnabled): Added.
     28        * page/Settings.h:
     29        (WebCore::Settings::resourceLoadStatisticsEnabled): Added.
     30        * platform/Logging.h:
     31        * testing/Internals.cpp:
     32        (WebCore::Internals::resourceLoadStatisticsForOrigin):
     33        (WebCore::Internals::setResourceLoadStatisticsEnabled):
     34        * testing/Internals.h:
     35        * testing/Internals.idl:
     36
    1372016-02-15  Chris Dumez  <cdumez@apple.com>
    238
  • trunk/Source/WebCore/PlatformWin.cmake

    r195733 r196622  
    6565
    6666    platform/cf/FileSystemCF.cpp
     67    platform/cf/KeyedDecoderCF.cpp
     68    platform/cf/KeyedEncoderCF.cpp
    6769    platform/cf/SharedBufferCF.cpp
    6870
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r196614 r196622  
    25182518                65FEA86909833ADE00BED4AB /* Page.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65FEA86809833ADE00BED4AB /* Page.cpp */; };
    25192519                6B3480940EEF50D400AC1B41 /* NativeImagePtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B3480920EEF50D400AC1B41 /* NativeImagePtr.h */; settings = {ATTRIBUTES = (Private, ); }; };
     2520                6B693A2E1C51A82E00B03BEF /* ResourceLoadObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B693A2D1C51A82E00B03BEF /* ResourceLoadObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
     2521                6B693A341C51A95D00B03BEF /* ResourceLoadObserver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B693A331C51A95D00B03BEF /* ResourceLoadObserver.cpp */; };
    25202522                6C4C96DE1AD4483500365A50 /* JSReadableStreamController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6C4C96DA1AD4483500365A50 /* JSReadableStreamController.cpp */; };
    25212523                6C4C96DF1AD4483500365A50 /* JSReadableStreamController.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C4C96DB1AD4483500365A50 /* JSReadableStreamController.h */; };
     
    26922694                7A74ECBB101839A600BF939E /* InspectorDOMStorageAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A74ECB9101839A600BF939E /* InspectorDOMStorageAgent.h */; };
    26932695                7A74ECBD101839DA00BF939E /* JSInspectorFrontendHostCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A74ECBC101839DA00BF939E /* JSInspectorFrontendHostCustom.cpp */; };
     2696                7A929CA61C598A9E004DF226 /* ResourceLoadStatistics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A929CA11C598378004DF226 /* ResourceLoadStatistics.cpp */; };
     2697                7A929CA71C598AA9004DF226 /* ResourceLoadStatistics.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A929CA21C598378004DF226 /* ResourceLoadStatistics.h */; };
    26942698                7A93868518DCC14500B8263D /* VTTScanner.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A93868218DCC14500B8263D /* VTTScanner.cpp */; };
    26952699                7A93868618DCC14500B8263D /* VTTScanner.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A93868318DCC14500B8263D /* VTTScanner.h */; };
     
    1008910093                65FEA86809833ADE00BED4AB /* Page.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Page.cpp; sourceTree = "<group>"; };
    1009010094                6B3480920EEF50D400AC1B41 /* NativeImagePtr.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = NativeImagePtr.h; sourceTree = "<group>"; };
     10095                6B693A2D1C51A82E00B03BEF /* ResourceLoadObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadObserver.h; sourceTree = "<group>"; };
     10096                6B693A331C51A95D00B03BEF /* ResourceLoadObserver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoadObserver.cpp; sourceTree = "<group>"; };
    1009110097                6C4C96DA1AD4483500365A50 /* JSReadableStreamController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSReadableStreamController.cpp; sourceTree = "<group>"; };
    1009210098                6C4C96DB1AD4483500365A50 /* JSReadableStreamController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSReadableStreamController.h; sourceTree = "<group>"; };
     
    1029310299                7A74ECB9101839A600BF939E /* InspectorDOMStorageAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorDOMStorageAgent.h; sourceTree = "<group>"; };
    1029410300                7A74ECBC101839DA00BF939E /* JSInspectorFrontendHostCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSInspectorFrontendHostCustom.cpp; sourceTree = "<group>"; };
     10301                7A929CA11C598378004DF226 /* ResourceLoadStatistics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoadStatistics.cpp; sourceTree = "<group>"; };
     10302                7A929CA21C598378004DF226 /* ResourceLoadStatistics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadStatistics.h; sourceTree = "<group>"; };
    1029510303                7A93868218DCC14500B8263D /* VTTScanner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VTTScanner.cpp; sourceTree = "<group>"; };
    1029610304                7A93868318DCC14500B8263D /* VTTScanner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VTTScanner.h; sourceTree = "<group>"; };
     
    2269022698                                973E325410883B7C005BC493 /* ResourceLoadNotifier.cpp */,
    2269122699                                973E325510883B7C005BC493 /* ResourceLoadNotifier.h */,
     22700                                6B693A331C51A95D00B03BEF /* ResourceLoadObserver.cpp */,
     22701                                6B693A2D1C51A82E00B03BEF /* ResourceLoadObserver.h */,
     22702                                7A929CA11C598378004DF226 /* ResourceLoadStatistics.cpp */,
     22703                                7A929CA21C598378004DF226 /* ResourceLoadStatistics.h */,
    2269222704                                51327D5F11A33A2B004F9D65 /* SinkDocument.cpp */,
    2269322705                                51327D5E11A33A2B004F9D65 /* SinkDocument.h */,
     
    2485624868                        buildActionMask = 2147483647;
    2485724869                        files = (
     24870                                6B693A2E1C51A82E00B03BEF /* ResourceLoadObserver.h in Headers */,
    2485824871                                FE115FAB167988CD00249134 /* AbstractDatabaseServer.h in Headers */,
    2485924872                                41E1B1D10FF5986900576B3B /* AbstractWorker.h in Headers */,
     
    2508525098                                CDC734151977896D0046BFC5 /* CARingBuffer.h in Headers */,
    2508625099                                6550B69E099DF0270090D781 /* CDATASection.h in Headers */,
     25100                                7A929CA71C598AA9004DF226 /* ResourceLoadStatistics.h in Headers */,
    2508725101                                CDE8B5ED1A69777300B4B66A /* CDMPrivateClearKey.h in Headers */,
    2508825102                                CD318623199F1E2A0030A0F7 /* CDMPrivateMediaSourceAVFObjC.h in Headers */,
     
    2914929163                                E125F859182C1AA600D84CD9 /* CryptoKeySerializationRaw.cpp in Sources */,
    2915029164                                31BC742D1AAFF45C006B4340 /* CSSAnimationTriggerScrollValue.cpp in Sources */,
     29165                                7A929CA61C598A9E004DF226 /* ResourceLoadStatistics.cpp in Sources */,
    2915129166                                CAE9F90F146441F000C245B0 /* CSSAspectRatioValue.cpp in Sources */,
    2915229167                                FBD6AF8B15EF25E5008B7110 /* CSSBasicShapes.cpp in Sources */,
     
    3012130136                                FD7868B9136B999200D403DF /* JSDynamicsCompressorNode.cpp in Sources */,
    3012230137                                65DF31F909D1CC60000BE325 /* JSElement.cpp in Sources */,
     30138                                6B693A341C51A95D00B03BEF /* ResourceLoadObserver.cpp in Sources */,
    3012330139                                BC2ED5550C6B9BD300920BFF /* JSElementCustom.cpp in Sources */,
    3012430140                                2ECF7ADC10162B3800427DE7 /* JSErrorEvent.cpp in Sources */,
  • trunk/Source/WebCore/dom/Document.cpp

    r196400 r196622  
    135135#include "RenderView.h"
    136136#include "RenderWidget.h"
     137#include "ResourceLoadObserver.h"
    137138#include "RuntimeEnabledFeatures.h"
    138139#include "SVGDocumentExtensions.h"
     
    63976398void Document::updateLastHandledUserGestureTimestamp()
    63986399{
     6400    if (!m_lastHandledUserGestureTimestamp)
     6401        ResourceLoadObserver::sharedObserver().logUserInteraction(*this);
     6402
    63996403    m_lastHandledUserGestureTimestamp = monotonicallyIncreasingTime();
    64006404}
  • trunk/Source/WebCore/loader/DocumentLoader.cpp

    r195770 r196622  
    6060#include "ProgressTracker.h"
    6161#include "ResourceHandle.h"
     62#include "ResourceLoadObserver.h"
    6263#include "SchemeRegistry.h"
    6364#include "ScriptController.h"
     
    525526    }
    526527
     528    ASSERT(m_frame);
     529
     530    Frame& topFrame = m_frame->tree().top();
     531
     532    ASSERT(m_frame->document());
     533    ASSERT(topFrame.document());
     534
     535    if (Settings::resourceLoadStatisticsEnabled())
     536        ResourceLoadObserver::sharedObserver().logFrameNavigation(!redirectResponse.isNull(), m_frame->document()->url(), newRequest.url(), m_frame->isMainFrame(), topFrame.document()->url());
     537   
    527538    // Update cookie policy base URL as URL changes, except for subframes, which use the
    528539    // URL of the main frame which doesn't change when we redirect.
    529     if (frameLoader()->frame().isMainFrame())
     540    if (m_frame->isMainFrame())
    530541        newRequest.setFirstPartyForCookies(newRequest.url());
    531542
     
    537548        newRequest.setCachePolicy(ReloadIgnoringCacheData);
    538549
    539     Frame& topFrame = m_frame->tree().top();
    540550    if (&topFrame != m_frame) {
    541551        if (!frameLoader()->mixedContentChecker().canDisplayInsecureContent(topFrame.document()->securityOrigin(), MixedContentChecker::ContentType::Active, newRequest.url())) {
  • trunk/Source/WebCore/loader/SubresourceLoader.cpp

    r195004 r196622  
    4141#include "MemoryCache.h"
    4242#include "Page.h"
     43#include "ResourceLoadObserver.h"
    4344#include "Settings.h"
    4445#include <wtf/Ref.h>
     
    190191    if (newRequest.isNull())
    191192        cancel();
     193
     194    if (Settings::resourceLoadStatisticsEnabled())
     195        ResourceLoadObserver::sharedObserver().logSubresourceLoading(!redirectResponse.isNull(), redirectResponse.url(), newRequest.url(), m_frame ? m_frame->mainFrame().document()->url() : URL());
    192196}
    193197
  • trunk/Source/WebCore/page/Settings.cpp

    r196332 r196622  
    9797bool Settings::gShouldRespectPriorityInCSSAttributeSetters = false;
    9898bool Settings::gLowPowerVideoAudioBufferSizeEnabled = false;
     99bool Settings::gResourceLoadStatisticsEnabledEnabled = false;
    99100
    100101#if PLATFORM(IOS)
     
    700701}
    701702
     703void Settings::setResourceLoadStatisticsEnabled(bool flag)
     704{
     705    gResourceLoadStatisticsEnabledEnabled = flag;
     706}
     707
    702708#if PLATFORM(IOS)
    703709void Settings::setAudioSessionCategoryOverride(unsigned sessionCategory)
  • trunk/Source/WebCore/page/Settings.h

    r196328 r196622  
    243243    WEBCORE_EXPORT static void setLowPowerVideoAudioBufferSizeEnabled(bool);
    244244
     245    static bool resourceLoadStatisticsEnabled() { return gResourceLoadStatisticsEnabledEnabled; }
     246    WEBCORE_EXPORT static void setResourceLoadStatisticsEnabled(bool);
     247
    245248#if PLATFORM(IOS)
    246249    WEBCORE_EXPORT static void setAudioSessionCategoryOverride(unsigned);
     
    378381
    379382    static bool gLowPowerVideoAudioBufferSizeEnabled;
     383    static bool gResourceLoadStatisticsEnabledEnabled;
    380384};
    381385
  • trunk/Source/WebCore/platform/Logging.h

    r194708 r196622  
    8787    M(WebReplay) \
    8888    M(WheelEventTestTriggers) \
     89    M(ResourceLoadObserver) \
    8990
    9091#define DECLARE_LOG_CHANNEL(name) \
  • trunk/Source/WebCore/testing/Internals.cpp

    r196575 r196622  
    103103#include "RenderView.h"
    104104#include "RenderedDocumentMarker.h"
     105#include "ResourceLoadObserver.h"
    105106#include "RuntimeEnabledFeatures.h"
    106107#include "SchemeRegistry.h"
     
    34613462#endif
    34623463
    3463 }
     3464String Internals::resourceLoadStatisticsForOrigin(String origin)
     3465{
     3466    return ResourceLoadObserver::sharedObserver().statisticsForOrigin(origin);
     3467}
     3468
     3469void Internals::setResourceLoadStatisticsEnabled(bool enable)
     3470{
     3471    Settings::setResourceLoadStatisticsEnabled(enable);
     3472}
     3473
     3474}
  • trunk/Source/WebCore/testing/Internals.h

    r196575 r196622  
    463463    void setShowAllPlugins(bool);
    464464
     465    String resourceLoadStatisticsForOrigin(String origin);
     466    void setResourceLoadStatisticsEnabled(bool);
     467
    465468#if ENABLE(STREAMS_API)
    466469    bool isReadableStreamDisturbed(ScriptState&, JSC::JSValue);
  • trunk/Source/WebCore/testing/Internals.idl

    r196575 r196622  
    434434
    435435    [Conditional=STREAMS_API, CallWith=ScriptState] boolean isReadableStreamDisturbed(any stream);
    436 };
     436
     437    DOMString resourceLoadStatisticsForOrigin(DOMString domain);
     438    void setResourceLoadStatisticsEnabled(boolean enable);
     439};
  • trunk/Source/WebKit/mac/ChangeLog

    r196551 r196622  
     12016-02-15  Brent Fulgham  <bfulgham@apple.com>
     2
     3        [Mac] Gather some rudimentary statistics during resource load
     4        https://bugs.webkit.org/show_bug.cgi?id=153575
     5        <rdar://problem/24075254>
     6
     7        Reviewed by Brady Eidson.
     8
     9        * Misc/WebKitNSStringExtras.h:
     10        * Misc/WebKitNSStringExtras.mm:
     11        (+[NSString _webkit_localStorageDirectoryWithBundleIdentifier:]): Added.
     12        * WebView/WebPreferenceKeysPrivate.h:
     13        * WebView/WebPreferences.mm:
     14        (+[WebPreferences initialize]):
     15        (-[WebPreferences resourceLoadStatisticsEnabled]): Added.
     16        (-[WebPreferences setResourceLoadStatisticsEnabled:]): Added.
     17        * WebView/WebPreferencesPrivate.h:
     18        * WebView/WebView.mm:
     19        (WebKitInitializeApplicationCachePathIfNecessary):
     20        (WebKitInitializeApplicationStatisticsStoragePathIfNecessary): Added.
     21        (-[WebView _commonInitializationWithFrameName:groupName:]): Add call to new
     22        initialization method.
     23        (-[WebView _preferencesChanged:]): Track changes in the user's desire to
     24        monitor resource load statistics.
     25        (+[WebView _applicationWillTerminate]): Write statistics to disk (if preferences
     26        say to do so.)
     27
    1282016-02-13  Mark Lam  <mark.lam@apple.com>
    229
  • trunk/Source/WebKit/mac/Misc/WebKitNSStringExtras.h

    r185294 r196622  
    3434
    3535extern NSString *WebKitLocalCacheDefaultsKey;
     36extern NSString *WebKitResourceLoadStatisticsDirectoryDefaultsKey;
    3637
    3738@interface NSString (WebKitExtras)
     
    6667
    6768+ (NSString *)_webkit_localCacheDirectoryWithBundleIdentifier:(NSString*)bundleIdentifier;
     69+ (NSString *)_webkit_localStorageDirectoryWithBundleIdentifier:(NSString*)bundleIdentifier;
    6870
    6971@end
  • trunk/Source/WebKit/mac/Misc/WebKitNSStringExtras.mm

    r195180 r196622  
    4747
    4848NSString *WebKitLocalCacheDefaultsKey = @"WebKitLocalCache";
     49NSString *WebKitResourceLoadStatisticsDirectoryDefaultsKey = @"WebKitResourceLoadStatisticsDirectory";
    4950
    5051using namespace WebCore;
     
    312313}
    313314
     315+ (NSString *)_webkit_localStorageDirectoryWithBundleIdentifier:(NSString*)bundleIdentifier
     316{
     317    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
     318    NSString *storageDirectory = [defaults objectForKey:WebKitResourceLoadStatisticsDirectoryDefaultsKey];
     319
     320    if (!storageDirectory || ![storageDirectory isKindOfClass:[NSString class]]) {
     321        NSError *error;
     322        NSString *storageDirectory = [[[NSFileManager defaultManager] URLForDirectory:NSApplicationSupportDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:&error] path];
     323       
     324        if (!storageDirectory || ![storageDirectory isKindOfClass:[NSString class]])
     325            storageDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support"];
     326    }
     327
     328    return [storageDirectory stringByAppendingPathComponent:bundleIdentifier];
     329}
     330
    314331@end
  • trunk/Source/WebKit/mac/WebKit.exp

    r174621 r196622  
    8181_WebKitErrorPlugInPageURLStringKey
    8282_WebKitLocalCacheDefaultsKey
     83_WebKitResourceLoadStatisticsDirectoryDefaultsKey
    8384_WebLocalizedString
    8485_WebPlugInAttributesKey
  • trunk/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h

    r196328 r196622  
    137137#define WebKitSuppressesIncrementalRenderingKey @"WebKitSuppressesIncrementalRendering"
    138138#define WebKitSubpixelCSSOMElementMetricsEnabledPreferenceKey @"WebKitSubpixelCSSOMElementMetricsEnabled"
     139#define WebKitResourceLoadStatisticsEnabledPreferenceKey @"WebKitResourceLoadStatisticsEnabled"
    139140#if TARGET_OS_IPHONE
    140141#define WebKitAudioSessionCategoryOverride @"WebKitAudioSessionCategoryOverride"
  • trunk/Source/WebKit/mac/WebView/WebPreferences.mm

    r196328 r196622  
    506506        [NSNumber numberWithBool:NO],   WebKitAccelerated2dCanvasEnabledPreferenceKey,
    507507        [NSNumber numberWithBool:NO],  WebKitSubpixelCSSOMElementMetricsEnabledPreferenceKey,
     508        [NSNumber numberWithBool:NO],  WebKitResourceLoadStatisticsEnabledPreferenceKey,
    508509#if PLATFORM(IOS)
    509510        [NSNumber numberWithBool:YES],  WebKitFrameFlatteningEnabledPreferenceKey,
     
    18301831}
    18311832
     1833- (BOOL)resourceLoadStatisticsEnabled
     1834{
     1835    return [self _boolValueForKey:WebKitResourceLoadStatisticsEnabledPreferenceKey];
     1836}
     1837
     1838- (void)setResourceLoadStatisticsEnabled:(BOOL)enabled
     1839{
     1840    [self _setBoolValue:enabled forKey:WebKitResourceLoadStatisticsEnabledPreferenceKey];
     1841}
     1842
    18321843- (BOOL)canvasUsesAcceleratedDrawing
    18331844{
  • trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h

    r196328 r196622  
    204204- (void)setDisplayListDrawingEnabled:(BOOL)enabled;
    205205
     206- (BOOL)resourceLoadStatisticsEnabled;
     207- (void)setResourceLoadStatisticsEnabled:(BOOL)enabled;
     208
    206209- (BOOL)canvasUsesAcceleratedDrawing;
    207210- (void)setCanvasUsesAcceleratedDrawing:(BOOL)enabled;
  • trunk/Source/WebKit/mac/WebView/WebView.mm

    r196551 r196622  
    169169#import <WebCore/RenderWidget.h>
    170170#import <WebCore/ResourceHandle.h>
     171#import <WebCore/ResourceLoadObserver.h>
    171172#import <WebCore/ResourceRequest.h>
    172173#import <WebCore/RuntimeApplicationChecks.h>
     
    747748
    748749    webApplicationCacheStorage().setCacheDirectory(cacheDir);
     750   
     751    initialized = YES;
     752}
     753
     754static void WebKitInitializeApplicationStatisticsStoragePathIfNecessary()
     755{
     756    static BOOL initialized = NO;
     757    if (initialized)
     758        return;
     759   
     760    NSString *appName = [[NSBundle mainBundle] bundleIdentifier];
     761    if (!appName)
     762        appName = [[NSProcessInfo processInfo] processName];
     763   
     764    ASSERT(appName);
     765   
     766    NSString *supportDirectory = [NSString _webkit_localStorageDirectoryWithBundleIdentifier:appName];
     767    ResourceLoadObserver::sharedObserver().setStatisticsStorageDirectory(supportDirectory);
     768   
    749769    initialized = YES;
    750770}
     
    944964        WebKitInitializeStorageIfNecessary();
    945965        WebKitInitializeApplicationCachePathIfNecessary();
     966        WebKitInitializeApplicationStatisticsStoragePathIfNecessary();
    946967#if ENABLE(GAMEPAD)
    947968        WebKitInitializeGamepadProviderIfNecessary();
     
    24532474    settings.setHiddenPageCSSAnimationSuspensionEnabled([preferences hiddenPageCSSAnimationSuspensionEnabled]);
    24542475
     2476    settings.setResourceLoadStatisticsEnabled([preferences resourceLoadStatisticsEnabled]);
     2477    ResourceLoadObserver::sharedObserver().readDataFromDiskIfNeeded();
     2478
    24552479#if ENABLE(GAMEPAD)
    24562480    RuntimeEnabledFeatures::sharedFeatures().setGamepadsEnabled([preferences gamepadsEnabled]);
     
    48204844{   
    48214845    applicationIsTerminating = YES;
     4846
     4847    ResourceLoadObserver::sharedObserver().writeDataToDisk();
    48224848
    48234849    if (fastDocumentTeardownEnabled())
  • trunk/Tools/ChangeLog

    r196601 r196622  
     12016-02-15  Brent Fulgham  <bfulgham@apple.com>
     2
     3        [Mac] Gather some rudimentary statistics during resource load
     4        https://bugs.webkit.org/show_bug.cgi?id=153575
     5        <rdar://problem/24075254>
     6
     7        Reviewed by Brady Eidson.
     8
     9        * MiniBrowser/mac/SettingsController.h:
     10        * MiniBrowser/mac/SettingsController.m:
     11        (-[SettingsController _populateMenu]): Add menu item for new debug flag.
     12        (-[SettingsController toggleResourceLoadStatisticsEnabled:]): Added.
     13        (-[SettingsController resourceLoadStatisticsEnabled]): Added.
     14        * MiniBrowser/mac/WK1BrowserWindowController.m:
     15        (-[WK1BrowserWindowController didChangeSettings]): React to changes in
     16        users's desire to track resource load statistics.
     17
    1182016-02-15  Csaba Osztrogonác  <ossy@webkit.org>
    219
  • trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm

    r195984 r196622  
    10541054        WebStorageDirectoryDefaultsKey: [libraryPath stringByAppendingPathComponent:@"LocalStorage"],
    10551055        WebKitLocalCacheDefaultsKey: [libraryPath stringByAppendingPathComponent:@"LocalCache"],
     1056        WebKitResourceLoadStatisticsDirectoryDefaultsKey: [libraryPath stringByAppendingPathComponent:@"LocalStorage"],
    10561057#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED > 101000
    10571058        // This needs to also be added to argument domain because of <rdar://problem/20210002>.
  • trunk/Tools/MiniBrowser/mac/SettingsController.h

    r194683 r196622  
    11/*
    2  * Copyright (C) 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014-2016 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4949@property (nonatomic, readonly) BOOL acceleratedDrawingEnabled;
    5050@property (nonatomic, readonly) BOOL displayListDrawingEnabled;
     51@property (nonatomic, readonly) BOOL resourceLoadStatisticsEnabled;
    5152@property (nonatomic, readonly) NSString *defaultURL;
    5253
  • trunk/Tools/MiniBrowser/mac/SettingsController.m

    r194683 r196622  
    11/*
    2  * Copyright (C) 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014-2016 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4040static NSString * const AcceleratedDrawingEnabledPreferenceKey = @"AcceleratedDrawingEnabled";
    4141static NSString * const DisplayListDrawingEnabledPreferenceKey = @"DisplayListDrawingEnabled";
     42static NSString * const ResourceLoadStatisticsEnabledPreferenceKey = @"ResourceLoadStatisticsEnabled";
    4243
    4344static NSString * const NonFastScrollableRegionOverlayVisiblePreferenceKey = @"NonFastScrollableRegionOverlayVisible";
     
    141142    [self _addHeaderWithTitle:@"WebKit1-only Settings"];
    142143    [self _addItemWithTitle:@"Enable Subpixel CSSOM Metrics" action:@selector(toggleEnableSubPixelCSSOMMetrics:) indented:YES];
     144    [self _addItemWithTitle:@"Enable Resource Load Statistics" action:@selector(toggleResourceLoadStatisticsEnabled:) indented:NO];
    143145}
    144146
     
    163165    else if (action == @selector(toggleDisplayListDrawingEnabled:))
    164166        [menuItem setState:[self displayListDrawingEnabled] ? NSOnState : NSOffState];
     167    else if (action == @selector(toggleResourceLoadStatisticsEnabled:))
     168        [menuItem setState:[self resourceLoadStatisticsEnabled] ? NSOnState : NSOffState];
    165169    else if (action == @selector(toggleShowTiledScrollingIndicator:))
    166170        [menuItem setState:[self tiledScrollingIndicatorVisible] ? NSOnState : NSOffState];
     
    317321}
    318322
     323- (void)toggleResourceLoadStatisticsEnabled:(id)sender
     324{
     325    [self _toggleBooleanDefault:ResourceLoadStatisticsEnabledPreferenceKey];
     326}
     327
     328- (BOOL)resourceLoadStatisticsEnabled
     329{
     330    return [[NSUserDefaults standardUserDefaults] boolForKey:ResourceLoadStatisticsEnabledPreferenceKey];
     331}
     332
    319333- (void)toggleEnableSubPixelCSSOMMetrics:(id)sender
    320334{
  • trunk/Tools/MiniBrowser/mac/WK1BrowserWindowController.m

    r192801 r196622  
    261261    [[WebPreferences standardPreferences] setSuppressesIncrementalRendering:settings.incrementalRenderingSuppressed];
    262262    [[WebPreferences standardPreferences] setAcceleratedDrawingEnabled:settings.acceleratedDrawingEnabled];
     263    [[WebPreferences standardPreferences] setResourceLoadStatisticsEnabled:settings.resourceLoadStatisticsEnabled];
    263264
    264265    BOOL useTransparentWindows = settings.useTransparentWindows;
Note: See TracChangeset for help on using the changeset viewer.