Add UI process WebRTC runtime logging.
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Mar 2019 21:15:29 +0000 (21:15 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Mar 2019 21:15:29 +0000 (21:15 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196020
<rdar://problem/49071443>

Reviewed by Youenn Fablet.

Source/WebCore:

* inspector/agents/WebConsoleAgent.cpp:
(WebCore::WebConsoleAgent::getLoggingChannels): Deleted.
(WebCore::channelConfigurationForString): Deleted.
(WebCore::WebConsoleAgent::setLoggingChannelLevel): Deleted.
* inspector/agents/WebConsoleAgent.h:
* inspector/agents/page/PageConsoleAgent.cpp:
(WebCore::PageConsoleAgent::PageConsoleAgent): Change 'context' parameter from
WebAgentContext to PageAgentContext. Store the inspected page for later use.
(WebCore::PageConsoleAgent::getLoggingChannels): Moved from WebConsoleAgent.
(WebCore::channelConfigurationForString): Ditto.
(WebCore::PageConsoleAgent::setLoggingChannelLevel): Moved from WebConsoleAgent.
Call the inspected page to actually change the log channel configuration.
* inspector/agents/page/PageConsoleAgent.h:
* page/ChromeClient.h:
* page/Page.cpp:
(WebCore::Page::configureLoggingChannel): New.
* page/Page.h:

Source/WebKit:

* Platform/Logging.cpp:
(WebKit::getLogChannel): New.
* Platform/Logging.h:
* Shared/WebCoreArgumentCoders.h: Add coders for WTFLogChannelState and WTFLogLevel.

Add runtime logging.
* UIProcess/UserMediaPermissionRequestManagerProxy.cpp:
(WebKit::UserMediaPermissionRequestManagerProxy::UserMediaPermissionRequestManagerProxy):
(WebKit::UserMediaPermissionRequestManagerProxy::stopCapture):
(WebKit::UserMediaPermissionRequestManagerProxy::captureDevicesChanged):
(WebKit::UserMediaPermissionRequestManagerProxy::clearCachedState):
(WebKit::UserMediaPermissionRequestManagerProxy::userMediaAccessWasDenied):
(WebKit::UserMediaPermissionRequestManagerProxy::denyRequest):
(WebKit::UserMediaPermissionRequestManagerProxy::userMediaAccessWasGranted):
(WebKit::UserMediaPermissionRequestManagerProxy::resetAccess):
(WebKit::UserMediaPermissionRequestManagerProxy::grantAccess):
(WebKit::UserMediaPermissionRequestManagerProxy::requestUserMediaPermissionForFrame):
(WebKit::UserMediaPermissionRequestManagerProxy::processUserMediaPermissionRequest):
(WebKit::UserMediaPermissionRequestManagerProxy::processUserMediaPermissionInvalidRequest):
(WebKit::UserMediaPermissionRequestManagerProxy::processUserMediaPermissionValidRequest):
(WebKit::UserMediaPermissionRequestManagerProxy::computeFilteredDeviceList):
(WebKit::UserMediaPermissionRequestManagerProxy::enumerateMediaDevicesForFrame):
(WebKit::UserMediaPermissionRequestManagerProxy::captureStateChanged):
(WebKit::UserMediaPermissionRequestManagerProxy::watchdogTimerFired):
(WebKit::UserMediaPermissionRequestManagerProxy::logChannel const):
(WebKit::convertEnumerationToString):

* UIProcess/UserMediaPermissionRequestManagerProxy.h:
(WTF::LogArgument<WebKit::UserMediaPermissionRequestManagerProxy::RequestAction>::toString):
* UIProcess/UserMediaPermissionRequestProxy.cpp:
(WebKit::convertEnumerationToString): Add an enum specialization for logging.

* UIProcess/UserMediaPermissionRequestProxy.h:
(WTF::LogArgument<WebKit::UserMediaPermissionRequestProxy::UserMediaAccessDenialReason>::toString): Ditto.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::logger):
(WebKit::WebPageProxy::configureLoggingChannel):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:

* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::configureLoggingChannel):
* WebProcess/WebCoreSupport/WebChromeClient.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::configureLoggingChannel):
* WebProcess/WebPage/WebPage.h:

Source/WTF:

* wtf/Logger.h:
(WTF::LogArgument::toString): Add long long and unsigned long long variants.

LayoutTests:

* inspector/console/webcore-logging.html:
* inspector/console/webcore-logging-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243328 268f45cc-cd09-0410-ab3c-d52691b4dbfc

28 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector/console/webcore-logging-expected.txt
LayoutTests/inspector/console/webcore-logging.html
Source/WTF/ChangeLog
Source/WTF/wtf/Logger.h
Source/WebCore/ChangeLog
Source/WebCore/inspector/agents/WebConsoleAgent.cpp
Source/WebCore/inspector/agents/WebConsoleAgent.h
Source/WebCore/inspector/agents/page/PageConsoleAgent.cpp
Source/WebCore/inspector/agents/page/PageConsoleAgent.h
Source/WebCore/page/ChromeClient.h
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebKit/ChangeLog
Source/WebKit/Platform/Logging.cpp
Source/WebKit/Platform/Logging.h
Source/WebKit/Shared/WebCoreArgumentCoders.h
Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.cpp
Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.h
Source/WebKit/UIProcess/UserMediaPermissionRequestProxy.cpp
Source/WebKit/UIProcess/UserMediaPermissionRequestProxy.h
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/WebPageProxy.messages.in
Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp
Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h

index f188fdd..7929d00 100644 (file)
@@ -1,3 +1,14 @@
+2019-03-21  Eric Carlson  <eric.carlson@apple.com>
+
+        Add UI process WebRTC runtime logging.
+        https://bugs.webkit.org/show_bug.cgi?id=196020
+        <rdar://problem/49071443>
+
+        Reviewed by Youenn Fablet.
+
+        * inspector/console/webcore-logging.html:
+        * inspector/console/webcore-logging-expected.txt:
+
 2019-03-21  Alex Christensen  <achristensen@webkit.org>
 
         Add SPI to inform applications of WKContentRuleList actions
index a328a52..a160b41 100644 (file)
@@ -16,9 +16,6 @@ PASS: Log channel disabled by default.
 PASS: Log channel has known source.
 PASS: Log channel disabled by default.
 
--- Running test case: Console.Logging.InvalidChannel
-PASS: Logging channel not found
-
 -- Running test case: Console.Logging.InvalidLevel
 PASS: Invalid logging level
 
