Title: [209937] trunk/Source/WebKit2
- Revision
- 209937
- Author
- jer.no...@apple.com
- Date
- 2016-12-16 14:05:54 -0800 (Fri, 16 Dec 2016)
Log Message
Small refactor: Use HashCountedSet rather than HashMap<..., int> to store client counts in WebPlaybackSessionManager{,Proxy}.
https://bugs.webkit.org/show_bug.cgi?id=165807
Reviewed by Eric Carlson.
* UIProcess/Cocoa/WebPlaybackSessionManagerProxy.h:
* UIProcess/Cocoa/WebPlaybackSessionManagerProxy.mm:
(WebKit::WebPlaybackSessionManagerProxy::addClientForContext):
(WebKit::WebPlaybackSessionManagerProxy::removeClientForContext):
* WebProcess/cocoa/WebPlaybackSessionManager.h:
* WebProcess/cocoa/WebPlaybackSessionManager.mm:
(WebKit::WebPlaybackSessionManager::addClientForContext):
(WebKit::WebPlaybackSessionManager::removeClientForContext):
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (209936 => 209937)
--- trunk/Source/WebKit2/ChangeLog 2016-12-16 21:52:38 UTC (rev 209936)
+++ trunk/Source/WebKit2/ChangeLog 2016-12-16 22:05:54 UTC (rev 209937)
@@ -1,3 +1,19 @@
+2016-12-16 Jer Noble <jer.no...@apple.com>
+
+ Small refactor: Use HashCountedSet rather than HashMap<..., int> to store client counts in WebPlaybackSessionManager{,Proxy}.
+ https://bugs.webkit.org/show_bug.cgi?id=165807
+
+ Reviewed by Eric Carlson.
+
+ * UIProcess/Cocoa/WebPlaybackSessionManagerProxy.h:
+ * UIProcess/Cocoa/WebPlaybackSessionManagerProxy.mm:
+ (WebKit::WebPlaybackSessionManagerProxy::addClientForContext):
+ (WebKit::WebPlaybackSessionManagerProxy::removeClientForContext):
+ * WebProcess/cocoa/WebPlaybackSessionManager.h:
+ * WebProcess/cocoa/WebPlaybackSessionManager.mm:
+ (WebKit::WebPlaybackSessionManager::addClientForContext):
+ (WebKit::WebPlaybackSessionManager::removeClientForContext):
+
2016-12-16 Wenson Hsieh <wenson_hs...@apple.com>
Visual viewports: carets and selection UI are incorrectly positioned when editing fixed elements
Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.h (209936 => 209937)
--- trunk/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.h 2016-12-16 21:52:38 UTC (rev 209936)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.h 2016-12-16 22:05:54 UTC (rev 209937)
@@ -32,6 +32,7 @@
#include <WebCore/PlatformView.h>
#include <WebCore/TimeRanges.h>
#include <WebCore/WebPlaybackSessionModel.h>
+#include <wtf/HashCountedSet.h>
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/RefCounted.h>
@@ -203,7 +204,7 @@
WebPageProxy* m_page;
HashMap<uint64_t, ModelInterfaceTuple> m_contextMap;
uint64_t m_controlsManagerContextId { 0 };
- HashMap<uint64_t, int> m_clientCounts;
+ HashCountedSet<uint64_t> m_clientCounts;
};
} // namespace WebKit
Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.mm (209936 => 209937)
--- trunk/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.mm 2016-12-16 21:52:38 UTC (rev 209936)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebPlaybackSessionManagerProxy.mm 2016-12-16 22:05:54 UTC (rev 209937)
@@ -281,31 +281,16 @@
void WebPlaybackSessionManagerProxy::addClientForContext(uint64_t contextId)
{
- auto addResult = m_clientCounts.add(contextId, 1);
- if (!addResult.isNewEntry)
- addResult.iterator->value++;
+ m_clientCounts.add(contextId);
}
void WebPlaybackSessionManagerProxy::removeClientForContext(uint64_t contextId)
{
- ASSERT(m_clientCounts.contains(contextId));
-
- int clientCount = m_clientCounts.get(contextId);
- ASSERT(clientCount > 0);
- clientCount--;
-
- if (clientCount <= 0) {
- m_clientCounts.remove(contextId);
-
- RefPtr<WebPlaybackSessionModelContext> model;
- RefPtr<PlatformWebPlaybackSessionInterface> interface;
- std::tie(model, interface) = ensureModelAndInterface(contextId);
- interface->invalidate();
- m_contextMap.remove(contextId);
+ if (!m_clientCounts.remove(contextId))
return;
- }
- m_clientCounts.set(contextId, clientCount);
+ ensureInterface(contextId).invalidate();
+ m_contextMap.remove(contextId);
}
#pragma mark Messages from WebPlaybackSessionManager
Modified: trunk/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.h (209936 => 209937)
--- trunk/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.h 2016-12-16 21:52:38 UTC (rev 209936)
+++ trunk/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.h 2016-12-16 22:05:54 UTC (rev 209937)
@@ -34,6 +34,7 @@
#include <WebCore/PlatformCALayer.h>
#include <WebCore/WebPlaybackSessionInterface.h>
#include <WebCore/WebPlaybackSessionModelMediaElement.h>
+#include <wtf/HashCountedSet.h>
#include <wtf/HashMap.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
@@ -151,7 +152,7 @@
HashMap<WebCore::HTMLMediaElement*, uint64_t> m_mediaElements;
HashMap<uint64_t, ModelInterfaceTuple> m_contextMap;
uint64_t m_controlsManagerContextId { 0 };
- HashMap<uint64_t, int> m_clientCounts;
+ HashCountedSet<uint64_t> m_clientCounts;
};
} // namespace WebKit
Modified: trunk/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.mm (209936 => 209937)
--- trunk/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.mm 2016-12-16 21:52:38 UTC (rev 209936)
+++ trunk/Source/WebKit2/WebProcess/cocoa/WebPlaybackSessionManager.mm 2016-12-16 22:05:54 UTC (rev 209937)
@@ -213,26 +213,14 @@
void WebPlaybackSessionManager::addClientForContext(uint64_t contextId)
{
- auto addResult = m_clientCounts.add(contextId, 1);
- if (!addResult.isNewEntry)
- addResult.iterator->value++;
+ m_clientCounts.add(contextId);
}
void WebPlaybackSessionManager::removeClientForContext(uint64_t contextId)
{
ASSERT(m_clientCounts.contains(contextId));
-
- int clientCount = m_clientCounts.get(contextId);
- ASSERT(clientCount > 0);
- clientCount--;
-
- if (clientCount <= 0) {
- m_clientCounts.remove(contextId);
+ if (m_clientCounts.remove(contextId))
removeContext(contextId);
- return;
- }
-
- m_clientCounts.set(contextId, clientCount);
}
void WebPlaybackSessionManager::setUpPlaybackControlsManager(WebCore::HTMLMediaElement& mediaElement)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes