Index: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp |
diff --git a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp |
index e156684c20d05c411f7b235db09fb49701e16d35..8b5e181216e350e6ef523a0defc97de115b82717 100644 |
--- a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp |
+++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp |
@@ -96,7 +96,9 @@ |
#include "public/platform/Platform.h" |
#include "public/platform/WebGraphicsContext3D.h" |
#include "public/platform/WebGraphicsContext3DProvider.h" |
+#include "public/platform/callback/WebClosure.h" |
#include "wtf/ArrayBufferContents.h" |
+#include "wtf/Functional.h" |
#include "wtf/PassOwnPtr.h" |
#include "wtf/text/StringBuilder.h" |
#include "wtf/text/StringUTF8Adaptor.h" |
@@ -993,10 +995,10 @@ void WebGLRenderingContextBase::initializeNewContext() |
contextGL()->Viewport(0, 0, drawingBufferWidth(), drawingBufferHeight()); |
contextGL()->Scissor(0, 0, drawingBufferWidth(), drawingBufferHeight()); |
- m_contextLostCallbackAdapter = WebGLRenderingContextLostCallback::create(this); |
m_errorMessageCallbackAdapter = WebGLRenderingContextErrorMessageCallback::create(this); |
- webContext()->setContextLostCallback(m_contextLostCallbackAdapter.get()); |
+ // Uses raw |this| as the callback is reset before |this| is destroyed. |
+ drawingBuffer()->contextProvider()->setLostContextCallback(WebClosure(WTF::bind(&WebGLRenderingContextBase::forceLostContext, this, WebGLRenderingContextBase::RealLostContext, WebGLRenderingContextBase::Auto))); |
webContext()->setErrorMessageCallback(m_errorMessageCallbackAdapter.get()); |
// This ensures that the context has a valid "lastFlushID" and won't be mistakenly identified as the "least recently used" context. |
@@ -1112,7 +1114,7 @@ void WebGLRenderingContextBase::destroyContext() |
m_extensionsUtil.clear(); |
- webContext()->setContextLostCallback(nullptr); |
+ drawingBuffer()->contextProvider()->setLostContextCallback(WebClosure()); |
webContext()->setErrorMessageCallback(nullptr); |
ASSERT(drawingBuffer()); |
@@ -6283,7 +6285,6 @@ DEFINE_TRACE(WebGLRenderingContextBase) |
#if ENABLE(OILPAN) |
visitor->trace(m_contextObjects); |
#endif |
- visitor->trace(m_contextLostCallbackAdapter); |
visitor->trace(m_errorMessageCallbackAdapter); |
visitor->trace(m_boundArrayBuffer); |
visitor->trace(m_defaultVertexArrayObject); |