index 55b90d7..00364c0 100644 (file)
@@ -69,22 +69,6 @@ function test()
     });
 
     suite.addTestCase({
-        name: "Console.Logging.InvalidChannel",
-        description: "setLoggingChannelLevel should reject invalid log channel name.",
-        test(resolve, reject) {
-            ConsoleAgent.setLoggingChannelLevel("DOES_NOT_EXIST", WI.LoggingChannel.Level.Off, (error) => {
-                if (!error) {
-                    InspectorTest.fail("Should have an error with invalid channel.");
-                    reject();
-                    return;
-                }
-                InspectorTest.pass(error);
-                resolve();
-            });
-        }
-    });
-
-    suite.addTestCase({
         name: "Console.Logging.InvalidLevel",
         description: "setLoggingChannelLevel should reject invalid log channel level.",
         test(resolve, reject) {
index cf0f175..a1e080e 100644 (file)
@@ -1,3 +1,14 @@
+2019-03-21  Eric Carlson  <eric.carlson@apple.com>
+
+        Add UI process WebRTC runtime logging.
+        https://bugs.webkit.org/show_bug.cgi?id=196020
+        <rdar://problem/49071443>
+
+        Reviewed by Youenn Fablet.
+
+        * wtf/Logger.h:
+        (WTF::LogArgument::toString): Add long long and unsigned long long variants.
+
 2019-03-20  Simon Fraser  <simon.fraser@apple.com>
 
         Rename ENABLE_ACCELERATED_OVERFLOW_SCROLLING macro to ENABLE_OVERFLOW_SCROLLING_TOUCH
index bb87743..552f9b6 100644 (file)
@@ -36,6 +36,8 @@ struct LogArgument {
     template<typename U = T> static typename std::enable_if<std::is_same<U, unsigned>::value, String>::type toString(unsigned argument) { return String::number(argument); }
     template<typename U = T> static typename std::enable_if<std::is_same<U, unsigned long>::value, String>::type toString(unsigned long argument) { return String::number(argument); }
     template<typename U = T> static typename std::enable_if<std::is_same<U, long>::value, String>::type toString(long argument) { return String::number(argument); }
+    template<typename U = T> static typename std::enable_if<std::is_same<U, unsigned long long>::value, String>::type toString(unsigned long argument) { return String::number(argument); }
+    template<typename U = T> static typename std::enable_if<std::is_same<U, long long>::value, String>::type toString(long argument) { return String::number(argument); }
     template<typename U = T> static typename std::enable_if<std::is_enum<U>::value, String>::type toString(U argument) { return String::number(static_cast<typename std::underlying_type<U>::type>(argument)); }
     template<typename U = T> static typename std::enable_if<std::is_same<U, float>::value, String>::type toString(float argument) { return String::numberToStringFixedPrecision(argument); }
     template<typename U = T> static typename std::enable_if<std::is_same<U, double>::value, String>::type toString(double argument) { return String::numberToStringFixedPrecision(argument); }
index 5b69ad4..15a4e61 100644 (file)
@@ -1,3 +1,29 @@
+2019-03-21  Eric Carlson  <eric.carlson@apple.com>
+
+        Add UI process WebRTC runtime logging.
+        https://bugs.webkit.org/show_bug.cgi?id=196020
+        <rdar://problem/49071443>
+
+        Reviewed by Youenn Fablet.
+
+        * inspector/agents/WebConsoleAgent.cpp:
+        (WebCore::WebConsoleAgent::getLoggingChannels): Deleted.
+        (WebCore::channelConfigurationForString): Deleted.
+        (WebCore::WebConsoleAgent::setLoggingChannelLevel): Deleted.
+        * inspector/agents/WebConsoleAgent.h:
+        * inspector/agents/page/PageConsoleAgent.cpp:
+        (WebCore::PageConsoleAgent::PageConsoleAgent): Change 'context' parameter from 
+        WebAgentContext to PageAgentContext. Store the inspected page for later use.
+        (WebCore::PageConsoleAgent::getLoggingChannels): Moved from WebConsoleAgent.
+        (WebCore::channelConfigurationForString): Ditto.
+        (WebCore::PageConsoleAgent::setLoggingChannelLevel): Moved from WebConsoleAgent.
+        Call the inspected page to actually change the log channel configuration.
+        * inspector/agents/page/PageConsoleAgent.h:
+        * page/ChromeClient.h:
+        * page/Page.cpp:
+        (WebCore::Page::configureLoggingChannel): New.
+        * page/Page.h:
+
 2019-03-21  Andy Estes  <aestes@apple.com>
 
         [iOS] Apple Pay should be available in documents with no user agent scripts
index 5a18f81..d565743 100644 (file)
@@ -48,87 +48,6 @@ WebConsoleAgent::WebConsoleAgent(AgentContext& context)
 {
 }
 
-void WebConsoleAgent::getLoggingChannels(ErrorString&, RefPtr<JSON::ArrayOf<Inspector::Protocol::Console::Channel>>& channels)
-{
-    static const struct ChannelTable {
-        NeverDestroyed<String> name;
-        Inspector::Protocol::Console::ChannelSource source;
-    } channelTable[] = {
-        { MAKE_STATIC_STRING_IMPL("WebRTC"), Inspector::Protocol::Console::ChannelSource::WebRTC },
-        { MAKE_STATIC_STRING_IMPL("Media"), Inspector::Protocol::Console::ChannelSource::Media },
-        { MAKE_STATIC_STRING_IMPL("MediaSource"), Inspector::Protocol::Console::ChannelSource::MediaSource },
-    };
-
-    channels = JSON::ArrayOf<Inspector::Protocol::Console::Channel>::create();
-
-    size_t length = WTF_ARRAY_LENGTH(channelTable);
-    for (size_t i = 0; i < length; ++i) {
-        auto* logChannel = getLogChannel(channelTable[i].name);
-        if (!logChannel)
-            return;
-
-        auto level = Inspector::Protocol::Console::ChannelLevel::Off;
-        if (logChannel->state != WTFLogChannelState::Off) {
-            switch (logChannel->level) {
-            case WTFLogLevel::Always:
-            case WTFLogLevel::Error:
-            case WTFLogLevel::Warning:
-            case WTFLogLevel::Info:
-                level = Inspector::Protocol::Console::ChannelLevel::Basic;
-                break;
-            case WTFLogLevel::Debug:
-                level = Inspector::Protocol::Console::ChannelLevel::Verbose;
-                break;
-            }
-        }
-
-        auto channel = Inspector::Protocol::Console::Channel::create()
-            .setSource(channelTable[i].source)
-            .setLevel(level)
-            .release();
-        channels->addItem(WTFMove(channel));
-    }
-}
-
-static Optional<std::pair<WTFLogChannelState, WTFLogLevel>> channelConfigurationForString(const String& levelString)
-{
-    WTFLogChannelState state;
-    WTFLogLevel level;
-
-    if (equalIgnoringASCIICase(levelString, "off")) {
-        state = WTFLogChannelState::Off;
-        level = WTFLogLevel::Error;
-    } else {
-        state = WTFLogChannelState::On;
-        if (equalIgnoringASCIICase(levelString, "basic"))
-            level = WTFLogLevel::Warning;
-        else if (equalIgnoringASCIICase(levelString, "verbose"))
-            level = WTFLogLevel::Debug;
-        else
-            return WTF::nullopt;
-    }
-
-    return { { state, level } };
-}
-
-void WebConsoleAgent::setLoggingChannelLevel(ErrorString& errorString, const String& channelName, const String& channelLevel)
-{
-    auto* channel = getLogChannel(channelName.utf8().data());
-    if (!channel) {
-        errorString = "Logging channel not found"_s;
-        return;
-    }
-
-    auto configuration = channelConfigurationForString(channelLevel);
-    if (!configuration) {
-        errorString = "Invalid logging level"_s;
-        return;
-    }
-
-    channel->state = configuration.value().first;
-    channel->level = configuration.value().second;
-}
-
 void WebConsoleAgent::frameWindowDiscarded(DOMWindow* window)
 {
     for (auto& message : m_consoleMessages) {
index e49a78f..59be812 100644 (file)
@@ -43,9 +43,6 @@ public:
 
     void frameWindowDiscarded(DOMWindow*);
 
-    void getLoggingChannels(ErrorString&, RefPtr<JSON::ArrayOf<Inspector::Protocol::Console::Channel>>&) final;
-    void setLoggingChannelLevel(ErrorString&, const String& channel, const String& level) final;
-
     void didReceiveResponse(unsigned long requestIdentifier, const ResourceResponse&);
     void didFailLoading(unsigned long requestIdentifier, const ResourceError&);
 };
index f717ea7..2dd1c8f 100644 (file)
@@ -42,9 +42,10 @@ namespace WebCore {
 
 using namespace Inspector;
 
-PageConsoleAgent::PageConsoleAgent(WebAgentContext& context)
+PageConsoleAgent::PageConsoleAgent(PageAgentContext& context)
     : WebConsoleAgent(context)
     , m_instrumentingAgents(context.instrumentingAgents)
+    , m_inspectedPage(context.inspectedPage)
 {
 }
 
@@ -56,4 +57,71 @@ void PageConsoleAgent::clearMessages(ErrorString& errorString)
     WebConsoleAgent::clearMessages(errorString);
 }
 
+void PageConsoleAgent::getLoggingChannels(ErrorString&, RefPtr<JSON::ArrayOf<Inspector::Protocol::Console::Channel>>& channels)
+{
+    static const struct ChannelTable {
+        NeverDestroyed<String> name;
+        Inspector::Protocol::Console::ChannelSource source;
+    } channelTable[] = {
+        { MAKE_STATIC_STRING_IMPL("WebRTC"), Inspector::Protocol::Console::ChannelSource::WebRTC },
+        { MAKE_STATIC_STRING_IMPL("Media"), Inspector::Protocol::Console::ChannelSource::Media },
+        { MAKE_STATIC_STRING_IMPL("MediaSource"), Inspector::Protocol::Console::ChannelSource::MediaSource },
+    };
+
+    channels = JSON::ArrayOf<Inspector::Protocol::Console::Channel>::create();
+
+    size_t length = WTF_ARRAY_LENGTH(channelTable);
+    for (size_t i = 0; i < length; ++i) {
+        auto* logChannel = getLogChannel(channelTable[i].name);
+        if (!logChannel)
+            return;
+
+        auto level = Inspector::Protocol::Console::ChannelLevel::Off;
+        if (logChannel->state != WTFLogChannelState::Off) {
+            switch (logChannel->level) {
+            case WTFLogLevel::Always:
+            case WTFLogLevel::Error:
+            case WTFLogLevel::Warning:
+            case WTFLogLevel::Info:
+                level = Inspector::Protocol::Console::ChannelLevel::Basic;
+                break;
+            case WTFLogLevel::Debug:
+                level = Inspector::Protocol::Console::ChannelLevel::Verbose;
+                break;
+            }
+        }
+
+        auto channel = Inspector::Protocol::Console::Channel::create()
+            .setSource(channelTable[i].source)
+            .setLevel(level)
+            .release();
+        channels->addItem(WTFMove(channel));
+    }
+}
+
+static Optional<std::pair<WTFLogChannelState, WTFLogLevel>> channelConfigurationForString(const String& levelString)
+{
+    if (equalIgnoringASCIICase(levelString, "off"))
+        return { { WTFLogChannelState::Off, WTFLogLevel::Error } };
+
+    if (equalIgnoringASCIICase(levelString, "basic"))
+        return { { WTFLogChannelState::On, WTFLogLevel::Info } };
+
+    if (equalIgnoringASCIICase(levelString, "verbose"))
+        return { { WTFLogChannelState::On, WTFLogLevel::Debug } };
+
+    return WTF::nullopt;
+}
+
+void PageConsoleAgent::setLoggingChannelLevel(ErrorString& errorString, const String& channelName, const String& channelLevel)
+{
+    auto configuration = channelConfigurationForString(channelLevel);
+    if (!configuration) {
+        errorString = "Invalid logging level"_s;
+        return;
+    }
+
+    m_inspectedPage.configureLoggingChannel(channelName, configuration.value().first, configuration.value().second);
+}
+
 } // namespace WebCore
index ada24fe..dea2494 100644 (file)
@@ -40,13 +40,17 @@ class PageConsoleAgent final : public WebConsoleAgent {
     WTF_MAKE_NONCOPYABLE(PageConsoleAgent);
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    PageConsoleAgent(WebAgentContext&);
+    PageConsoleAgent(PageAgentContext&);
     virtual ~PageConsoleAgent() = default;
 
+    void getLoggingChannels(ErrorString&, RefPtr<JSON::ArrayOf<Inspector::Protocol::Console::Channel>>&) final;
+    void setLoggingChannelLevel(ErrorString&, const String& channel, const String& level) final;
+
 private:
     void clearMessages(ErrorString&) override;
 
     InstrumentingAgents& m_instrumentingAgents;
+    Page& m_inspectedPage;
 };
 
 } // namespace WebCore
index cff2860..0c3cb09 100644 (file)
@@ -45,6 +45,7 @@
 #include "SearchPopupMenu.h"
 #include "WebCoreKeyboardUIMode.h"
 #include <JavaScriptCore/ConsoleTypes.h>
+#include <wtf/Assertions.h>
 #include <wtf/CompletionHandler.h>
 #include <wtf/Forward.h>
 #include <wtf/Seconds.h>
@@ -498,6 +499,8 @@ public:
     virtual void didCreateEditableImage(GraphicsLayer::EmbeddedViewID) { }
     virtual void didDestroyEditableImage(GraphicsLayer::EmbeddedViewID) { }
 
+    virtual void configureLoggingChannel(const String&, WTFLogChannelState, WTFLogLevel) { }
+
 protected:
     virtual ~ChromeClient() = default;
 };
index f3e70df..60559d4 100644 (file)
@@ -2910,4 +2910,20 @@ void Page::setPaymentCoordinator(std::unique_ptr<PaymentCoordinator>&& paymentCo
 }
 #endif
 
+void Page::configureLoggingChannel(const String& channelName, WTFLogChannelState state, WTFLogLevel level)
+{
+#if !RELEASE_LOG_DISABLED
+    if (auto* channel = getLogChannel(channelName)) {
+        channel->state = state;
+        channel->level = level;
+    }
+
+    chrome().client().configureLoggingChannel(channelName, state, level);
+#else
+    UNUSED_PARAM(channelName);
+    UNUSED_PARAM(state);
+    UNUSED_PARAM(level);
+#endif
+}
+
 } // namespace WebCore
index c355258..648683b 100644 (file)
@@ -42,6 +42,7 @@
 #include "WheelEventTestTrigger.h"
 #include <memory>
 #include <pal/SessionID.h>
+#include <wtf/Assertions.h>
 #include <wtf/Forward.h>
 #include <wtf/Function.h>
 #include <wtf/HashSet.h>
@@ -704,6 +705,8 @@ public:
 
     PerformanceLogging& performanceLogging() const { return *m_performanceLogging; }
 
+    void configureLoggingChannel(const String&, WTFLogChannelState, WTFLogLevel);
+
 private:
     struct Navigation {
         RegistrableDomain domain;
index 571efc5..f5c22d4 100644 (file)
@@ -1,3 +1,59 @@
+2019-03-21  Eric Carlson  <eric.carlson@apple.com>
+
+        Add UI process WebRTC runtime logging.
+        https://bugs.webkit.org/show_bug.cgi?id=196020
+        <rdar://problem/49071443>
+
+        Reviewed by Youenn Fablet.
+
+        * Platform/Logging.cpp:
+        (WebKit::getLogChannel): New.
+        * Platform/Logging.h:
+        * Shared/WebCoreArgumentCoders.h: Add coders for WTFLogChannelState and WTFLogLevel.
+
+        Add runtime logging.
+        * UIProcess/UserMediaPermissionRequestManagerProxy.cpp:
+        (WebKit::UserMediaPermissionRequestManagerProxy::UserMediaPermissionRequestManagerProxy):
+        (WebKit::UserMediaPermissionRequestManagerProxy::stopCapture):
+        (WebKit::UserMediaPermissionRequestManagerProxy::captureDevicesChanged):
+        (WebKit::UserMediaPermissionRequestManagerProxy::clearCachedState):
+        (WebKit::UserMediaPermissionRequestManagerProxy::userMediaAccessWasDenied):
+        (WebKit::UserMediaPermissionRequestManagerProxy::denyRequest):
+        (WebKit::UserMediaPermissionRequestManagerProxy::userMediaAccessWasGranted):
+        (WebKit::UserMediaPermissionRequestManagerProxy::resetAccess):
+        (WebKit::UserMediaPermissionRequestManagerProxy::grantAccess):
+        (WebKit::UserMediaPermissionRequestManagerProxy::requestUserMediaPermissionForFrame):
+        (WebKit::UserMediaPermissionRequestManagerProxy::processUserMediaPermissionRequest):
+        (WebKit::UserMediaPermissionRequestManagerProxy::processUserMediaPermissionInvalidRequest):
+        (WebKit::UserMediaPermissionRequestManagerProxy::processUserMediaPermissionValidRequest):
+        (WebKit::UserMediaPermissionRequestManagerProxy::computeFilteredDeviceList):
+        (WebKit::UserMediaPermissionRequestManagerProxy::enumerateMediaDevicesForFrame):
+        (WebKit::UserMediaPermissionRequestManagerProxy::captureStateChanged):
+        (WebKit::UserMediaPermissionRequestManagerProxy::watchdogTimerFired):
+        (WebKit::UserMediaPermissionRequestManagerProxy::logChannel const):
+        (WebKit::convertEnumerationToString):
+
+        * UIProcess/UserMediaPermissionRequestManagerProxy.h:
+        (WTF::LogArgument<WebKit::UserMediaPermissionRequestManagerProxy::RequestAction>::toString):
+        * UIProcess/UserMediaPermissionRequestProxy.cpp:
+        (WebKit::convertEnumerationToString): Add an enum specialization for logging.
+
+        * UIProcess/UserMediaPermissionRequestProxy.h:
+        (WTF::LogArgument<WebKit::UserMediaPermissionRequestProxy::UserMediaAccessDenialReason>::toString): Ditto.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::logger):
+        (WebKit::WebPageProxy::configureLoggingChannel):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::configureLoggingChannel):
+        * WebProcess/WebCoreSupport/WebChromeClient.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::configureLoggingChannel):
+        * WebProcess/WebPage/WebPage.h:
+
 2019-03-21  Alex Christensen  <achristensen@webkit.org>
 
         Stop using LegacySync messages in WebPageProxy
