Changeset 280758 in webkit
- Timestamp:
- Aug 7, 2021, 11:50:12 AM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 36 edited
- 6 copied
-
WTF/ChangeLog (modified) (1 diff)
-
WTF/WTF.xcodeproj/project.pbxproj (modified) (5 diffs)
-
WTF/wtf/CMakeLists.txt (modified) (2 diffs)
-
WTF/wtf/LogChannels.cpp (copied) (copied from trunk/Source/WebCore/platform/Logging.cpp ) (3 diffs)
-
WTF/wtf/LogChannels.h (copied) (copied from trunk/Source/WebCore/platform/LogInitialization.h ) (2 diffs)
-
WTF/wtf/ThreadSpecific.h (modified) (1 diff)
-
WTF/wtf/Threading.h (modified) (1 diff)
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/Sources.txt (modified) (1 diff)
-
WebCore/WebCore.xcodeproj/project.pbxproj (modified) (2 diffs)
-
WebCore/accessibility/AXLogger.cpp (modified) (1 diff)
-
WebCore/inspector/agents/page/PageConsoleAgent.cpp (modified) (1 diff)
-
WebCore/page/Page.cpp (modified) (1 diff)
-
WebCore/platform/LogInitialization.cpp (copied) (copied from trunk/Source/WebCore/platform/LogInitialization.h ) (3 diffs)
-
WebCore/platform/LogInitialization.h (modified) (3 diffs)
-
WebCore/platform/Logging.cpp (modified) (3 diffs)
-
WebCore/platform/Logging.h (modified) (1 diff)
-
WebCore/testing/js/WebCoreTestSupport.cpp (modified) (4 diffs)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/GPUProcess/GPUConnectionToWebProcess.cpp (modified) (1 diff)
-
WebKit/GPUProcess/GPUProcess.cpp (modified) (1 diff)
-
WebKit/Platform/LogInitialization.cpp (copied) (copied from trunk/Source/WebKit/Shared/WebKit2Initialize.cpp ) (2 diffs)
-
WebKit/Platform/LogInitialization.h (modified) (2 diffs)
-
WebKit/Platform/Logging.cpp (modified) (3 diffs)
-
WebKit/Platform/Logging.h (modified) (2 diffs)
-
WebKit/Shared/AuxiliaryProcess.cpp (modified) (1 diff)
-
WebKit/Shared/WebKit2Initialize.cpp (modified) (1 diff)
-
WebKit/Sources.txt (modified) (1 diff)
-
WebKit/UIProcess/WebPageProxy.cpp (modified) (1 diff)
-
WebKit/UIProcess/WebProcessPool.cpp (modified) (1 diff)
-
WebKit/WebKit.xcodeproj/project.pbxproj (modified) (7 diffs)
-
WebKit/WebProcess/cocoa/WebProcessCocoa.mm (modified) (1 diff)
-
WebKitLegacy/ChangeLog (modified) (1 diff)
-
WebKitLegacy/WebKitLegacy.xcodeproj/project.pbxproj (modified) (4 diffs)
-
WebKitLegacy/mac/ChangeLog (modified) (1 diff)
-
WebKitLegacy/mac/Misc/WebKitLogInitialization.h (copied) (copied from trunk/Source/WebKit/Platform/LogInitialization.h ) (2 diffs)
-
WebKitLegacy/mac/Misc/WebKitLogInitialization.mm (copied) (copied from trunk/Source/WebKitLegacy/mac/Misc/WebKitLogging.m ) (3 diffs)
-
WebKitLegacy/mac/Misc/WebKitLogging.h (modified) (2 diffs)
-
WebKitLegacy/mac/Misc/WebKitLogging.m (modified) (1 diff)
-
WebKitLegacy/mac/WebCoreSupport/WebDragClient.mm (modified) (1 diff)
-
WebKitLegacy/mac/WebView/WebDelegateImplementationCaching.mm (modified) (2 diffs)
-
WebKitLegacy/mac/WebView/WebView.mm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r280757 r280758 1 2021-08-07 Myles C. Maxfield <mmaxfield@apple.com> 2 3 Deduplicate logging channel algorithms 4 https://bugs.webkit.org/show_bug.cgi?id=228809 5 6 Reviewed by Fujii Hironori. 7 8 The current infrastructure (before this patch) had the following duplicated for each framework: 9 - A .cpp file declared the list of logging channels for that framework 10 - The .cpp file also had algorithms to search, modify, and initialize these logging channels 11 12 Each framework's .cpp file had duplicate algorithms. (The initialization algorithm was even 13 duplicated 3 times!) 14 15 Because the algorithms directly name their specific list of logging channels, a naive deduplication 16 would have had to add new parameters to these algorithms to pass in the appropriate framework's 17 list. That's fine, but this is exactly the sort of thing classes were designed for - classes are 18 an association of algorithms and data. The algorithms are shared but the data isn't, which really 19 just means we should have 3 instances of a shared class - one for the 3 sets of data. 20 21 So, this patch creates the LogChannels class which contains the deduplicated algorithms, and each 22 framework has a NeverDestroyed singleton instance of that class. There is a single virtual method 23 in the class, so the appropriate "default write" variable can be queried for each framework. 24 25 The instances cannot be declared in the Logging.h files in the frameworks, because certain WebKit2 26 files want to initialize all 3 instances of LogChannels, but you can't #include multiple Logging.h 27 files at the same time because their LOG_CHANNEL_PREFIX #defines will collide with each other. 28 Luckily, LogInitialization.h files exist exactly to solve this purpose, so that's where the 29 LogChannels instances are declared in. After this change, the Logging.h files are just for the 30 declarations of the logging channels themselves, and the LogInitialization.h files are for the 31 LogChannels instances which contain the searching/modifying/initializing algorithms on the list of 32 logging channels. If you just want to LOG(...) something, #include the relevant Logging.h file, and 33 if you want to search/modify/initialize across the entire list of channels, then #include the 34 relevant LogInitialization.h file. 35 36 * WTF.xcodeproj/project.pbxproj: 37 * wtf/CMakeLists.txt: 38 * wtf/LogChannels.cpp: Copied from Source/WebCore/platform/Logging.cpp. 39 (WTF::LogChannels::isLogChannelEnabled): 40 (WTF::LogChannels::setLogChannelToAccumulate): 41 (WTF::LogChannels::clearAllLogChannelsToAccumulate): 42 (WTF::LogChannels::initializeLogChannelsIfNecessary): 43 (WTF::LogChannels::getLogChannel): 44 * wtf/LogChannels.h: Copied from Source/WebCore/platform/LogInitialization.h. 45 1 46 2021-08-07 Commit Queue <commit-queue@webkit.org> 2 47 -
trunk/Source/WTF/WTF.xcodeproj/project.pbxproj
r280757 r280758 62 62 1C503BE623AAE0AE0072E66B /* LanguageCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C503BE523AAE0AE0072E66B /* LanguageCocoa.mm */; }; 63 63 1CA85CA9241B0B260071C2F5 /* RuntimeApplicationChecksCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1CA85CA8241B0B260071C2F5 /* RuntimeApplicationChecksCocoa.cpp */; }; 64 1CF18F3B26BB579E004B1722 /* LogChannels.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1CF18F3926BB579E004B1722 /* LogChannels.cpp */; }; 64 65 1FA47C8A152502DA00568D1B /* WebCoreThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1FA47C88152502DA00568D1B /* WebCoreThread.cpp */; }; 65 66 2CCD892A15C0390200285083 /* GregorianDateTime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2CCD892915C0390200285083 /* GregorianDateTime.cpp */; }; … … 352 353 1CCDB14D1E566898006C73C0 /* TextBreakIteratorICU.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextBreakIteratorICU.h; sourceTree = "<group>"; }; 353 354 1CCDB1511E566BC5006C73C0 /* CFStringSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFStringSPI.h; sourceTree = "<group>"; }; 355 1CF18F3926BB579E004B1722 /* LogChannels.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LogChannels.cpp; sourceTree = "<group>"; }; 356 1CF18F3A26BB579E004B1722 /* LogChannels.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LogChannels.h; sourceTree = "<group>"; }; 354 357 1FA47C88152502DA00568D1B /* WebCoreThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebCoreThread.cpp; sourceTree = "<group>"; }; 355 358 1FA47C89152502DA00568D1B /* WebCoreThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreThread.h; sourceTree = "<group>"; }; … … 513 516 9BC70F04176C379D00101DEC /* AtomStringTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AtomStringTable.cpp; sourceTree = "<group>"; }; 514 517 9BD8F40A176C2AD80002D865 /* AtomStringTable.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AtomStringTable.h; sourceTree = "<group>"; }; 518 9BE153352671F00F00C7D096 /* WeakHashMap.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WeakHashMap.h; sourceTree = "<group>"; }; 515 519 9BF00134267C4CCF00DCFB3F /* CheckedRef.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CheckedRef.h; sourceTree = "<group>"; }; 516 9BE153352671F00F00C7D096 /* WeakHashMap.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WeakHashMap.h; sourceTree = "<group>"; };517 520 9C67C542589348E285B49699 /* IndexedContainerIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IndexedContainerIterator.h; sourceTree = "<group>"; }; 518 521 A1B89B87221E000F00EB4CEA /* SDKVariant.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = SDKVariant.xcconfig; sourceTree = "<group>"; }; … … 1123 1126 A8A472C3151A825A004123FF /* Locker.h */, 1124 1127 5311BD551EA7E15A00525281 /* LocklessBag.h */, 1128 1CF18F3926BB579E004B1722 /* LogChannels.cpp */, 1129 1CF18F3A26BB579E004B1722 /* LogChannels.h */, 1125 1130 93B5B45022171EE9004B7AA7 /* Logger.cpp */, 1126 1131 077CD86A1FD9CFD200828587 /* Logger.h */, … … 1739 1744 0FE1646A1B6FFC9600400E7C /* Lock.cpp in Sources */, 1740 1745 0F60F32F1DFCBD1B00416D6C /* LockedPrintStream.cpp in Sources */, 1746 1CF18F3B26BB579E004B1722 /* LogChannels.cpp in Sources */, 1741 1747 93B5B45122171EEA004B7AA7 /* Logger.cpp in Sources */, 1742 1748 53534F2A1EC0E10E00141B2F /* MachExceptions.defs in Sources */, -
trunk/Source/WTF/wtf/CMakeLists.txt
r280757 r280758 124 124 Locker.h 125 125 LocklessBag.h 126 LogChannels.h 126 127 Logger.h 127 128 LoggerHelper.h … … 423 424 Lock.cpp 424 425 LockedPrintStream.cpp 426 LogChannels.cpp 425 427 Logger.cpp 426 428 MainThread.cpp -
trunk/Source/WTF/wtf/LogChannels.cpp
r280757 r280758 1 1 /* 2 * Copyright (C) 20 03, 2006, 2013Apple Inc. All rights reserved.2 * Copyright (C) 2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 25 25 26 26 #include "config.h" 27 #include "Logging.h" 28 #include "LogInitialization.h" 27 #include "LogChannels.h" 29 28 30 29 #include <wtf/LoggingAccumulator.h> 31 #include <wtf/StdLibExtras.h>32 #include <wtf/text/CString.h>33 #include <wtf/text/WTFString.h>34 30 35 #if PLATFORM(COCOA) 36 #include <notify.h> 37 #include <wtf/BlockPtr.h> 38 #endif 39 40 namespace WebCore { 31 namespace WTF { 41 32 42 33 #if !LOG_DISABLED || !RELEASE_LOG_DISABLED 43 34 44 #define DEFINE_WEBCORE_LOG_CHANNEL(name) DEFINE_LOG_CHANNEL(name, LOG_CHANNEL_WEBKIT_SUBSYSTEM) 45 WEBCORE_LOG_CHANNELS(DEFINE_WEBCORE_LOG_CHANNEL) 46 47 static WTFLogChannel* logChannels[] = { 48 WEBCORE_LOG_CHANNELS(LOG_CHANNEL_ADDRESS) 49 }; 50 51 static const size_t logChannelCount = WTF_ARRAY_LENGTH(logChannels); 52 53 bool isLogChannelEnabled(const String& name) 35 bool LogChannels::isLogChannelEnabled(const String& name) 54 36 { 55 WTFLogChannel* channel = WTFLogChannelByName(logChannels, logChannelCount, name.utf8().data());37 WTFLogChannel* channel = getLogChannel(name); 56 38 if (!channel) 57 39 return false; … … 59 41 } 60 42 61 static bool logChannelsNeedInitialization = true; 62 63 void setLogChannelToAccumulate(const String& name) 43 void LogChannels::setLogChannelToAccumulate(const String& name) 64 44 { 65 WTFLogChannel* channel = WTFLogChannelByName(logChannels, logChannelCount, name.utf8().data());45 WTFLogChannel* channel = getLogChannel(name); 66 46 if (!channel) 67 47 return; 68 48 69 49 channel->state = WTFLogChannelState::OnWithAccumulation; 70 logChannelsNeedInitialization = true;50 m_logChannelsNeedInitialization = true; 71 51 } 72 52 73 void clearAllLogChannelsToAccumulate()53 void LogChannels::clearAllLogChannelsToAccumulate() 74 54 { 75 55 resetAccumulatedLogs(); 76 for (auto* channel : logChannels) {56 for (auto* channel : m_logChannels) { 77 57 if (channel->state == WTFLogChannelState::OnWithAccumulation) 78 58 channel->state = WTFLogChannelState::Off; 79 59 } 80 60 81 logChannelsNeedInitialization = true;61 m_logChannelsNeedInitialization = true; 82 62 } 83 63 84 void initializeLogChannelsIfNecessary(std::optional<String> logChannelString)64 void LogChannels::initializeLogChannelsIfNecessary(std::optional<String> logChannelString) 85 65 { 86 if (! logChannelsNeedInitialization && !logChannelString)66 if (!m_logChannelsNeedInitialization && !logChannelString) 87 67 return; 88 68 89 logChannelsNeedInitialization = false;69 m_logChannelsNeedInitialization = false; 90 70 91 71 String enabledChannelsString = logChannelString ? logChannelString.value() : logLevelString(); 92 WTFInitializeLogChannelStatesFromString(logChannels, logChannelCount, enabledChannelsString.utf8().data()); 93 // LogEventLoop.state = WTFLogChannelState::On; 72 WTFInitializeLogChannelStatesFromString(m_logChannels.data(), m_logChannels.size(), enabledChannelsString.utf8().data()); 94 73 } 95 74 96 WTFLogChannel* getLogChannel(const String& name)75 WTFLogChannel* LogChannels::getLogChannel(const String& name) 97 76 { 98 return WTFLogChannelByName(logChannels, logChannelCount, name.utf8().data()); 99 } 100 101 #else 102 103 WTFLogChannel* getLogChannel(const String&) 104 { 105 return nullptr; 77 return WTFLogChannelByName(m_logChannels.data(), m_logChannels.size(), name.utf8().data()); 106 78 } 107 79 108 80 #endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED 109 81 110 } // namespace W ebCore82 } // namespace WTF -
trunk/Source/WTF/wtf/LogChannels.h
r280757 r280758 1 1 /* 2 * Copyright (C) 20 03, 2006, 2013, 2015, 2016Apple Inc. All rights reserved.2 * Copyright (C) 2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 26 26 #pragma once 27 27 28 #include <optional> 28 29 #include <wtf/Assertions.h> 29 30 #include <wtf/Forward.h> 30 31 #include <wtf/text/WTFString.h> 31 32 32 namespace W ebCore{33 namespace WTF { 33 34 34 35 #if !LOG_DISABLED || !RELEASE_LOG_DISABLED 35 36 36 WEBCORE_EXPORT String logLevelString(); 37 bool isLogChannelEnabled(const String& name); 38 WEBCORE_EXPORT void setLogChannelToAccumulate(const String& name); 39 WEBCORE_EXPORT void clearAllLogChannelsToAccumulate(); 40 WEBCORE_EXPORT void initializeLogChannelsIfNecessary(std::optional<String> = std::nullopt); 37 class LogChannels { 38 public: 39 virtual ~LogChannels() = default; 40 virtual String logLevelString() = 0; 41 42 bool isLogChannelEnabled(const String& name); 43 WTF_EXPORT_PRIVATE void setLogChannelToAccumulate(const String& name); 44 WTF_EXPORT_PRIVATE void clearAllLogChannelsToAccumulate(); 45 WTF_EXPORT_PRIVATE void initializeLogChannelsIfNecessary(std::optional<String> = std::nullopt); 46 WTF_EXPORT_PRIVATE WTFLogChannel* getLogChannel(const String& name); 47 48 protected: 49 Vector<WTFLogChannel*> m_logChannels; 50 bool m_logChannelsNeedInitialization { true }; 51 }; 41 52 42 53 #endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED 43 54 44 } // namespace W ebCore55 } // namespace WTF -
trunk/Source/WTF/wtf/ThreadSpecific.h
r252687 r280758 47 47 #include <wtf/Threading.h> 48 48 49 // X11 headers define a bunch of macros with common terms, interfering with WebCore and WTF enum values. 50 // As a workaround, we explicitly undef them here. 51 #if defined(False) 52 #undef False 53 #endif 54 #if defined(True) 55 #undef True 56 #endif 57 49 58 namespace WTF { 50 59 -
trunk/Source/WTF/wtf/Threading.h
r278253 r280758 62 62 #endif 63 63 64 // X11 headers define a bunch of macros with common terms, interfering with WebCore and WTF enum values. 65 // As a workaround, we explicitly undef them here. 66 #if defined(None) 67 #undef None 68 #endif 69 64 70 namespace WTF { 65 71 -
trunk/Source/WebCore/ChangeLog
r280757 r280758 1 2021-08-07 Myles C. Maxfield <mmaxfield@apple.com> 2 3 Deduplicate logging channel algorithms 4 https://bugs.webkit.org/show_bug.cgi?id=228809 5 6 Reviewed by Fujii Hironori. 7 8 No new tests because there is no behavior change. 9 10 * Sources.txt: 11 * WebCore.xcodeproj/project.pbxproj: 12 * accessibility/AXLogger.cpp: 13 * inspector/agents/page/PageConsoleAgent.cpp: 14 * page/Page.cpp: 15 * platform/LogInitialization.cpp: Copied from Source/WebCore/platform/LogInitialization.h. 16 (WebCore::logChannels): 17 (WebCore::getLogChannel): 18 * platform/LogInitialization.h: 19 * platform/Logging.cpp: 20 (WebCore::isLogChannelEnabled): Deleted. 21 (WebCore::setLogChannelToAccumulate): Deleted. 22 (WebCore::clearAllLogChannelsToAccumulate): Deleted. 23 (WebCore::initializeLogChannelsIfNecessary): Deleted. 24 (WebCore::getLogChannel): Deleted. 25 * platform/Logging.h: 26 * testing/js/WebCoreTestSupport.cpp: 27 (WebCoreTestSupport::setLogChannelToAccumulate): 28 (WebCoreTestSupport::clearAllLogChannelsToAccumulate): 29 (WebCoreTestSupport::initializeLogChannelsIfNecessary): 30 1 31 2021-08-07 Commit Queue <commit-queue@webkit.org> 2 32 -
trunk/Source/WebCore/Sources.txt
r280757 r280758 1756 1756 platform/LengthSize.cpp 1757 1757 platform/LocalizedStrings.cpp 1758 platform/LogInitialization.cpp 1758 1759 platform/Logging.cpp 1759 1760 platform/LowPowerModeNotifier.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r280757 r280758 6978 6978 1CE8D12C2618616400FC3AEF /* DisplayListIterator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DisplayListIterator.h; sourceTree = "<group>"; }; 6979 6979 1CF0BFD42298706800ED2074 /* TextSizeAdjustment.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TextSizeAdjustment.cpp; sourceTree = "<group>"; }; 6980 1CF18F3C26BB5AF2004B1722 /* LogInitialization.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LogInitialization.cpp; sourceTree = "<group>"; }; 6980 6981 1CFAE3220A6D6A3F0032593D /* libobjc.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libobjc.dylib; path = /usr/lib/libobjc.dylib; sourceTree = "<absolute>"; }; 6981 6982 1D0026A22374D62300CA6CDF /* JSPictureInPictureWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPictureInPictureWindow.h; sourceTree = "<group>"; }; … … 27588 27589 A8239DFE09B3CF8A00B60641 /* Logging.cpp */, 27589 27590 A8239DFF09B3CF8A00B60641 /* Logging.h */, 27591 1CF18F3C26BB5AF2004B1722 /* LogInitialization.cpp */, 27590 27592 0FDCD7F21D47E655009F08BC /* LogInitialization.h */, 27591 27593 46EFAF0F1E5FB9E100E7F34B /* LowPowerModeNotifier.cpp */, -
trunk/Source/WebCore/accessibility/AXLogger.cpp
r280757 r280758 37 37 #include "AXObjectCache.h" 38 38 #include "FrameView.h" 39 #include "LogInitialization.h" 39 40 #include "Logging.h" 40 41 #include <wtf/text/TextStream.h> -
trunk/Source/WebCore/inspector/agents/page/PageConsoleAgent.cpp
r280757 r280758 36 36 #include "InspectorDOMAgent.h" 37 37 #include "InstrumentingAgents.h" 38 #include "LogInitialization.h" 38 39 #include "Logging.h" 39 40 #include "Node.h" -
trunk/Source/WebCore/page/Page.cpp
r280757 r280758 84 84 #include "LibWebRTCProvider.h" 85 85 #include "LoaderStrategy.h" 86 #include "LogInitialization.h" 86 87 #include "Logging.h" 87 88 #include "LowPowerModeNotifier.h" -
trunk/Source/WebCore/platform/LogInitialization.cpp
r280757 r280758 1 1 /* 2 * Copyright (C) 2003 , 2006, 2013, 2015, 2016Apple Inc. All rights reserved.2 * Copyright (C) 2003-2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #pragma once 26 #include "config.h" 27 #include "LogInitialization.h" 27 28 28 #include <wtf/Assertions.h>29 #include <wtf/ Forward.h>29 #include "Logging.h" 30 #include <wtf/NeverDestroyed.h> 30 31 #include <wtf/text/WTFString.h> 31 32 … … 34 35 #if !LOG_DISABLED || !RELEASE_LOG_DISABLED 35 36 36 WEBCORE_EXPORT String logLevelString(); 37 bool isLogChannelEnabled(const String& name); 38 WEBCORE_EXPORT void setLogChannelToAccumulate(const String& name); 39 WEBCORE_EXPORT void clearAllLogChannelsToAccumulate(); 40 WEBCORE_EXPORT void initializeLogChannelsIfNecessary(std::optional<String> = std::nullopt); 37 class LogChannels final : public WTF::LogChannels { 38 public: 39 LogChannels() 40 { 41 m_logChannels = { 42 WEBCORE_LOG_CHANNELS(LOG_CHANNEL_ADDRESS) 43 }; 44 } 45 46 private: 47 String logLevelString() final 48 { 49 return WebCore::logLevelString(); 50 } 51 }; 52 53 WTF::LogChannels& logChannels() 54 { 55 static NeverDestroyed<LogChannels> logChannels; 56 return logChannels.get(); 57 } 58 59 WTFLogChannel* getLogChannel(const String& name) 60 { 61 return logChannels().getLogChannel(name); 62 } 63 64 #else 65 66 WTFLogChannel* getLogChannel(const String& name) 67 { 68 return nullptr; 69 } 41 70 42 71 #endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED -
trunk/Source/WebCore/platform/LogInitialization.h
r280757 r280758 1 1 /* 2 * Copyright (C) 20 03, 2006, 2013, 2015, 2016 Apple Inc.All rights reserved.2 * Copyright (C) 2010-2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 26 26 #pragma once 27 27 28 #include <wtf/Assertions.h> 29 #include <wtf/Forward.h> 28 #include <wtf/LogChannels.h> 30 29 #include <wtf/text/WTFString.h> 31 30 … … 34 33 #if !LOG_DISABLED || !RELEASE_LOG_DISABLED 35 34 36 WEBCORE_EXPORT String logLevelString(); 37 bool isLogChannelEnabled(const String& name); 38 WEBCORE_EXPORT void setLogChannelToAccumulate(const String& name); 39 WEBCORE_EXPORT void clearAllLogChannelsToAccumulate(); 40 WEBCORE_EXPORT void initializeLogChannelsIfNecessary(std::optional<String> = std::nullopt); 35 WEBCORE_EXPORT WTF::LogChannels& logChannels(); 36 String logLevelString(); 41 37 42 38 #endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED 43 39 40 WEBCORE_EXPORT WTFLogChannel* getLogChannel(const String& name); 41 44 42 } // namespace WebCore -
trunk/Source/WebCore/platform/Logging.cpp
r280757 r280758 1 1 /* 2 * Copyright (C) 2003 , 2006, 2013Apple Inc. All rights reserved.2 * Copyright (C) 2003-2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 26 26 #include "config.h" 27 27 #include "Logging.h" 28 #include "LogInitialization.h"29 30 #include <wtf/LoggingAccumulator.h>31 #include <wtf/StdLibExtras.h>32 #include <wtf/text/CString.h>33 #include <wtf/text/WTFString.h>34 35 #if PLATFORM(COCOA)36 #include <notify.h>37 #include <wtf/BlockPtr.h>38 #endif39 28 40 29 namespace WebCore { … … 45 34 WEBCORE_LOG_CHANNELS(DEFINE_WEBCORE_LOG_CHANNEL) 46 35 47 static WTFLogChannel* logChannels[] = {48 WEBCORE_LOG_CHANNELS(LOG_CHANNEL_ADDRESS)49 };50 51 static const size_t logChannelCount = WTF_ARRAY_LENGTH(logChannels);52 53 bool isLogChannelEnabled(const String& name)54 {55 WTFLogChannel* channel = WTFLogChannelByName(logChannels, logChannelCount, name.utf8().data());56 if (!channel)57 return false;58 return channel->state != WTFLogChannelState::Off;59 }60 61 static bool logChannelsNeedInitialization = true;62 63 void setLogChannelToAccumulate(const String& name)64 {65 WTFLogChannel* channel = WTFLogChannelByName(logChannels, logChannelCount, name.utf8().data());66 if (!channel)67 return;68 69 channel->state = WTFLogChannelState::OnWithAccumulation;70 logChannelsNeedInitialization = true;71 }72 73 void clearAllLogChannelsToAccumulate()74 {75 resetAccumulatedLogs();76 for (auto* channel : logChannels) {77 if (channel->state == WTFLogChannelState::OnWithAccumulation)78 channel->state = WTFLogChannelState::Off;79 }80 81 logChannelsNeedInitialization = true;82 }83 84 void initializeLogChannelsIfNecessary(std::optional<String> logChannelString)85 {86 if (!logChannelsNeedInitialization && !logChannelString)87 return;88 89 logChannelsNeedInitialization = false;90 91 String enabledChannelsString = logChannelString ? logChannelString.value() : logLevelString();92 WTFInitializeLogChannelStatesFromString(logChannels, logChannelCount, enabledChannelsString.utf8().data());93 // LogEventLoop.state = WTFLogChannelState::On;94 }95 96 WTFLogChannel* getLogChannel(const String& name)97 {98 return WTFLogChannelByName(logChannels, logChannelCount, name.utf8().data());99 }100 101 #else102 103 WTFLogChannel* getLogChannel(const String&)104 {105 return nullptr;106 }107 108 36 #endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED 109 37 -
trunk/Source/WebCore/platform/Logging.h
r280757 r280758 134 134 #endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED 135 135 136 WEBCORE_EXPORT WTFLogChannel* getLogChannel(const String& name);137 138 136 } // namespace WebCore -
trunk/Source/WebCore/testing/js/WebCoreTestSupport.cpp
r280757 r280758 37 37 #include "JSWorkerGlobalScope.h" 38 38 #include "LogInitialization.h" 39 #include "Logging.h" 39 40 #include "MockGamepadProvider.h" 40 41 #include "Page.h" … … 123 124 { 124 125 #if !LOG_DISABLED 125 WebCore::setLogChannelToAccumulate(name);126 logChannels().setLogChannelToAccumulate(name); 126 127 #else 127 128 UNUSED_PARAM(name); … … 132 133 { 133 134 #if !LOG_DISABLED 134 WebCore::clearAllLogChannelsToAccumulate();135 logChannels().clearAllLogChannelsToAccumulate(); 135 136 #endif 136 137 } … … 139 140 { 140 141 #if !LOG_DISABLED || !RELEASE_LOG_DISABLED 141 WebCore::initializeLogChannelsIfNecessary();142 logChannels().initializeLogChannelsIfNecessary(); 142 143 #endif 143 144 } -
trunk/Source/WebKit/ChangeLog
r280757 r280758 1 2021-08-07 Myles C. Maxfield <mmaxfield@apple.com> 2 3 Deduplicate logging channel algorithms 4 https://bugs.webkit.org/show_bug.cgi?id=228809 5 6 Reviewed by Fujii Hironori. 7 8 * GPUProcess/GPUConnectionToWebProcess.cpp: 9 * GPUProcess/GPUProcess.cpp: 10 (WebKit::GPUProcess::initializeGPUProcess): 11 * Platform/LogInitialization.cpp: Copied from Source/WebKit/Shared/WebKit2Initialize.cpp. 12 (WebKit::logChannels): 13 (WebKit::getLogChannel): 14 * Platform/LogInitialization.h: 15 * Platform/Logging.cpp: 16 (WebKit::initializeLogChannelsIfNecessary): Deleted. 17 (WebKit::getLogChannel): Deleted. 18 * Platform/Logging.h: 19 * Shared/AuxiliaryProcess.cpp: 20 (WebKit::AuxiliaryProcess::initialize): 21 * Shared/WebKit2Initialize.cpp: 22 (WebKit::InitializeWebKit2): 23 * Sources.txt: 24 * UIProcess/WebPageProxy.cpp: 25 * UIProcess/WebProcessPool.cpp: 26 * WebKit.xcodeproj/project.pbxproj: 27 * WebProcess/cocoa/WebProcessCocoa.mm: 28 (WebKit::WebProcess::platformInitializeWebProcess): 29 1 30 2021-08-07 Commit Queue <commit-queue@webkit.org> 2 31 -
trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp
r280757 r280758 65 65 #include "WebErrors.h" 66 66 #include "WebProcessMessages.h" 67 #include <WebCore/LogInitialization.h> 67 68 #include <WebCore/Logging.h> 68 69 #include <WebCore/MockRealtimeMediaSourceCenter.h> -
trunk/Source/WebKit/GPUProcess/GPUProcess.cpp
r280757 r280758 244 244 245 245 #if !LOG_DISABLED || !RELEASE_LOG_DISABLED 246 WebCore:: initializeLogChannelsIfNecessary(parameters.webCoreLoggingChannels);247 WebKit:: initializeLogChannelsIfNecessary(parameters.webKitLoggingChannels);246 WebCore::logChannels().initializeLogChannelsIfNecessary(parameters.webCoreLoggingChannels); 247 WebKit::logChannels().initializeLogChannelsIfNecessary(parameters.webKitLoggingChannels); 248 248 #endif 249 249 -
trunk/Source/WebKit/Platform/LogInitialization.cpp
r280757 r280758 1 1 /* 2 * Copyright (C) 20 13Apple Inc. All rights reserved.2 * Copyright (C) 2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 25 25 26 26 #include "config.h" 27 #include " WebKit2Initialize.h"27 #include "LogInitialization.h" 28 28 29 #include "LogInitialization.h" 30 #include <JavaScriptCore/InitializeThreading.h> 31 #include <WebCore/LogInitialization.h> 32 #include <WebCore/WebCoreJITOperations.h> 33 #include <wtf/MainThread.h> 34 #include <wtf/RefCounted.h> 35 #include <wtf/RunLoop.h> 29 #include "Logging.h" 30 #include <wtf/text/CString.h> 36 31 37 32 namespace WebKit { 38 33 39 #if ! PLATFORM(COCOA)34 #if !LOG_DISABLED || !RELEASE_LOG_DISABLED 40 35 41 void InitializeWebKit2() 36 class LogChannels final : public WTF::LogChannels { 37 public: 38 LogChannels() 39 { 40 m_logChannels = { 41 WEBKIT2_LOG_CHANNELS(LOG_CHANNEL_ADDRESS) 42 }; 43 } 44 45 private: 46 String logLevelString() final 47 { 48 return WebKit::logLevelString(); 49 } 50 }; 51 52 WTF::LogChannels& logChannels() 42 53 { 43 JSC::initialize();44 WTF::initializeMainThread();45 AtomString::init(); 54 static NeverDestroyed<LogChannels> logChannels; 55 return logChannels.get(); 56 } 46 57 47 WTF::RefCountedBase::enableThreadingChecksGlobally(); 58 WTFLogChannel* getLogChannel(const String& name) 59 { 60 return logChannels().getLogChannel(name); 61 } 48 62 49 #if !LOG_DISABLED || !RELEASE_LOG_DISABLED 50 WebCore::initializeLogChannelsIfNecessary(); 51 WebKit::initializeLogChannelsIfNecessary(); 63 #else 64 65 WTFLogChannel* getLogChannel(const String& name) 66 { 67 return nullptr; 68 } 69 52 70 #endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED 53 71 54 WebCore::populateJITOperations();55 }56 57 #endif // !PLATFORM(COCOA)58 59 72 } // namespace WebKit -
trunk/Source/WebKit/Platform/LogInitialization.h
r280757 r280758 1 1 /* 2 * Copyright (C) 20 10, 2013, 2016 Apple Inc.All rights reserved.2 * Copyright (C) 2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 26 26 #pragma once 27 27 28 #include <wtf/LogChannels.h> 28 29 #include <wtf/text/WTFString.h> 30 31 namespace WebKit { 29 32 30 33 #if !LOG_DISABLED || !RELEASE_LOG_DISABLED 31 34 32 namespace WebKit { 33 34 void initializeLogChannelsIfNecessary(std::optional<String> = std::nullopt); 35 WTF::LogChannels& logChannels(); 35 36 String logLevelString(); 36 37 38 #endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED 39 40 WTFLogChannel* getLogChannel(const String& name); 41 37 42 } // namespace WebKit 38 39 #endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED -
trunk/Source/WebKit/Platform/Logging.cpp
r280757 r280758 1 1 /* 2 * Copyright (C) 20 10, 2013Apple Inc. All rights reserved.2 * Copyright (C) 2021 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2011 Samsung Electronics 4 4 * … … 27 27 #include "config.h" 28 28 #include "Logging.h" 29 #include "LogInitialization.h"30 31 #include <wtf/text/CString.h>32 29 33 30 #if !LOG_DISABLED || !RELEASE_LOG_DISABLED … … 36 33 WEBKIT2_LOG_CHANNELS(DEFINE_WEBKIT2_LOG_CHANNEL) 37 34 38 static WTFLogChannel* logChannels[] = {39 WEBKIT2_LOG_CHANNELS(LOG_CHANNEL_ADDRESS)40 };41 42 namespace WebKit {43 44 static const size_t logChannelCount = WTF_ARRAY_LENGTH(logChannels);45 static bool logChannelsNeedInitialization = true;46 47 void initializeLogChannelsIfNecessary(std::optional<String> logChannelString)48 {49 if (!logChannelsNeedInitialization && !logChannelString)50 return;51 52 logChannelsNeedInitialization = false;53 54 String enabledChannelsString = logChannelString ? logChannelString.value() : logLevelString();55 WTFInitializeLogChannelStatesFromString(logChannels, logChannelCount, enabledChannelsString.utf8().data());56 }57 58 WTFLogChannel* getLogChannel(const String& name)59 {60 return WTFLogChannelByName(logChannels, logChannelCount, name.utf8().data());61 }62 63 } // namespace WebKit64 65 35 #endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED -
trunk/Source/WebKit/Platform/Logging.h
r280757 r280758 113 113 #undef DECLARE_LOG_CHANNEL 114 114 115 namespace WebKit {116 WTFLogChannel* getLogChannel(const String&);117 } // namespace WebKit118 119 115 #ifdef __cplusplus 120 116 } … … 122 118 123 119 #endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED 124 -
trunk/Source/WebKit/Shared/AuxiliaryProcess.cpp
r280757 r280758 83 83 84 84 #if !LOG_DISABLED || !RELEASE_LOG_DISABLED 85 WebCore:: initializeLogChannelsIfNecessary();86 WebKit:: initializeLogChannelsIfNecessary();85 WebCore::logChannels().initializeLogChannelsIfNecessary(); 86 WebKit::logChannels().initializeLogChannelsIfNecessary(); 87 87 #endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED 88 88 -
trunk/Source/WebKit/Shared/WebKit2Initialize.cpp
r280757 r280758 48 48 49 49 #if !LOG_DISABLED || !RELEASE_LOG_DISABLED 50 WebCore:: initializeLogChannelsIfNecessary();51 WebKit:: initializeLogChannelsIfNecessary();50 WebCore::logChannels().initializeLogChannelsIfNecessary(); 51 WebKit::logChannels().initializeLogChannelsIfNecessary(); 52 52 #endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED 53 53 -
trunk/Source/WebKit/Sources.txt
r280757 r280758 136 136 137 137 // TODO: We should unify these files once GTK's PluginProcess2 is removed. 138 Platform/LogInitialization.cpp @no-unify 138 139 Platform/Logging.cpp @no-unify 139 140 Platform/Module.cpp @no-unify -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r280757 r280758 69 69 #include "LegacyGlobalSettings.h" 70 70 #include "LoadParameters.h" 71 #include "LogInitialization.h" 71 72 #include "Logging.h" 72 73 #include "NativeWebGestureEvent.h" -
trunk/Source/WebKit/UIProcess/WebProcessPool.cpp
r280757 r280758 252 252 253 253 #if !LOG_DISABLED || !RELEASE_LOG_DISABLED 254 WebCore:: initializeLogChannelsIfNecessary();255 WebKit:: initializeLogChannelsIfNecessary();254 WebCore::logChannels().initializeLogChannelsIfNecessary(); 255 WebKit::logChannels().initializeLogChannelsIfNecessary(); 256 256 #endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED 257 257 -
trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r280757 r280758 4 4 classes = { 5 5 }; 6 objectVersion = 5 2;6 objectVersion = 54; 7 7 objects = { 8 8 … … 442 442 1CBBE4A019B66C53006B7D81 /* WebInspectorUIMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1CBBE49E19B66C53006B7D81 /* WebInspectorUIMessageReceiver.cpp */; }; 443 443 1CBBE4A119B66C53006B7D81 /* WebInspectorUIMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CBBE49F19B66C53006B7D81 /* WebInspectorUIMessages.h */; }; 444 1CF18F3F26BB5D95004B1722 /* LogInitialization.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1CF18F3E26BB5D90004B1722 /* LogInitialization.cpp */; }; 444 445 1D4D737023A9E54700717A25 /* RemoteMediaResourceManagerMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1D4D736B23A9DF5500717A25 /* RemoteMediaResourceManagerMessageReceiver.cpp */; }; 445 446 1D4D737123A9E56200717A25 /* RemoteMediaResourceManagerMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 1D4D736C23A9DF6000717A25 /* RemoteMediaResourceManagerMessages.h */; }; … … 3050 3051 1CBBE49E19B66C53006B7D81 /* WebInspectorUIMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebInspectorUIMessageReceiver.cpp; path = DerivedSources/WebKit2/WebInspectorUIMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; }; 3051 3052 1CBBE49F19B66C53006B7D81 /* WebInspectorUIMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebInspectorUIMessages.h; path = DerivedSources/WebKit2/WebInspectorUIMessages.h; sourceTree = BUILT_PRODUCTS_DIR; }; 3053 1CF18F3E26BB5D90004B1722 /* LogInitialization.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LogInitialization.cpp; sourceTree = "<group>"; }; 3052 3054 1D0530C9258EAB4400E436F7 /* combine-feature-flags-plist.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = "combine-feature-flags-plist.py"; sourceTree = "<group>"; }; 3053 3055 1D0530D1259162C800E436F7 /* WebKit-ios.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "WebKit-ios.plist"; sourceTree = "<group>"; }; … … 6001 6003 F40D1B68220BDC0F00B49A01 /* WebAutocorrectionContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WebAutocorrectionContext.h; path = ios/WebAutocorrectionContext.h; sourceTree = "<group>"; }; 6002 6004 F41056612130699A0092281D /* APIAttachmentCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = APIAttachmentCocoa.mm; sourceTree = "<group>"; }; 6003 F414CE2A269DDED100BD216A /* GPUProcessCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = GPUProcessCocoa.mm; path = cocoa/GPUProcessCocoa.mm; sourceTree = "<group>"; };6004 6005 F414CE2C269DE6EA00BD216A /* RemoteRenderingBackendState.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteRenderingBackendState.h; sourceTree = "<group>"; }; 6005 6006 F42D633F22A0EFD300D2FB3A /* WebAutocorrectionData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebAutocorrectionData.h; path = ios/WebAutocorrectionData.h; sourceTree = "<group>"; }; … … 10698 10699 51A7F2F4125BF8D4008AEB1D /* Logging.cpp */, 10699 10700 51A7F2F2125BF820008AEB1D /* Logging.h */, 10701 1CF18F3E26BB5D90004B1722 /* LogInitialization.cpp */, 10700 10702 0FDCD7F61D47E92A009F08BC /* LogInitialization.h */, 10701 10703 C0E3AA451209E2BA00A49D01 /* Module.cpp */, … … 11715 11717 ); 11716 11718 path = cache; 11717 sourceTree = "<group>";11718 };11719 F414CE27269DDE8000BD216A /* cocoa */ = {11720 isa = PBXGroup;11721 children = (11722 F414CE2A269DDED100BD216A /* GPUProcessCocoa.mm */,11723 );11724 name = cocoa;11725 11719 sourceTree = "<group>"; 11726 11720 }; … … 14236 14230 449D90DA21FDC30B00F677C0 /* LocalAuthenticationSoftLink.mm in Sources */, 14237 14231 2D92A779212B6A6100F493FD /* Logging.cpp in Sources */, 14232 1CF18F3F26BB5D95004B1722 /* LogInitialization.cpp in Sources */, 14238 14233 07E19EFB23D401F10094FFB4 /* MediaPlayerPrivateRemoteMessageReceiver.cpp in Sources */, 14239 14234 1DF29E64257F37A3003C28AF /* MediaSourcePrivateRemoteMessageReceiver.cpp in Sources */, -
trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm
r280757 r280758 282 282 283 283 #if !LOG_DISABLED || !RELEASE_LOG_DISABLED 284 WebCore:: initializeLogChannelsIfNecessary(parameters.webCoreLoggingChannels);285 WebKit:: initializeLogChannelsIfNecessary(parameters.webKitLoggingChannels);284 WebCore::logChannels().initializeLogChannelsIfNecessary(parameters.webCoreLoggingChannels); 285 WebKit::logChannels().initializeLogChannelsIfNecessary(parameters.webKitLoggingChannels); 286 286 #endif 287 287 -
trunk/Source/WebKitLegacy/ChangeLog
r280757 r280758 1 2021-08-07 Myles C. Maxfield <mmaxfield@apple.com> 2 3 Deduplicate logging channel algorithms 4 https://bugs.webkit.org/show_bug.cgi?id=228809 5 6 Reviewed by Fujii Hironori. 7 8 * WebKitLegacy.xcodeproj/project.pbxproj: 9 1 10 2021-08-07 Commit Queue <commit-queue@webkit.org> 2 11 -
trunk/Source/WebKitLegacy/WebKitLegacy.xcodeproj/project.pbxproj
r280757 r280758 112 112 1C7B0C660EB2464D00A28502 /* WebInspectorClientCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C7B0C650EB2464D00A28502 /* WebInspectorClientCF.cpp */; }; 113 113 1C8CB07A0AE9830C00B1F6E9 /* WebEditingDelegatePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C8CB0790AE9830C00B1F6E9 /* WebEditingDelegatePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; }; 114 1CF18F4126BB71B7004B1722 /* WebKitLogInitialization.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1CF18F4026BB71B7004B1722 /* WebKitLogInitialization.mm */; }; 114 115 22F219CC08D236730030E078 /* WebBackForwardListPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 22F219CB08D236730030E078 /* WebBackForwardListPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; }; 115 116 29AEF960134C76FB00FE5096 /* OutlookQuirksUserScript.js in Resources */ = {isa = PBXBuildFile; fileRef = 29AEF95D134C755400FE5096 /* OutlookQuirksUserScript.js */; }; … … 832 833 1C904FD40BA9DD0F0081E9D0 /* DebugRelease.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = DebugRelease.xcconfig; sourceTree = "<group>"; }; 833 834 1C904FD50BA9DD0F0081E9D0 /* Base.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Base.xcconfig; sourceTree = "<group>"; }; 835 1CF18F4026BB71B7004B1722 /* WebKitLogInitialization.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebKitLogInitialization.mm; sourceTree = "<group>"; }; 836 1CF18F4226BB71D3004B1722 /* WebKitLogInitialization.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebKitLogInitialization.h; sourceTree = "<group>"; }; 834 837 22F219CB08D236730030E078 /* WebBackForwardListPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebBackForwardListPrivate.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; }; 835 838 2568C72C0174912D0ECA149E /* WebKit.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebKit.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; }; … … 1788 1791 93AEB17D032C1735008635CE /* WebKitLogging.h */, 1789 1792 93AEB17E032C1735008635CE /* WebKitLogging.m */, 1793 1CF18F4226BB71D3004B1722 /* WebKitLogInitialization.h */, 1794 1CF18F4026BB71B7004B1722 /* WebKitLogInitialization.mm */, 1790 1795 7082F56F038EADAA00A80180 /* WebKitNSStringExtras.h */, 1791 1796 7082F570038EADAA00A80180 /* WebKitNSStringExtras.mm */, … … 3652 3657 CD8BFCE715531224005AFB25 /* WebKitFullScreenListener.mm in Sources */, 3653 3658 939810C30824BF01008DF038 /* WebKitLogging.m in Sources */, 3659 1CF18F4126BB71B7004B1722 /* WebKitLogInitialization.mm in Sources */, 3654 3660 939810C40824BF01008DF038 /* WebKitNSStringExtras.mm in Sources */, 3655 3661 1AAF5D0F0EDDE7A7008D883D /* WebKitPluginAgent.defs in Sources */, -
trunk/Source/WebKitLegacy/mac/ChangeLog
r280757 r280758 1 2021-08-07 Myles C. Maxfield <mmaxfield@apple.com> 2 3 Deduplicate logging channel algorithms 4 https://bugs.webkit.org/show_bug.cgi?id=228809 5 6 Reviewed by Fujii Hironori. 7 8 * Misc/WebKitLogInitialization.h: Copied from Source/WebKit/Platform/LogInitialization.h. 9 * Misc/WebKitLogInitialization.mm: Copied from Source/WebKitLegacy/mac/Misc/WebKitLogging.m. 10 (WebKit::logChannels): 11 (ReportDiscardedDelegateException): 12 * Misc/WebKitLogging.h: 13 * Misc/WebKitLogging.m: 14 (ReportDiscardedDelegateException): Deleted. 15 * WebCoreSupport/WebDragClient.mm: 16 * WebView/WebDelegateImplementationCaching.mm: 17 * WebView/WebView.mm: 18 (-[WebView _commonInitializationWithFrameName:groupName:]): 19 1 20 2021-08-07 Commit Queue <commit-queue@webkit.org> 2 21 -
trunk/Source/WebKitLegacy/mac/Misc/WebKitLogInitialization.h
r280757 r280758 1 1 /* 2 * Copyright (C) 20 10, 2013, 2016 Apple Inc.All rights reserved.2 * Copyright (C) 2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 26 26 #pragma once 27 27 28 #include <wtf/LogChannels.h> 28 29 #include <wtf/text/WTFString.h> 30 31 namespace WebKit { 29 32 30 33 #if !LOG_DISABLED || !RELEASE_LOG_DISABLED 31 34 32 namespace WebKit { 35 WTF::LogChannels& logChannels(); 33 36 34 void initializeLogChannelsIfNecessary(std::optional<String> = std::nullopt); 35 String logLevelString(); 37 #endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED 38 39 WTFLogChannel* getLogChannel(const String& name); 36 40 37 41 } // namespace WebKit 38 42 39 #endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED 43 void ReportDiscardedDelegateException(SEL delegateSelector, id exception); -
trunk/Source/WebKitLegacy/mac/Misc/WebKitLogInitialization.mm
r280757 r280758 1 1 /* 2 * Copyright (C) 2005 , 2007, 2013Apple Inc. All rights reserved.2 * Copyright (C) 2005-2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 7 7 * 8 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer. 10 10 * 2. Redistributions in binary form must reproduce the above copyright 11 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 12 * documentation and/or other materials provided with the distribution. 13 13 * 3. Neither the name of Apple Inc. ("Apple") nor the names of 14 14 * its contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 15 * from this software without specific prior written permission. 16 16 * 17 17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY … … 27 27 */ 28 28 29 #import "WebKitLogging.h" 29 #include "WebKitLogInitialization.h" 30 31 #include "WebKitLogging.h" 32 #include <wtf/text/CString.h> 33 34 namespace WebKit { 30 35 31 36 #if !LOG_DISABLED || !RELEASE_LOG_DISABLED 32 37 33 #define DEFINE_WEBKIT_LOG_CHANNEL(name) DEFINE_LOG_CHANNEL(name, LOG_CHANNEL_WEBKIT_SUBSYSTEM) 34 WEBKIT_LOG_CHANNELS(DEFINE_WEBKIT_LOG_CHANNEL) 38 class LogChannels final : public WTF::LogChannels { 39 public: 40 LogChannels() 41 { 42 m_logChannels = { 43 WEBKIT_LOG_CHANNELS(LOG_CHANNEL_ADDRESS) 44 }; 45 } 35 46 36 static WTFLogChannel* logChannels[] = { 37 WEBKIT_LOG_CHANNELS(LOG_CHANNEL_ADDRESS) 47 private: 48 String logLevelString() final 49 { 50 static NSString * const defaultsDomain = @"WebKitLogging"; 51 return [[NSUserDefaults standardUserDefaults] stringForKey:defaultsDomain]; 52 } 38 53 }; 39 54 40 static const size_t logChannelCount = sizeof(logChannels) / sizeof(logChannels[0]); 41 42 43 static NSString * const defaultsDomain = @"WebKitLogging"; 44 45 void WebKitInitializeLogChannelsIfNecessary() 55 WTF::LogChannels& logChannels() 46 56 { 47 static bool haveInitializedLoggingChannels = false; 48 if (haveInitializedLoggingChannels) 49 return; 50 haveInitializedLoggingChannels = true; 51 52 NSString *logLevel = [[NSUserDefaults standardUserDefaults] stringForKey:defaultsDomain]; 53 if (!logLevel) 54 return; 55 56 WTFInitializeLogChannelStatesFromString(logChannels, logChannelCount, [logLevel UTF8String]); 57 static NeverDestroyed<LogChannels> logChannels; 58 return logChannels.get(); 57 59 } 58 60 59 61 #endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED 60 62 63 } // namespace WebKit 64 61 65 void ReportDiscardedDelegateException(SEL delegateSelector, id exception) 62 66 { 63 if ([exception isKindOfClass:[NSException class]]) 67 if ([exception isKindOfClass:[NSException class]]) { 64 68 NSLog(@"*** WebKit discarded an uncaught exception in the %s delegate: <%@> %@", 65 69 sel_getName(delegateSelector), [exception name], [exception reason]); 66 else70 } else { 67 71 NSLog(@"*** WebKit discarded an uncaught exception in the %s delegate: %@", 68 72 sel_getName(delegateSelector), exception); 73 } 69 74 } -
trunk/Source/WebKitLegacy/mac/Misc/WebKitLogging.h
r280757 r280758 1 1 /* 2 * Copyright (C) 2005 , 2007, 2008, 2013Apple Inc. All rights reserved.2 * Copyright (C) 2005-2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 69 69 #undef DECLARE_LOG_CHANNEL 70 70 71 void WebKitInitializeLogChannelsIfNecessary(void);72 71 #endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED 73 74 void ReportDiscardedDelegateException(SEL delegateSelector, id exception);75 72 76 73 #ifdef __cplusplus -
trunk/Source/WebKitLegacy/mac/Misc/WebKitLogging.m
r280757 r280758 34 34 WEBKIT_LOG_CHANNELS(DEFINE_WEBKIT_LOG_CHANNEL) 35 35 36 static WTFLogChannel* logChannels[] = {37 WEBKIT_LOG_CHANNELS(LOG_CHANNEL_ADDRESS)38 };39 40 static const size_t logChannelCount = sizeof(logChannels) / sizeof(logChannels[0]);41 42 43 static NSString * const defaultsDomain = @"WebKitLogging";44 45 void WebKitInitializeLogChannelsIfNecessary()46 {47 static bool haveInitializedLoggingChannels = false;48 if (haveInitializedLoggingChannels)49 return;50 haveInitializedLoggingChannels = true;51 52 NSString *logLevel = [[NSUserDefaults standardUserDefaults] stringForKey:defaultsDomain];53 if (!logLevel)54 return;55 56 WTFInitializeLogChannelStatesFromString(logChannels, logChannelCount, [logLevel UTF8String]);57 }58 59 36 #endif // !LOG_DISABLED || !RELEASE_LOG_DISABLED 60 61 void ReportDiscardedDelegateException(SEL delegateSelector, id exception)62 {63 if ([exception isKindOfClass:[NSException class]])64 NSLog(@"*** WebKit discarded an uncaught exception in the %s delegate: <%@> %@",65 sel_getName(delegateSelector), [exception name], [exception reason]);66 else67 NSLog(@"*** WebKit discarded an uncaught exception in the %s delegate: %@",68 sel_getName(delegateSelector), exception);69 } -
trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebDragClient.mm
r280757 r280758 35 35 #import "WebFrameView.h" 36 36 #import "WebHTMLViewInternal.h" 37 #import "WebKitLogInitialization.h" 37 38 #import "WebKitLogging.h" 38 39 #import "WebKitNSStringExtras.h" -
trunk/Source/WebKitLegacy/mac/WebView/WebDelegateImplementationCaching.mm
r280757 r280758 1 1 /* 2 * Copyright (C) 2005 , 2006, 2007, 2008, 2009Apple Inc. All rights reserved.2 * Copyright (C) 2005-2021 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2006 David Smith (catfish.man@gmail.com) 4 4 * … … 30 30 #import "WebDelegateImplementationCaching.h" 31 31 32 #import "WebKitLogInitialization.h" 32 33 #import "WebKitLogging.h" 33 34 #import "WebView.h" -
trunk/Source/WebKitLegacy/mac/WebView/WebView.mm
r280757 r280758 82 82 #import "WebKitErrors.h" 83 83 #import "WebKitFullScreenListener.h" 84 #import "WebKitLogInitialization.h" 84 85 #import "WebKitLogging.h" 85 86 #import "WebKitNSStringExtras.h" … … 1481 1482 if (!didOneTimeInitialization) { 1482 1483 #if !LOG_DISABLED || !RELEASE_LOG_DISABLED 1483 Web KitInitializeLogChannelsIfNecessary();1484 Web Core::initializeLogChannelsIfNecessary();1484 WebCore::logChannels().initializeLogChannelsIfNecessary(); 1485 WebKit::logChannels().initializeLogChannelsIfNecessary(); 1485 1486 #endif 1486 1487
Note:
See TracChangeset
for help on using the changeset viewer.