WebKit Bugzilla
Attachment 343433 Details for
Bug 186969
: Remove static initializers more
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-186969-20180623224103.patch (text/plain), 16.54 KB, created by
Yusuke Suzuki
on 2018-06-23 06:41:04 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Yusuke Suzuki
Created:
2018-06-23 06:41:04 PDT
Size:
16.54 KB
patch
obsolete
>Subversion Revision: 233123 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 80a4223ffbff6997c5743d34794274ef4f19c5f7..43e01c9fb2b94baa075e60f17c988ec4114a29b7 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,40 @@ >+2018-06-23 Yusuke Suzuki <utatane.tea@gmail.com> >+ >+ Remove static initializers more >+ https://bugs.webkit.org/show_bug.cgi?id=186969 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ This patch removes static initializers more. They typically exists in GTK port. >+ >+ No behavior change. >+ >+ * WebCore.xcodeproj/project.pbxproj: >+ * page/ResourceUsageData.cpp: Removed. >+ * page/ResourceUsageData.h: >+ Remove ResourceUsageData constructors since default constructors are enough. >+ >+ (WebCore::MemoryCategoryInfo::MemoryCategoryInfo): >+ * platform/gtk/PasteboardHelper.cpp: >+ (WebCore::markupPrefix): >+ (WebCore::removeMarkupPrefix): >+ (WebCore::PasteboardHelper::fillSelectionData): >+ Use NeverDestroyed<> and static functions. >+ >+ * platform/mediastream/gstreamer/GStreamerAudioCaptureSource.cpp: >+ (WebCore::defaultVolumeCapability): >+ (WebCore::GStreamerAudioCaptureSource::capabilities const): >+ CapabilityValueOrRange's constructor is not constexpr. >+ >+ * platform/network/soup/SoupNetworkSession.cpp: >+ (WebCore::initialAcceptLanguages): >+ (WebCore::proxySettings): >+ (WebCore::SoupNetworkSession::SoupNetworkSession): >+ (WebCore::SoupNetworkSession::setupProxy): >+ (WebCore::SoupNetworkSession::setProxySettings): >+ (WebCore::SoupNetworkSession::setInitialAcceptLanguages): >+ Use NeverDestroyed<> and static functions. >+ > 2018-06-23 Yusuke Suzuki <utatane.tea@gmail.com> > > [WTF] Add user-defined literal for ASCIILiteral >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index ea6827d749306ae24d3c2e19523011e7c7f49221..bf54a0d9d457f905e56c0841e40f0516bab0e1bb 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -11137,7 +11137,6 @@ > A5071E831C56D079009951BE /* ResourceUsageThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceUsageThread.cpp; sourceTree = "<group>"; }; > A5071E841C56D079009951BE /* ResourceUsageThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceUsageThread.h; sourceTree = "<group>"; }; > A5071E881C56D4FA009951BE /* ResourceUsageThreadCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ResourceUsageThreadCocoa.mm; sourceTree = "<group>"; }; >- A5071E8A1C56FAFA009951BE /* ResourceUsageData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceUsageData.cpp; sourceTree = "<group>"; }; > A516E8B4136E04DB0076C3C0 /* LocalizedDateCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocalizedDateCache.h; sourceTree = "<group>"; }; > A516E8B5136E04DB0076C3C0 /* LocalizedDateCache.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalizedDateCache.mm; sourceTree = "<group>"; }; > A518225417E2A0D400A9BA1D /* InspectorOverlayPage.css */ = {isa = PBXFileReference; lastKnownFileType = text.css; path = InspectorOverlayPage.css; sourceTree = "<group>"; }; >@@ -19386,7 +19385,6 @@ > 46BCBBC3208500A700710638 /* RemoteDOMWindow.idl */, > 46B9518C207D632900A7D2DD /* RemoteFrame.cpp */, > 46B95192207D632E00A7D2DD /* RemoteFrame.h */, >- A5071E8A1C56FAFA009951BE /* ResourceUsageData.cpp */, > A5071E821C56D079009951BE /* ResourceUsageData.h */, > ADBAD6EC1BCDD95000381325 /* ResourceUsageOverlay.cpp */, > ADBAD6ED1BCDD95000381325 /* ResourceUsageOverlay.h */, >diff --git a/Source/WebCore/page/ResourceUsageData.cpp b/Source/WebCore/page/ResourceUsageData.cpp >deleted file mode 100644 >index 7a170026b8ecc4a61d1280a03a0a3c341854398d..0000000000000000000000000000000000000000 >--- a/Source/WebCore/page/ResourceUsageData.cpp >+++ /dev/null >@@ -1,61 +0,0 @@ >-/* >- * Copyright (C) 2016-2017 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >- * THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#include "config.h" >-#include "ResourceUsageData.h" >- >-#if ENABLE(RESOURCE_USAGE) >- >-namespace WebCore { >- >-ResourceUsageData::ResourceUsageData() >-{ >- // VM tag categories. >- categories[MemoryCategory::JSJIT] = MemoryCategoryInfo(MemoryCategory::JSJIT); >- categories[MemoryCategory::WebAssembly] = MemoryCategoryInfo(MemoryCategory::WebAssembly); >- categories[MemoryCategory::Images] = MemoryCategoryInfo(MemoryCategory::Images); >- categories[MemoryCategory::Layers] = MemoryCategoryInfo(MemoryCategory::Layers); >- categories[MemoryCategory::LibcMalloc] = MemoryCategoryInfo(MemoryCategory::LibcMalloc); >- categories[MemoryCategory::bmalloc] = MemoryCategoryInfo(MemoryCategory::bmalloc); >- categories[MemoryCategory::Other] = MemoryCategoryInfo(MemoryCategory::Other); >- >- // Sub categories (e.g breakdown of bmalloc tag.) >- categories[MemoryCategory::GCHeap] = MemoryCategoryInfo(MemoryCategory::GCHeap, true); >- categories[MemoryCategory::GCOwned] = MemoryCategoryInfo(MemoryCategory::GCOwned, true); >-} >- >-ResourceUsageData::ResourceUsageData(const ResourceUsageData& other) >- : cpu(other.cpu) >- , totalDirtySize(other.totalDirtySize) >- , totalExternalSize(other.totalExternalSize) >- , timeOfNextEdenCollection(other.timeOfNextEdenCollection) >- , timeOfNextFullCollection(other.timeOfNextFullCollection) >-{ >- std::copy(other.categories.begin(), other.categories.end(), categories.begin()); >-} >- >-} >- >-#endif // ENABLE(RESOURCE_USAGE) >diff --git a/Source/WebCore/page/ResourceUsageData.h b/Source/WebCore/page/ResourceUsageData.h >index c881538bb55e34b94b86816c48f58be83e084a3d..219376bf9ad20ee3b7501e93f53e2adebe70a0d5 100644 >--- a/Source/WebCore/page/ResourceUsageData.h >+++ b/Source/WebCore/page/ResourceUsageData.h >@@ -32,22 +32,31 @@ > > namespace WebCore { > >+// v(name, id, subcategory) >+#define WEBCORE_EACH_MEMORY_CATEGORIES(v) \ >+ v(bmalloc, 0, false) \ >+ v(LibcMalloc, 1, false) \ >+ v(JSJIT, 2, false) \ >+ v(WebAssembly, 3, false) \ >+ v(Images, 4, false) \ >+ v(GCHeap, 5, true) \ >+ v(GCOwned, 6, true) \ >+ v(Other, 7, false) \ >+ v(Layers, 8, false) \ >+ > namespace MemoryCategory { >-static const unsigned bmalloc = 0; >-static const unsigned LibcMalloc = 1; >-static const unsigned JSJIT = 2; >-static const unsigned WebAssembly = 3; >-static const unsigned Images = 4; >-static const unsigned GCHeap = 5; >-static const unsigned GCOwned = 6; >-static const unsigned Other = 7; >-static const unsigned Layers = 8; >-static const unsigned NumberOfCategories = 9; >+#define WEBCORE_DEFINE_MEMORY_CATEGORY(name, id, subcategory) static constexpr unsigned name = id; >+WEBCORE_EACH_MEMORY_CATEGORIES(WEBCORE_DEFINE_MEMORY_CATEGORY) >+#undef WEBCORE_DEFINE_MEMORY_CATEGORY >+ >+#define WEBCORE_DEFINE_MEMORY_CATEGORY(name, id, subcategory) + 1 >+static constexpr unsigned NumberOfCategories = 0 WEBCORE_EACH_MEMORY_CATEGORIES(WEBCORE_DEFINE_MEMORY_CATEGORY); >+#undef WEBCORE_DEFINE_MEMORY_CATEGORY > } > > struct MemoryCategoryInfo { >- MemoryCategoryInfo() { } // Needed for std::array. >- MemoryCategoryInfo(unsigned category, bool subcategory = false) >+ constexpr MemoryCategoryInfo() = default; // Needed for std::array. >+ constexpr MemoryCategoryInfo(unsigned category, bool subcategory = false) > : isSubcategory(subcategory) > , type(category) > { >@@ -63,13 +72,16 @@ struct MemoryCategoryInfo { > }; > > struct ResourceUsageData { >- ResourceUsageData(); >- ResourceUsageData(const ResourceUsageData& data); >+ constexpr ResourceUsageData() = default; > > float cpu { 0 }; > size_t totalDirtySize { 0 }; > size_t totalExternalSize { 0 }; >- std::array<MemoryCategoryInfo, MemoryCategory::NumberOfCategories> categories; >+ std::array<MemoryCategoryInfo, MemoryCategory::NumberOfCategories> categories { >+#define WEBCORE_DEFINE_MEMORY_CATEGORY(name, id, subcategory) MemoryCategoryInfo(MemoryCategory::name, subcategory), >+WEBCORE_EACH_MEMORY_CATEGORIES(WEBCORE_DEFINE_MEMORY_CATEGORY) >+#undef WEBCORE_DEFINE_MEMORY_CATEGORY >+ }; > MonotonicTime timeOfNextEdenCollection { MonotonicTime::nan() }; > MonotonicTime timeOfNextFullCollection { MonotonicTime::nan() }; > }; >diff --git a/Source/WebCore/platform/gtk/PasteboardHelper.cpp b/Source/WebCore/platform/gtk/PasteboardHelper.cpp >index c2686fd4eabe0f7b7a648ff65da3bcee0536ea57..1cdcd51b4fdfe554628d581231724723954698b2 100644 >--- a/Source/WebCore/platform/gtk/PasteboardHelper.cpp >+++ b/Source/WebCore/platform/gtk/PasteboardHelper.cpp >@@ -40,14 +40,18 @@ static GdkAtom uriListAtom; > static GdkAtom smartPasteAtom; > static GdkAtom unknownAtom; > >-static const String gMarkupPrefix = "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">"_s; >+static const String& markupPrefix() >+{ >+ static NeverDestroyed<const String> prefix(MAKE_STATIC_STRING_IMPL("<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">")); >+ return prefix.get(); >+} > > static void removeMarkupPrefix(String& markup) > { > // The markup prefix is not harmful, but we remove it from the string anyway, so that > // we can have consistent results with other ports during the layout tests. >- if (markup.startsWith(gMarkupPrefix)) >- markup.remove(0, gMarkupPrefix.length()); >+ if (markup.startsWith(markupPrefix())) >+ markup.remove(0, markupPrefix().length()); > } > > PasteboardHelper& PasteboardHelper::singleton() >@@ -163,7 +167,7 @@ void PasteboardHelper::fillSelectionData(const SelectionData& selection, unsigne > else if (info == TargetTypeMarkup) { > // Some Linux applications refuse to accept pasted markup unless it is > // prefixed by a content-type meta tag. >- CString markup = String(gMarkupPrefix + selection.markup()).utf8(); >+ CString markup = makeString(markupPrefix(), selection.markup()).utf8(); > gtk_selection_data_set(selectionData, markupAtom, 8, reinterpret_cast<const guchar*>(markup.data()), markup.length()); > > } else if (info == TargetTypeURIList) { >diff --git a/Source/WebCore/platform/mediastream/gstreamer/GStreamerAudioCaptureSource.cpp b/Source/WebCore/platform/mediastream/gstreamer/GStreamerAudioCaptureSource.cpp >index 9c5aeafffcf12a2fe82b1835927f0e70c6b6b88b..0d57b23f45282fbb27aba97bb8994eea0530df8b 100644 >--- a/Source/WebCore/platform/mediastream/gstreamer/GStreamerAudioCaptureSource.cpp >+++ b/Source/WebCore/platform/mediastream/gstreamer/GStreamerAudioCaptureSource.cpp >@@ -34,7 +34,10 @@ > > namespace WebCore { > >-const static CapabilityValueOrRange defaultVolumeCapability = CapabilityValueOrRange(0.0, 1.0); >+static CapabilityValueOrRange defaultVolumeCapability() >+{ >+ return CapabilityValueOrRange(0.0, 1.0); >+} > const static RealtimeMediaSourceCapabilities::EchoCancellation defaultEchoCancellationCapability = RealtimeMediaSourceCapabilities::EchoCancellation::ReadWrite; > > GST_DEBUG_CATEGORY(webkit_audio_capture_source_debug); >@@ -162,7 +165,7 @@ const RealtimeMediaSourceCapabilities& GStreamerAudioCaptureSource::capabilities > RealtimeMediaSourceCapabilities capabilities(settings().supportedConstraints()); > capabilities.setDeviceId(id()); > capabilities.setEchoCancellation(defaultEchoCancellationCapability); >- capabilities.setVolume(defaultVolumeCapability); >+ capabilities.setVolume(defaultVolumeCapability()); > capabilities.setSampleRate(CapabilityValueOrRange(minSampleRate, maxSampleRate)); > m_capabilities = WTFMove(capabilities); > >diff --git a/Source/WebCore/platform/network/soup/SoupNetworkSession.cpp b/Source/WebCore/platform/network/soup/SoupNetworkSession.cpp >index 2c29a51f035694bae7430d47751811a734b8a406..adcd3e7131088da51de7b2a0ef580e29c9938133 100644 >--- a/Source/WebCore/platform/network/soup/SoupNetworkSession.cpp >+++ b/Source/WebCore/platform/network/soup/SoupNetworkSession.cpp >@@ -45,8 +45,16 @@ > namespace WebCore { > > static bool gIgnoreTLSErrors; >-static CString gInitialAcceptLanguages; >-static SoupNetworkProxySettings gProxySettings; >+static CString& initialAcceptLanguages() >+{ >+ static NeverDestroyed<CString> storage; >+ return storage.get(); >+} >+static SoupNetworkProxySettings proxySettings() >+{ >+ static NeverDestroyed<SoupNetworkProxySettings> settings; >+ return settings.get(); >+} > static GType gCustomProtocolRequestType; > > #if !LOG_DISABLED >@@ -124,8 +132,8 @@ SoupNetworkSession::SoupNetworkSession(PAL::SessionID sessionID, SoupCookieJar* > > setupCustomProtocols(); > >- if (!gInitialAcceptLanguages.isNull()) >- setAcceptLanguages(gInitialAcceptLanguages); >+ if (!initialAcceptLanguages().isNull()) >+ setAcceptLanguages(initialAcceptLanguages()); > > #if SOUP_CHECK_VERSION(2, 53, 92) > if (soup_auth_negotiate_supported() && !sessionID.isEphemeral()) { >@@ -137,7 +145,7 @@ SoupNetworkSession::SoupNetworkSession(PAL::SessionID sessionID, SoupCookieJar* > UNUSED_PARAM(sessionID); > #endif > >- if (gProxySettings.mode != SoupNetworkProxySettings::Mode::Default) >+ if (proxySettings().mode != SoupNetworkProxySettings::Mode::Default) > setupProxy(); > setupLogger(); > } >@@ -203,7 +211,7 @@ void SoupNetworkSession::clearOldSoupCache(const String& cacheDirectory) > void SoupNetworkSession::setupProxy() > { > GRefPtr<GProxyResolver> resolver; >- switch (gProxySettings.mode) { >+ switch (proxySettings().mode) { > case SoupNetworkProxySettings::Mode::Default: { > GRefPtr<GProxyResolver> currentResolver; > g_object_get(m_soupSession.get(), SOUP_SESSION_PROXY_RESOLVER, ¤tResolver.outPtr(), nullptr); >@@ -218,11 +226,11 @@ void SoupNetworkSession::setupProxy() > break; > case SoupNetworkProxySettings::Mode::Custom: > resolver = adoptGRef(g_simple_proxy_resolver_new(nullptr, nullptr)); >- if (!gProxySettings.defaultProxyURL.isNull()) >- g_simple_proxy_resolver_set_default_proxy(G_SIMPLE_PROXY_RESOLVER(resolver.get()), gProxySettings.defaultProxyURL.data()); >- if (gProxySettings.ignoreHosts) >- g_simple_proxy_resolver_set_ignore_hosts(G_SIMPLE_PROXY_RESOLVER(resolver.get()), gProxySettings.ignoreHosts.get()); >- for (const auto& iter : gProxySettings.proxyMap) >+ if (!proxySettings().defaultProxyURL.isNull()) >+ g_simple_proxy_resolver_set_default_proxy(G_SIMPLE_PROXY_RESOLVER(resolver.get()), proxySettings().defaultProxyURL.data()); >+ if (proxySettings().ignoreHosts) >+ g_simple_proxy_resolver_set_ignore_hosts(G_SIMPLE_PROXY_RESOLVER(resolver.get()), proxySettings().ignoreHosts.get()); >+ for (const auto& iter : proxySettings().proxyMap) > g_simple_proxy_resolver_set_uri_proxy(G_SIMPLE_PROXY_RESOLVER(resolver.get()), iter.key.data(), iter.value.data()); > break; > } >@@ -233,12 +241,12 @@ void SoupNetworkSession::setupProxy() > > void SoupNetworkSession::setProxySettings(const SoupNetworkProxySettings& settings) > { >- gProxySettings = settings; >+ proxySettings() = settings; > } > > void SoupNetworkSession::setInitialAcceptLanguages(const CString& languages) > { >- gInitialAcceptLanguages = languages; >+ initialAcceptLanguages() = languages; > } > > void SoupNetworkSession::setAcceptLanguages(const CString& languages)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 186969
:
343433
|
343436
|
343437
|
343492
|
343555
|
343566