Changeset 220780 in webkit


Ignore:
Timestamp:
Aug 15, 2017, 6:37:30 PM (9 years ago)
Author:
Simon Fraser
Message:

Allow WebCore logging channels to be set from the UI process
https://bugs.webkit.org/show_bug.cgi?id=175608

Reviewed by Tim Horton.

Source/WebCore:

Change initializeLogChannelsIfNecessary() to take an optional String, which can
be a list of log channels passed from the UI process.

  • platform/LogInitialization.h:
  • platform/Logging.cpp:

(WebCore::initializeLogChannelsIfNecessary):

Source/WebKit:

The UI process can now read the "WebCoreLogging" default, and pass it to the web process
via WebProcessCreationParameters, where WebProcess::platformInitializeWebProcess() uses
it to set up WebCore logging channels. Note that these will override channels read from
the web process user defaults domain (but those are hard to set anyway).

  • Shared/WebProcessCreationParameters.cpp:

(WebKit::WebProcessCreationParameters::encode const):
(WebKit::WebProcessCreationParameters::decode):

  • Shared/WebProcessCreationParameters.h:
  • UIProcess/Cocoa/WebProcessPoolCocoa.mm:

(WebKit::WebProcessPool::platformInitializeWebProcess):

  • WebProcess/cocoa/WebProcessCocoa.mm:

(WebKit::WebProcess::platformInitializeWebProcess):

Location:
trunk/Source
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r220779 r220780  
     12017-08-15  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Allow WebCore logging channels to be set from the UI process
     4        https://bugs.webkit.org/show_bug.cgi?id=175608
     5
     6        Reviewed by Tim Horton.
     7
     8        Change initializeLogChannelsIfNecessary() to take an optional String, which can
     9        be a list of log channels passed from the UI process.
     10
     11        * platform/LogInitialization.h:
     12        * platform/Logging.cpp:
     13        (WebCore::initializeLogChannelsIfNecessary):
     14
    1152017-08-15  Chris Dumez  <cdumez@apple.com>
    216
  • trunk/Source/WebCore/platform/LogInitialization.h

    r205275 r220780  
    2828#include <wtf/Assertions.h>
    2929#include <wtf/Forward.h>
     30#include <wtf/Optional.h>
     31#include <wtf/text/WTFString.h>
    3032
    3133namespace WebCore {
     
    3638bool isLogChannelEnabled(const String& name);
    3739WEBCORE_EXPORT void setLogChannelToAccumulate(const String& name);
    38 WEBCORE_EXPORT void initializeLogChannelsIfNecessary();
     40WEBCORE_EXPORT void initializeLogChannelsIfNecessary(std::optional<String> = std::nullopt);
    3941
    4042#endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED
  • trunk/Source/WebCore/platform/Logging.cpp

    r218615 r220780  
    7070}
    7171
    72 void initializeLogChannelsIfNecessary()
     72void initializeLogChannelsIfNecessary(std::optional<String> logChannelString)
    7373{
    74     if (!logChannelsNeedInitialization)
     74    if (!logChannelsNeedInitialization && !logChannelString)
    7575        return;
    7676
    7777    logChannelsNeedInitialization = false;
    7878
    79     WTFInitializeLogChannelStatesFromString(logChannels, logChannelCount, logLevelString().utf8().data());
     79    String enabledChannelsString = logChannelString ? logChannelString.value() : logLevelString();
     80    WTFInitializeLogChannelStatesFromString(logChannels, logChannelCount, enabledChannelsString.utf8().data());
    8081}
    8182
  • trunk/Source/WebKit/ChangeLog

    r220759 r220780  
     12017-08-15  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Allow WebCore logging channels to be set from the UI process
     4        https://bugs.webkit.org/show_bug.cgi?id=175608
     5
     6        Reviewed by Tim Horton.
     7
     8        The UI process can now read the "WebCoreLogging" default, and pass it to the web process
     9        via WebProcessCreationParameters, where WebProcess::platformInitializeWebProcess() uses
     10        it to set up WebCore logging channels. Note that these will override channels read from
     11        the web process user defaults domain (but those are hard to set anyway).
     12
     13        * Shared/WebProcessCreationParameters.cpp:
     14        (WebKit::WebProcessCreationParameters::encode const):
     15        (WebKit::WebProcessCreationParameters::decode):
     16        * Shared/WebProcessCreationParameters.h:
     17        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
     18        (WebKit::WebProcessPool::platformInitializeWebProcess):
     19        * WebProcess/cocoa/WebProcessCocoa.mm:
     20        (WebKit::WebProcess::platformInitializeWebProcess):
     21
    1222017-08-15  Don Olmstead  <don.olmstead@sony.com>
    223
  • trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp

    r219713 r220780  
    6767#endif
    6868    encoder << mediaKeyStorageDirectory;
     69    encoder << webCoreLoggingChannels;
    6970    encoder << mediaKeyStorageDirectoryExtensionHandle;
    7071#if ENABLE(MEDIA_STREAM)
     
    188189    if (!decoder.decode(parameters.mediaKeyStorageDirectory))
    189190        return false;
     191    if (!decoder.decode(parameters.webCoreLoggingChannels))
     192        return false;
    190193    if (!decoder.decode(parameters.mediaKeyStorageDirectoryExtensionHandle))
    191194        return false;
  • trunk/Source/WebKit/Shared/WebProcessCreationParameters.h

    r219713 r220780  
    9494    String mediaKeyStorageDirectory;
    9595
     96    String webCoreLoggingChannels;
     97
    9698    Vector<String> urlSchemesRegisteredAsEmptyDocument;
    9799    Vector<String> urlSchemesRegisteredAsSecure;
  • trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm

    r220243 r220780  
    257257#endif
    258258
     259#if !LOG_DISABLED || !RELEASE_LOG_DISABLED
     260    parameters.webCoreLoggingChannels = [[NSUserDefaults standardUserDefaults] stringForKey:@"WebCoreLogging"];
     261#endif
     262
    259263    // FIXME: Remove this and related parameter when <rdar://problem/29448368> is fixed.
    260264    if (isSafari && !parameters.shouldCaptureAudioInUIProcess && mediaDevicesEnabled)
  • trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm

    r220506 r220780  
    5353#import <WebCore/FontCascade.h>
    5454#import <WebCore/LocalizedStrings.h>
     55#import <WebCore/LogInitialization.h>
    5556#import <WebCore/MemoryRelease.h>
    5657#import <WebCore/NSAccessibilitySPI.h>
     
    113114void WebProcess::platformInitializeWebProcess(WebProcessCreationParameters&& parameters)
    114115{
     116#if !LOG_DISABLED || !RELEASE_LOG_DISABLED
     117    WebCore::initializeLogChannelsIfNecessary(parameters.webCoreLoggingChannels);
     118#endif
     119
    115120    WebCore::setApplicationBundleIdentifier(parameters.uiProcessBundleIdentifier);
    116121    SessionTracker::setIdentifierBase(parameters.uiProcessBundleIdentifier);
Note: See TracChangeset for help on using the changeset viewer.