index 5f7d6ee..41d86dc 100644 (file)
@@ -55,6 +55,11 @@ void initializeLogChannelsIfNecessary(Optional<String> logChannelString)
     WTFInitializeLogChannelStatesFromString(logChannels, logChannelCount, enabledChannelsString.utf8().data());
 }
 
+WTFLogChannel* getLogChannel(const String& name)
+{
+    return WTFLogChannelByName(logChannels, logChannelCount, name.utf8().data());
+}
+
 } // namespace WebKit
 
 #endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED
index 96e4361..234e0ae 100644 (file)
@@ -92,6 +92,10 @@ WEBKIT2_LOG_CHANNELS(DECLARE_LOG_CHANNEL)
 
 #undef DECLARE_LOG_CHANNEL
 
+namespace WebKit {
+WTFLogChannel* getLogChannel(const String&);
+} // namespace WebKit
+
 #ifdef __cplusplus
 }
 #endif
index 0bdb9c7..ed027eb 100644 (file)
@@ -865,4 +865,25 @@ template <> struct EnumTraits<WebCore::CurlProxySettings::Mode> {
 };
 #endif
 
+template<> struct EnumTraits<WTFLogChannelState> {
+    using values = EnumValues<
+    WTFLogChannelState,
+    WTFLogChannelState::Off,
+    WTFLogChannelState::On,
+    WTFLogChannelState::OnWithAccumulation
+    >;
+};
+
+#undef Always
+template<> struct EnumTraits<WTFLogLevel> {
+    using values = EnumValues<
+    WTFLogLevel,
+    WTFLogLevel::Always,
+    WTFLogLevel::Error,
+    WTFLogLevel::Warning,
+    WTFLogLevel::Info,
+    WTFLogLevel::Debug
+    >;
+};
+
 } // namespace WTF
