Title: [220780] trunk/Source
Revision
220780
Author
[email protected]
Date
2017-08-15 18:37:30 -0700 (Tue, 15 Aug 2017)

Log 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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (220779 => 220780)


--- trunk/Source/WebCore/ChangeLog	2017-08-16 01:23:50 UTC (rev 220779)
+++ trunk/Source/WebCore/ChangeLog	2017-08-16 01:37:30 UTC (rev 220780)
@@ -1,3 +1,17 @@
+2017-08-15  Simon Fraser  <[email protected]>
+
+        Allow WebCore logging channels to be set from the UI process
+        https://bugs.webkit.org/show_bug.cgi?id=175608
+
+        Reviewed by Tim Horton.
+
+        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):
+
 2017-08-15  Chris Dumez  <[email protected]>
 
         Fetch / Beacon: Use "application/octet-stream" Content-Type for payloads of type ArrayBuffer / ArrayBufferView

Modified: trunk/Source/WebCore/platform/LogInitialization.h (220779 => 220780)


--- trunk/Source/WebCore/platform/LogInitialization.h	2017-08-16 01:23:50 UTC (rev 220779)
+++ trunk/Source/WebCore/platform/LogInitialization.h	2017-08-16 01:37:30 UTC (rev 220780)
@@ -27,6 +27,8 @@
 
 #include <wtf/Assertions.h>
 #include <wtf/Forward.h>
+#include <wtf/Optional.h>
+#include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
@@ -35,7 +37,7 @@
 String logLevelString();
 bool isLogChannelEnabled(const String& name);
 WEBCORE_EXPORT void setLogChannelToAccumulate(const String& name);
-WEBCORE_EXPORT void initializeLogChannelsIfNecessary();
+WEBCORE_EXPORT void initializeLogChannelsIfNecessary(std::optional<String> = std::nullopt);
 
 #endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED
 

Modified: trunk/Source/WebCore/platform/Logging.cpp (220779 => 220780)


--- trunk/Source/WebCore/platform/Logging.cpp	2017-08-16 01:23:50 UTC (rev 220779)
+++ trunk/Source/WebCore/platform/Logging.cpp	2017-08-16 01:37:30 UTC (rev 220780)
@@ -69,14 +69,15 @@
     logChannelsNeedInitialization = true;
 }
 
-void initializeLogChannelsIfNecessary()
+void initializeLogChannelsIfNecessary(std::optional<String> logChannelString)
 {
-    if (!logChannelsNeedInitialization)
+    if (!logChannelsNeedInitialization && !logChannelString)
         return;
 
     logChannelsNeedInitialization = false;
 
-    WTFInitializeLogChannelStatesFromString(logChannels, logChannelCount, logLevelString().utf8().data());
+    String enabledChannelsString = logChannelString ? logChannelString.value() : logLevelString();
+    WTFInitializeLogChannelStatesFromString(logChannels, logChannelCount, enabledChannelsString.utf8().data());
 }
 
 #ifndef NDEBUG

Modified: trunk/Source/WebKit/ChangeLog (220779 => 220780)


--- trunk/Source/WebKit/ChangeLog	2017-08-16 01:23:50 UTC (rev 220779)
+++ trunk/Source/WebKit/ChangeLog	2017-08-16 01:37:30 UTC (rev 220780)
@@ -1,3 +1,24 @@
+2017-08-15  Simon Fraser  <[email protected]>
+
+        Allow WebCore logging channels to be set from the UI process
+        https://bugs.webkit.org/show_bug.cgi?id=175608
+
+        Reviewed by Tim Horton.
+
+        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):
+
 2017-08-15  Don Olmstead  <[email protected]>
 
         [PAL] Move Sleep classes into PAL

Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp (220779 => 220780)


--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp	2017-08-16 01:23:50 UTC (rev 220779)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp	2017-08-16 01:37:30 UTC (rev 220780)
@@ -66,6 +66,7 @@
     encoder << containerTemporaryDirectoryExtensionHandle;
 #endif
     encoder << mediaKeyStorageDirectory;
+    encoder << webCoreLoggingChannels;
     encoder << mediaKeyStorageDirectoryExtensionHandle;
 #if ENABLE(MEDIA_STREAM)
     encoder << audioCaptureExtensionHandle;
@@ -187,6 +188,8 @@
 #endif
     if (!decoder.decode(parameters.mediaKeyStorageDirectory))
         return false;
+    if (!decoder.decode(parameters.webCoreLoggingChannels))
+        return false;
     if (!decoder.decode(parameters.mediaKeyStorageDirectoryExtensionHandle))
         return false;
 #if ENABLE(MEDIA_STREAM)

Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.h (220779 => 220780)


--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.h	2017-08-16 01:23:50 UTC (rev 220779)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.h	2017-08-16 01:37:30 UTC (rev 220780)
@@ -93,6 +93,8 @@
 #endif
     String mediaKeyStorageDirectory;
 
+    String webCoreLoggingChannels;
+
     Vector<String> urlSchemesRegisteredAsEmptyDocument;
     Vector<String> urlSchemesRegisteredAsSecure;
     Vector<String> urlSchemesRegisteredAsBypassingContentSecurityPolicy;

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (220779 => 220780)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2017-08-16 01:23:50 UTC (rev 220779)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2017-08-16 01:37:30 UTC (rev 220780)
@@ -256,6 +256,10 @@
         isSafari = true;
 #endif
 
+#if !LOG_DISABLED || !RELEASE_LOG_DISABLED
+    parameters.webCoreLoggingChannels = [[NSUserDefaults standardUserDefaults] stringForKey:@"WebCoreLogging"];
+#endif
+
     // FIXME: Remove this and related parameter when <rdar://problem/29448368> is fixed.
     if (isSafari && !parameters.shouldCaptureAudioInUIProcess && mediaDevicesEnabled)
         SandboxExtension::createHandleForGenericExtension("com.apple.webkit.microphone", parameters.audioCaptureExtensionHandle);

Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (220779 => 220780)


--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2017-08-16 01:23:50 UTC (rev 220779)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2017-08-16 01:37:30 UTC (rev 220780)
@@ -52,6 +52,7 @@
 #import <WebCore/FontCache.h>
 #import <WebCore/FontCascade.h>
 #import <WebCore/LocalizedStrings.h>
+#import <WebCore/LogInitialization.h>
 #import <WebCore/MemoryRelease.h>
 #import <WebCore/NSAccessibilitySPI.h>
 #import <WebCore/PerformanceLogging.h>
@@ -112,6 +113,10 @@
 
 void WebProcess::platformInitializeWebProcess(WebProcessCreationParameters&& parameters)
 {
+#if !LOG_DISABLED || !RELEASE_LOG_DISABLED
+    WebCore::initializeLogChannelsIfNecessary(parameters.webCoreLoggingChannels);
+#endif
+
     WebCore::setApplicationBundleIdentifier(parameters.uiProcessBundleIdentifier);
     SessionTracker::setIdentifierBase(parameters.uiProcessBundleIdentifier);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to