Ref: A smart pointer for the reference age.
<https://webkit.org/b/120570>
Reviewed by Antti Koivisto.
Source/WebCore:
Use Ref<T> for various stack guards where null checking isn't needed.
Source/WTF:
Add a very simple simple Ref<T> smart pointer class that is never null.
It's initialized by passing a T& to the constructor and cannot be assigned to.
operator-> is not overloaded, to prevent unsafe-looking code.
The value is extracted by "T& get()", since C++ does not let you override operator.()
* wtf/Ref.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154962 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/loader/DocumentThreadableLoader.cpp b/Source/WebCore/loader/DocumentThreadableLoader.cpp
index c924853..3fe56f3 100644
--- a/Source/WebCore/loader/DocumentThreadableLoader.cpp
+++ b/Source/WebCore/loader/DocumentThreadableLoader.cpp
@@ -48,6 +48,7 @@
#include "SubresourceLoader.h"
#include "ThreadableLoaderClient.h"
#include <wtf/Assertions.h>
+#include <wtf/Ref.h>
#if ENABLE(INSPECTOR)
#include "ProgressTracker.h"
@@ -144,7 +145,7 @@
void DocumentThreadableLoader::cancel()
{
- RefPtr<DocumentThreadableLoader> protect(this);
+ Ref<DocumentThreadableLoader> protect(*this);
// Cancel can re-enter and m_resource might be null here as a result.
if (m_client && m_resource) {
@@ -180,7 +181,7 @@
ASSERT(m_client);
ASSERT_UNUSED(resource, resource == m_resource);
- RefPtr<DocumentThreadableLoader> protect(this);
+ Ref<DocumentThreadableLoader> protect(*this);
// Allow same origin requests to continue after allowing clients to audit the redirect.
if (isAllowedRedirect(request.url())) {
if (m_client->isDocumentThreadableLoaderClient())