Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(440)

Unified Diff: Source/core/dom/CompositorProxy.cpp

Issue 1064123002: compositor-worker: Introduce CompositorProxy::disconnect(). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix-win-for-realz Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/CompositorProxy.h ('k') | Source/core/dom/CompositorProxy.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/CompositorProxy.cpp
diff --git a/Source/core/dom/CompositorProxy.cpp b/Source/core/dom/CompositorProxy.cpp
index f656b9c65e8563d7dfbbfc6f96e5640fb5c10f06..1934c7bd430a0ad4f733aefe27269b25ff08e149 100644
--- a/Source/core/dom/CompositorProxy.cpp
+++ b/Source/core/dom/CompositorProxy.cpp
@@ -10,6 +10,8 @@
#include "core/dom/DOMNodeIds.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/ExecutionContext.h"
+#include "public/platform/Platform.h"
+#include "public/platform/WebTraceLocation.h"
namespace blink {
@@ -58,6 +60,26 @@ static bool isCallingCompositorFrameCallback()
return true;
}
+static void decrementCountForElement(uint64_t elementId)
+{
+ ASSERT(isMainThread());
+ Node* node = DOMNodeIds::nodeForId(elementId);
+ if (!node)
+ return;
+ Element* element = toElement(node);
+ element->decrementProxyCount();
+}
+
+static void incrementProxyCountForElement(uint64_t elementId)
+{
+ ASSERT(isMainThread());
+ Node* node = DOMNodeIds::nodeForId(elementId);
+ if (!node)
+ return;
+ Element* element = toElement(node);
+ element->incrementProxyCount();
+}
+
static bool raiseExceptionIfMutationNotAllowed(ExceptionState& exceptionState)
{
if (!isControlThread()) {
@@ -114,6 +136,8 @@ CompositorProxy::CompositorProxy(Element& element, const Vector<String>& attribu
ASSERT(isMainThread());
ASSERT(m_bitfieldsSupported);
ASSERT(sanityCheckAttributeFlags(m_bitfieldsSupported));
+
+ incrementProxyCountForElement(m_elementId);
}
CompositorProxy::CompositorProxy(uint64_t elementId, uint32_t attributeFlags)
@@ -122,10 +146,13 @@ CompositorProxy::CompositorProxy(uint64_t elementId, uint32_t attributeFlags)
{
ASSERT(isControlThread());
ASSERT(sanityCheckAttributeFlags(m_bitfieldsSupported));
+ Platform::current()->mainThread()->postTask(FROM_HERE, bind(&incrementProxyCountForElement, m_elementId));
}
CompositorProxy::~CompositorProxy()
{
+ if (m_connected)
+ disconnect();
}
bool CompositorProxy::supports(const String& attributeName) const
@@ -211,10 +238,20 @@ void CompositorProxy::setTransform(DOMMatrix* transform, ExceptionState& excepti
bool CompositorProxy::raiseExceptionIfNotMutable(Attributes attribute, ExceptionState& exceptionState) const
{
- if (m_bitfieldsSupported & static_cast<uint32_t>(attribute))
+ if (m_connected && (m_bitfieldsSupported & static_cast<uint32_t>(attribute)))
return false;
- exceptionState.throwDOMException(NoModificationAllowedError, "Attempted to mutate non-mutable attribute.");
+ exceptionState.throwDOMException(NoModificationAllowedError,
+ m_connected ? "Attempted to mutate non-mutable attribute." : "Attempted to mutate attribute on a disconnected proxy.");
return true;
}
+void CompositorProxy::disconnect()
+{
+ m_connected = false;
+ if (isMainThread())
+ decrementCountForElement(m_elementId);
+ else
+ Platform::current()->mainThread()->postTask(FROM_HERE, bind(&decrementCountForElement, m_elementId));
+}
+
} // namespace blink
« no previous file with comments | « Source/core/dom/CompositorProxy.h ('k') | Source/core/dom/CompositorProxy.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698