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

Unified Diff: Source/core/html/canvas/WebGLExtension.h

Issue 687533005: Enforce context refrence guards in WebGL extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Switched to using RefPtr Created 6 years, 1 month 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/html/canvas/WebGLDrawBuffers.cpp ('k') | Source/core/html/canvas/WebGLExtension.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/canvas/WebGLExtension.h
diff --git a/Source/core/html/canvas/WebGLExtension.h b/Source/core/html/canvas/WebGLExtension.h
index 474f500d141fdb2fa9579af88d1587c7d264d0eb..09ae66ac0037203f17abfd623f5ad753a7d2994d 100644
--- a/Source/core/html/canvas/WebGLExtension.h
+++ b/Source/core/html/canvas/WebGLExtension.h
@@ -26,6 +26,7 @@
#ifndef WebGLExtension_h
#define WebGLExtension_h
+#include "core/html/HTMLCanvasElement.h"
#include "core/html/canvas/WebGLExtensionName.h"
#include "core/html/canvas/WebGLRenderingContextBase.h"
#include "platform/heap/Handle.h"
@@ -33,11 +34,25 @@
namespace blink {
-class WebGLExtension : public RefCountedWillBeGarbageCollectedFinalized<WebGLExtension> {
+class WebGLExtensionScopedContext : public NoBaseWillBeGarbageCollectedFinalized<WebGLExtensionScopedContext> {
+ WTF_MAKE_NONCOPYABLE(WebGLExtensionScopedContext);
WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
public:
- WebGLRenderingContextBase* context() { return m_context; }
+ WebGLExtensionScopedContext(WebGLExtension*);
+ virtual ~WebGLExtensionScopedContext();
+
+ bool isLost() { return !m_context; }
+ WebGLRenderingContextBase* context() const { return m_context.get(); }
+
+ virtual void trace(Visitor*);
+
+private:
+ RefPtrWillBeMember<WebGLRenderingContextBase> m_context;
+};
+class WebGLExtension : public RefCountedWillBeGarbageCollectedFinalized<WebGLExtension> {
+ WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
+public:
virtual ~WebGLExtension();
virtual WebGLExtensionName name() const = 0;
@@ -49,16 +64,16 @@ public:
m_context = nullptr;
}
- bool isLost()
- {
- return !m_context;
- }
+ bool isLost() { return !m_context; }
virtual void trace(Visitor*);
protected:
explicit WebGLExtension(WebGLRenderingContextBase*);
+private:
+ friend WebGLExtensionScopedContext;
+
RawPtrWillBeWeakMember<WebGLRenderingContextBase> m_context;
};
« no previous file with comments | « Source/core/html/canvas/WebGLDrawBuffers.cpp ('k') | Source/core/html/canvas/WebGLExtension.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698