index 440c30b..1993372 100644 (file)
@@ -23,6 +23,7 @@
 #include "APISecurityOrigin.h"
 #include "APIUIClient.h"
 #include "DeviceIdHashSaltStorage.h"
+#include "Logging.h"
 #include "UserMediaPermissionRequestManager.h"
 #include "UserMediaProcessManager.h"
 #include "WebAutomationSession.h"
@@ -69,6 +70,10 @@ UserMediaPermissionRequestManagerProxy::UserMediaPermissionRequestManagerProxy(W
     : m_page(page)
     , m_rejectionTimer(RunLoop::main(), this, &UserMediaPermissionRequestManagerProxy::rejectionTimerFired)
     , m_watchdogTimer(RunLoop::main(), this, &UserMediaPermissionRequestManagerProxy::watchdogTimerFired)
+#if !RELEASE_LOG_DISABLED
+    , m_logger(page.logger())
+    , m_logIdentifier(uniqueLogIdentifier())
+#endif
 {
 #if ENABLE(MEDIA_STREAM)
     proxies().add(this);
@@ -95,6 +100,7 @@ void UserMediaPermissionRequestManagerProxy::invalidatePendingRequests()
 
 void UserMediaPermissionRequestManagerProxy::stopCapture()
 {
+    ALWAYS_LOG(LOGIDENTIFIER);
     invalidatePendingRequests();
     m_page.stopMediaCapture();
 }
@@ -102,6 +108,7 @@ void UserMediaPermissionRequestManagerProxy::stopCapture()
 void UserMediaPermissionRequestManagerProxy::captureDevicesChanged()
 {
 #if ENABLE(MEDIA_STREAM)
+    ALWAYS_LOG(LOGIDENTIFIER);
     if (!m_page.hasRunningProcess() || !m_page.mainFrame())
         return;
 
@@ -122,6 +129,7 @@ void UserMediaPermissionRequestManagerProxy::captureDevicesChanged()
 
 void UserMediaPermissionRequestManagerProxy::clearCachedState()
 {
+    ALWAYS_LOG(LOGIDENTIFIER);
     invalidatePendingRequests();
 }
 
@@ -155,6 +163,8 @@ void UserMediaPermissionRequestManagerProxy::userMediaAccessWasDenied(uint64_t u
     if (!m_page.hasRunningProcess())
         return;
 
+    ALWAYS_LOG(LOGIDENTIFIER, userMediaID, ", reason: ", reason);
+
     auto request = m_pendingUserMediaRequests.take(userMediaID);
     if (!request)
         return;
@@ -169,6 +179,8 @@ void UserMediaPermissionRequestManagerProxy::denyRequest(uint64_t userMediaID, U
 {
     ASSERT(m_page.hasRunningProcess());
 
+    ALWAYS_LOG(LOGIDENTIFIER, userMediaID, ", reason: ", reason);
+
 #if ENABLE(MEDIA_STREAM)
     m_page.process().send(Messages::WebPage::UserMediaAccessWasDenied(userMediaID, toWebCore(reason), invalidConstraint), m_page.pageID());
 #else
@@ -185,18 +197,22 @@ void UserMediaPermissionRequestManagerProxy::userMediaAccessWasGranted(uint64_t
         return;
 
 #if ENABLE(MEDIA_STREAM)
+    auto logSiteIdentifier = LOGIDENTIFIER;
+    ALWAYS_LOG(logSiteIdentifier, userMediaID, ", video: ", videoDevice ? videoDevice.label() : "", ", audio: ", audioDevice ? audioDevice.label() : " ");
+
     auto request = m_pendingUserMediaRequests.take(userMediaID);
     if (!request)
         return;
 
     auto& userMediaDocumentSecurityOrigin = request->userMediaDocumentSecurityOrigin();
     auto& topLevelDocumentSecurityOrigin = request->topLevelDocumentSecurityOrigin();
-    m_page.websiteDataStore().deviceIdHashSaltStorage().deviceIdHashSaltForOrigin(userMediaDocumentSecurityOrigin, topLevelDocumentSecurityOrigin, [this, weakThis = makeWeakPtr(*this), request = request.releaseNonNull()] (String&& deviceIDHashSalt) mutable {
+    m_page.websiteDataStore().deviceIdHashSaltStorage().deviceIdHashSaltForOrigin(userMediaDocumentSecurityOrigin, topLevelDocumentSecurityOrigin, [this, weakThis = makeWeakPtr(*this), request = request.releaseNonNull(), logSiteIdentifier] (String&& deviceIDHashSalt) mutable {
         if (!weakThis)
             return;
         if (!grantAccess(request))
             return;
 
+        ALWAYS_LOG(logSiteIdentifier, deviceIDHashSalt);
         m_grantedRequests.append(WTFMove(request));
         if (m_hasFilteredDeviceList)
             captureDevicesChanged();
@@ -212,6 +228,7 @@ void UserMediaPermissionRequestManagerProxy::userMediaAccessWasGranted(uint64_t
 #if ENABLE(MEDIA_STREAM)
 void UserMediaPermissionRequestManagerProxy::resetAccess(uint64_t frameID)
 {
+    ALWAYS_LOG(LOGIDENTIFIER, frameID);
     m_grantedRequests.removeAllMatching([frameID](const auto& grantedRequest) {
         return grantedRequest->mainFrameID() == frameID;
     });
@@ -272,6 +289,7 @@ bool UserMediaPermissionRequestManagerProxy::wasRequestDenied(uint64_t mainFrame
 
 bool UserMediaPermissionRequestManagerProxy::grantAccess(const UserMediaPermissionRequestProxy& request)
 {
+    ALWAYS_LOG(LOGIDENTIFIER, request.userMediaID());
     if (!UserMediaProcessManager::singleton().willCreateMediaStream(*this, request.hasAudioDevice(), request.hasVideoDevice())) {
         denyRequest(request.userMediaID(), UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::OtherFailure, "Unable to extend sandbox.");
         return false;
@@ -322,7 +340,10 @@ UserMediaPermissionRequestManagerProxy::RequestAction UserMediaPermissionRequest
 void UserMediaPermissionRequestManagerProxy::requestUserMediaPermissionForFrame(uint64_t userMediaID, uint64_t frameID, Ref<SecurityOrigin>&& userMediaDocumentOrigin, Ref<SecurityOrigin>&& topLevelDocumentOrigin, MediaStreamRequest&& userRequest)
 {
 #if ENABLE(MEDIA_STREAM)
+    auto logSiteIdentifier = LOGIDENTIFIER;
+
     if (!UserMediaProcessManager::singleton().captureEnabled()) {
+        ALWAYS_LOG(logSiteIdentifier, "capture disabled");
         m_pendingRejections.append(userMediaID);
         scheduleNextRejection();
         return;
@@ -331,11 +352,13 @@ void UserMediaPermissionRequestManagerProxy::requestUserMediaPermissionForFrame(
     if (!m_page.hasRunningProcess())
         return;
 
+    ALWAYS_LOG(logSiteIdentifier, userMediaID);
+
     auto request = m_pendingUserMediaRequests.add(userMediaID, UserMediaPermissionRequestProxy::create(*this, userMediaID, m_page.mainFrame()->frameID(), frameID, WTFMove(userMediaDocumentOrigin), WTFMove(topLevelDocumentOrigin), { }, { }, WTFMove(userRequest))).iterator->value.copyRef();
 
     auto& userMediaOrigin = request->userMediaDocumentSecurityOrigin();
     auto& topLevelOrigin = request->topLevelDocumentSecurityOrigin();
-    getUserMediaPermissionInfo(frameID, userMediaOrigin, topLevelOrigin, [this, request = request.releaseNonNull()](Optional<bool> hasPersistentAccess) mutable {
+    getUserMediaPermissionInfo(frameID, userMediaOrigin, topLevelOrigin, [this, request = request.releaseNonNull(), logSiteIdentifier](Optional<bool> hasPersistentAccess) mutable {
         if (!request->isPending())
             return;
 
@@ -344,12 +367,15 @@ void UserMediaPermissionRequestManagerProxy::requestUserMediaPermissionForFrame(
             return;
         }
 
+        ALWAYS_LOG(logSiteIdentifier, request->userMediaID(), ", persistent access: ", *hasPersistentAccess);
         processUserMediaPermissionRequest(WTFMove(request), *hasPersistentAccess);
     });
 }
 
 void UserMediaPermissionRequestManagerProxy::processUserMediaPermissionRequest(Ref<UserMediaPermissionRequestProxy>&& request, bool hasPersistentAccess)
 {
+    ALWAYS_LOG(LOGIDENTIFIER, request->userMediaID());
+
     if (hasPersistentAccess)
         request->setHasPersistentAccess();
 
@@ -395,6 +421,7 @@ void UserMediaPermissionRequestManagerProxy::processUserMediaPermissionRequest(R
 #if ENABLE(MEDIA_STREAM)
 void UserMediaPermissionRequestManagerProxy::processUserMediaPermissionInvalidRequest(const UserMediaPermissionRequestProxy& request, const String& invalidConstraint)
 {
+    ALWAYS_LOG(LOGIDENTIFIER, request.userMediaID());
     bool filterConstraint = !request.hasPersistentAccess() && !wasGrantedVideoOrAudioAccess(request.frameID(), request.userMediaDocumentSecurityOrigin(), request.topLevelDocumentSecurityOrigin());
 
     denyRequest(request.userMediaID(), UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::InvalidConstraint, filterConstraint ? String { } : invalidConstraint);
@@ -402,6 +429,7 @@ void UserMediaPermissionRequestManagerProxy::processUserMediaPermissionInvalidRe
 
 void UserMediaPermissionRequestManagerProxy::processUserMediaPermissionValidRequest(Ref<UserMediaPermissionRequestProxy>&& request, Vector<CaptureDevice>&& audioDevices, Vector<CaptureDevice>&& videoDevices, String&& deviceIdentifierHashSalt)
 {
+    ALWAYS_LOG(LOGIDENTIFIER, request->userMediaID(), ", video:, ", videoDevices.size(), " audio: ", audioDevices.size());
     if (videoDevices.isEmpty() && audioDevices.isEmpty()) {
         denyRequest(request->userMediaID(), UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::NoConstraints, emptyString());
         return;
@@ -412,6 +440,8 @@ void UserMediaPermissionRequestManagerProxy::processUserMediaPermissionValidRequ
     request->setEligibleAudioDeviceUIDs(WTFMove(audioDevices));
 
     auto action = getRequestAction(request);
+    ALWAYS_LOG(LOGIDENTIFIER, request->userMediaID(), ", action: ", action);
+
     if (action == RequestAction::Deny) {
         denyRequest(request->userMediaID(), UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::PermissionDenied, emptyString());
         return;
@@ -430,6 +460,7 @@ void UserMediaPermissionRequestManagerProxy::processUserMediaPermissionValidRequ
 
     if (m_page.isControlledByAutomation()) {
         if (WebAutomationSession* automationSession = m_page.process().processPool().automationSession()) {
+            ALWAYS_LOG(LOGIDENTIFIER, request->userMediaID(), ", page controlled by automation");
             if (automationSession->shouldAllowGetUserMediaForPage(m_page))
                 request->allow();
             else
@@ -440,6 +471,7 @@ void UserMediaPermissionRequestManagerProxy::processUserMediaPermissionValidRequ
     }
 
     if (m_page.preferences().mockCaptureDevicesEnabled() && !m_page.preferences().mockCaptureDevicesPromptEnabled()) {
+        ALWAYS_LOG(LOGIDENTIFIER, request->userMediaID(), ", mock devices don't require prompt");
         request->allow();
         return;
     }
@@ -541,6 +573,8 @@ Vector<CaptureDevice> UserMediaPermissionRequestManagerProxy::computeFilteredDev
     }
 
     m_hasFilteredDeviceList = !revealIdsAndLabels;
+
+    ALWAYS_LOG(LOGIDENTIFIER, filteredDevices.size(), " devices revealed");
     return filteredDevices;
 }
 #endif
@@ -548,6 +582,8 @@ Vector<CaptureDevice> UserMediaPermissionRequestManagerProxy::computeFilteredDev
 void UserMediaPermissionRequestManagerProxy::enumerateMediaDevicesForFrame(uint64_t userMediaID, uint64_t frameID, Ref<SecurityOrigin>&& userMediaDocumentOrigin, Ref<SecurityOrigin>&& topLevelDocumentOrigin)
 {
 #if ENABLE(MEDIA_STREAM)
+    ALWAYS_LOG(LOGIDENTIFIER, userMediaID);
+
     auto completionHandler = [this, userMediaID, frameID, userMediaDocumentOrigin = userMediaDocumentOrigin.copyRef(), topLevelDocumentOrigin = topLevelDocumentOrigin.copyRef()](Optional<bool> originHasPersistentAccess) mutable {
         if (!originHasPersistentAccess)
             return;
@@ -611,6 +647,7 @@ void UserMediaPermissionRequestManagerProxy::captureStateChanged(MediaProducer::
     if (m_captureState == (newState & activeCaptureMask))
         return;
 
+    ALWAYS_LOG(LOGIDENTIFIER, "state was: ", m_captureState, ", is now: ", newState & activeCaptureMask);
     m_captureState = newState & activeCaptureMask;
 
     Seconds interval;
@@ -622,6 +659,7 @@ void UserMediaPermissionRequestManagerProxy::captureStateChanged(MediaProducer::
     if (interval == m_currentWatchdogInterval)
         return;
 
+    ALWAYS_LOG(LOGIDENTIFIER, "watchdog set to ", interval.value());
     m_currentWatchdogInterval = interval;
     m_watchdogTimer.startOneShot(m_currentWatchdogInterval);
 #endif
@@ -636,10 +674,37 @@ void UserMediaPermissionRequestManagerProxy::viewIsBecomingVisible()
 
 void UserMediaPermissionRequestManagerProxy::watchdogTimerFired()
 {
+    ALWAYS_LOG(LOGIDENTIFIER);
     m_grantedRequests.clear();
     m_pregrantedRequests.clear();
     m_currentWatchdogInterval = 0_s;
     m_hasFilteredDeviceList = false;
 }
 
+#if !RELEASE_LOG_DISABLED
+WTFLogChannel& UserMediaPermissionRequestManagerProxy::logChannel() const
+{
+    return WebKit2LogWebRTC;
+}
+
+const Logger& UserMediaPermissionRequestManagerProxy::logger() const
+{
+    return m_page.logger();
+}
+#endif
+
+String convertEnumerationToString(UserMediaPermissionRequestManagerProxy::RequestAction enumerationValue)
+{
+    static const NeverDestroyed<String> values[] = {
+        MAKE_STATIC_STRING_IMPL("Deny"),
+        MAKE_STATIC_STRING_IMPL("Grant"),
+        MAKE_STATIC_STRING_IMPL("Prompt"),
+    };
+    static_assert(static_cast<size_t>(UserMediaPermissionRequestManagerProxy::RequestAction::Deny) == 0, "UserMediaPermissionRequestManagerProxy::RequestAction::Deny is not 0 as expected");
+    static_assert(static_cast<size_t>(UserMediaPermissionRequestManagerProxy::RequestAction::Grant) == 1, "UserMediaPermissionRequestManagerProxy::RequestAction::Grant is not 1 as expected");
+    static_assert(static_cast<size_t>(UserMediaPermissionRequestManagerProxy::RequestAction::Prompt) == 2, "UserMediaPermissionRequestManagerProxy::RequestAction::Prompt is not 2 as expected");
+    ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));
+    return values[static_cast<size_t>(enumerationValue)];
+}
+
 } // namespace WebKit
index 88bf498..d87af41 100644 (file)
@@ -25,6 +25,7 @@
 #include <WebCore/SecurityOrigin.h>
 #include <wtf/CompletionHandler.h>
 #include <wtf/HashMap.h>
+#include <wtf/LoggerHelper.h>
 #include <wtf/RunLoop.h>
 #include <wtf/Seconds.h>
 #include <wtf/WeakPtr.h>
@@ -40,7 +41,12 @@ namespace WebKit {
 
 class WebPageProxy;
 
-class UserMediaPermissionRequestManagerProxy : public CanMakeWeakPtr<UserMediaPermissionRequestManagerProxy> {
+class UserMediaPermissionRequestManagerProxy
+    : public CanMakeWeakPtr<UserMediaPermissionRequestManagerProxy>
+#if !RELEASE_LOG_DISABLED
+    , private LoggerHelper
+#endif
+{
 public:
     explicit UserMediaPermissionRequestManagerProxy(WebPageProxy&);
     ~UserMediaPermissionRequestManagerProxy();
@@ -72,7 +78,20 @@ public:
     void captureStateChanged(WebCore::MediaProducer::MediaStateFlags oldState, WebCore::MediaProducer::MediaStateFlags newState);
     void syncWithWebCorePrefs() const;
 
+    enum class RequestAction {
+        Deny,
+        Grant,
+        Prompt
+    };
+
 private:
+#if !RELEASE_LOG_DISABLED
+    const Logger& logger() const final;
+    const void* logIdentifier() const final { return m_logIdentifier; }
+    const char* logClassName() const override { return "UserMediaPermissionRequestManagerProxy"; }
+    WTFLogChannel& logChannel() const final;
+#endif
+
     Ref<UserMediaPermissionRequestProxy> createPermissionRequest(uint64_t userMediaID, uint64_t mainFrameID, uint64_t frameID, Ref<WebCore::SecurityOrigin>&& userMediaDocumentOrigin, Ref<WebCore::SecurityOrigin>&& topLevelDocumentOrigin, Vector<WebCore::CaptureDevice>&& audioDevices, Vector<WebCore::CaptureDevice>&& videoDevices, WebCore::MediaStreamRequest&&);
     void denyRequest(uint64_t userMediaID, UserMediaPermissionRequestProxy::UserMediaAccessDenialReason, const String& invalidConstraint);
 #if ENABLE(MEDIA_STREAM)
@@ -83,11 +102,6 @@ private:
 
     void getUserMediaPermissionInfo(uint64_t frameID, Ref<WebCore::SecurityOrigin>&& userMediaDocumentOrigin, Ref<WebCore::SecurityOrigin>&& topLevelDocumentOrigin, CompletionHandler<void(Optional<bool>)>&&);
 
-    enum class RequestAction {
-        Deny,
-        Grant,
-        Prompt
-    };
     RequestAction getRequestAction(const UserMediaPermissionRequestProxy&);
 
     bool wasGrantedVideoOrAudioAccess(uint64_t, const WebCore::SecurityOrigin& userMediaDocumentOrigin, const WebCore::SecurityOrigin& topLevelDocumentOrigin);
@@ -125,8 +139,30 @@ private:
     WebCore::MediaProducer::MediaStateFlags m_captureState { WebCore::MediaProducer::IsNotPlaying };
     RunLoop::Timer<UserMediaPermissionRequestManagerProxy> m_watchdogTimer;
     Seconds m_currentWatchdogInterval;
+#if !RELEASE_LOG_DISABLED
+    Ref<const Logger> m_logger;
+    const void* m_logIdentifier;
+#endif
     bool m_hasFilteredDeviceList { false };
 };
 
+String convertEnumerationToString(UserMediaPermissionRequestManagerProxy::RequestAction);
+
 } // namespace WebKit
 
+#if ENABLE(MEDIA_STREAM)
+namespace WTF {
+
+template<typename Type>
+struct LogArgument;
+
+template <>
+struct LogArgument<WebKit::UserMediaPermissionRequestManagerProxy::RequestAction> {
+    static String toString(const WebKit::UserMediaPermissionRequestManagerProxy::RequestAction type)
+    {
+        return convertEnumerationToString(type);
+    }
+};
+
+}; // namespace WTF
+#endif
index 528fbc2..563bc8f 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2014 Igalia S.L.
- * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
@@ -136,4 +136,26 @@ Vector<String> UserMediaPermissionRequestProxy::audioDeviceUIDs() const
     });
 }
 
+String convertEnumerationToString(UserMediaPermissionRequestProxy::UserMediaAccessDenialReason enumerationValue)
+{
+    static const NeverDestroyed<String> values[] = {
+        MAKE_STATIC_STRING_IMPL("NoConstraints"),
+        MAKE_STATIC_STRING_IMPL("UserMediaDisabled"),
+        MAKE_STATIC_STRING_IMPL("NoCaptureDevices"),
+        MAKE_STATIC_STRING_IMPL("InvalidConstraint"),
+        MAKE_STATIC_STRING_IMPL("HardwareError"),
+        MAKE_STATIC_STRING_IMPL("PermissionDenied"),
+        MAKE_STATIC_STRING_IMPL("OtherFailure"),
+    };
+    static_assert(static_cast<size_t>(UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::NoConstraints) == 0, "UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::NoConstraints is not 0 as expected");
+    static_assert(static_cast<size_t>(UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::UserMediaDisabled) == 1, "UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::UserMediaDisabled is not 1 as expected");
+    static_assert(static_cast<size_t>(UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::NoCaptureDevices) == 2, "UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::NoCaptureDevices is not 2 as expected");
+    static_assert(static_cast<size_t>(UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::InvalidConstraint) == 3, "UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::InvalidConstraint is not 3 as expected");
+    static_assert(static_cast<size_t>(UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::HardwareError) == 4, "UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::HardwareError is not 4 as expected");
+    static_assert(static_cast<size_t>(UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::PermissionDenied) == 5, "UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::PermissionDenied is not 5 as expected");
+    static_assert(static_cast<size_t>(UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::OtherFailure) == 6, "UserMediaPermissionRequestProxy::UserMediaAccessDenialReason::OtherFailure is not 6 as expected");
+    ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));
+    return values[static_cast<size_t>(enumerationValue)];
+}
+
 } // namespace WebKit
index 067f802..f0a1420 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2014 Igalia S.L.
- * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public
@@ -100,4 +100,22 @@ private:
     String m_deviceIdentifierHashSalt;
 };
 
+String convertEnumerationToString(UserMediaPermissionRequestProxy::UserMediaAccessDenialReason);
+
 } // namespace WebKit
+
+namespace WTF {
+
+template<typename Type>
+struct LogArgument;
+
+template <>
+struct LogArgument<WebKit::UserMediaPermissionRequestProxy::UserMediaAccessDenialReason> {
+    static String toString(const WebKit::UserMediaPermissionRequestProxy::UserMediaAccessDenialReason type)
+    {
+        return convertEnumerationToString(type);
+    }
+};
+
+}; // namespace WTF
+
index 33536cc..e91273d 100644 (file)
@@ -798,6 +798,9 @@ void WebPageProxy::swapToWebProcess(Ref<WebProcessProxy>&& process, std::unique_
     m_process = WTFMove(process);
     m_websiteDataStore = m_process->websiteDataStore();
 
+    if (m_logger)
+        m_logger->setEnabled(this, isAlwaysOnLoggingAllowed());
+
     ASSERT(!m_drawingArea);
     setDrawingArea(WTFMove(drawingArea));
     ASSERT(!m_mainFrame);
@@ -8946,6 +8949,32 @@ void WebPageProxy::focusTextInputContext(const TextInputContext& context, Comple
     m_process->connection()->sendWithAsyncReply(Messages::WebPage::FocusTextInputContext(context), WTFMove(completionHandler), m_pageID);
 }
 
+Logger& WebPageProxy::logger()
+{
+    if (!m_logger) {
+        m_logger = Logger::create(this);
+        m_logger->setEnabled(this, isAlwaysOnLoggingAllowed());
+    }
+
+    return *m_logger;
+}
+
+void WebPageProxy::configureLoggingChannel(const String& channelName, WTFLogChannelState state, WTFLogLevel level)
+{
+#if !RELEASE_LOG_DISABLED
+    auto* channel = getLogChannel(channelName);
+    if  (!channel)
+        return;
+
+    channel->state = state;
+    channel->level = level;
+#else
+    UNUSED_PARAM(channelName);
+    UNUSED_PARAM(state);
+    UNUSED_PARAM(level);
+#endif
+}
+
 } // namespace WebKit
 
 #undef MERGE_WHEEL_EVENTS
index a2b7716..699e36b 100644 (file)
@@ -95,6 +95,7 @@
 #include <wtf/CompletionHandler.h>
 #include <wtf/HashMap.h>
 #include <wtf/HashSet.h>
+#include <wtf/Logger.h>
 #include <wtf/MonotonicTime.h>
 #include <wtf/Optional.h>
 #include <wtf/ProcessID.h>
@@ -1500,6 +1501,8 @@ public:
     void speechSynthesisResume(CompletionHandler<void()>&&);
 #endif
 
+    void configureLoggingChannel(const String&, WTFLogChannelState, WTFLogLevel);
+
     void addObserver(WebViewDidMoveToWindowObserver&);
     void removeObserver(WebViewDidMoveToWindowObserver&);
     void webViewDidMoveToWindow();
@@ -1508,6 +1511,8 @@ public:
 WEBPAGEPROXY_LOADOPTIMIZER_ADDITIONS_1
 #endif
 
+    Logger& logger();
+
     // IPC::MessageReceiver
     // Implemented in generated WebPageProxyMessageReceiver.cpp
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
@@ -2458,7 +2463,9 @@ WEBPAGEPROXY_LOADOPTIMIZER_ADDITIONS_2
 #endif
 
     HashMap<WebViewDidMoveToWindowObserver*, WeakPtr<WebViewDidMoveToWindowObserver>> m_webViewDidMoveToWindowObservers;
-    
+
+    mutable RefPtr<Logger> m_logger;
+
 #if ENABLE(SPEECH_SYNTHESIS)
     struct SpeechSynthesisData {
         std::unique_ptr<WebCore::PlatformSpeechSynthesizer> synthesizer;
index 0430c65..e1cc096 100644 (file)
@@ -558,4 +558,6 @@ messages -> WebPageProxy {
     SpeechSynthesisPause() -> () Async
     SpeechSynthesisResume() -> () Async
 #endif
+
+    ConfigureLoggingChannel(String channelName, enum:uint8_t WTFLogChannelState state, enum:uint8_t WTFLogLevel level)
 }
index a18def0..8c8b0fc 100644 (file)
@@ -1325,4 +1325,9 @@ void WebChromeClient::shouldAllowDeviceOrientationAndMotionAccess(Frame& frame,
 }
 #endif
 
+void WebChromeClient::configureLoggingChannel(const String& channelName, WTFLogChannelState state, WTFLogLevel level)
+{
+    m_page.configureLoggingChannel(channelName, state, level);
+}
+
 } // namespace WebKit
index 5992c89..269aa3e 100644 (file)
@@ -370,6 +370,8 @@ private:
     void shouldAllowDeviceOrientationAndMotionAccess(WebCore::Frame&, CompletionHandler<void(bool)>&&) final;
 #endif
 
+    void configureLoggingChannel(const String&, WTFLogChannelState, WTFLogLevel) final;
+
     String m_cachedToolTip;
     mutable RefPtr<WebFrame> m_cachedFrameSetLargestFrame;
     mutable bool m_cachedMainFrameHasHorizontalScrollbar { false };
index 2497ee7..abd7b8e 100644 (file)
@@ -6608,6 +6608,11 @@ void WebPage::focusTextInputContext(const TextInputContext& textInputContext, Co
     }());
 }
 
+void WebPage::configureLoggingChannel(const String& channelName, WTFLogChannelState state, WTFLogLevel level)
+{
+    send(Messages::WebPageProxy::ConfigureLoggingChannel(channelName, state, level));
+}
+
 } // namespace WebKit
 
 #undef RELEASE_LOG_IF_ALLOWED
index c0e8a56..05a5227 100644 (file)
@@ -1164,6 +1164,8 @@ public:
     void suspendAllMediaBuffering();
     void resumeAllMediaBuffering();
 
+    void configureLoggingChannel(const String&, WTFLogChannelState, WTFLogLevel);
+
 #if ENABLE(APPLE_PAY)
     WebPaymentCoordinator* paymentCoordinator();
 #endif