Fix leak of GrResourceCacheEntry

R=robertphillips@google.com
TBR=robertphillips@google.com

Author: bsalomon@google.com

Review URL: https://codereview.chromium.org/502543002
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index b420df2..63beb7d 100755
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -548,8 +548,9 @@
     if (texture->wasDestroyed()) {
         if (texture->getCacheEntry()->key().isScratch()) {
             // This texture was detached from the cache but the cache still had a ref to it but
-            // not a pointer to it.
-            texture->unref();
+            // not a pointer to it. This will unref the texture and delete its resource cache
+            // entry.
+            delete texture->getCacheEntry();
         }
         return;
     }
diff --git a/src/gpu/GrResourceCache.h b/src/gpu/GrResourceCache.h
index 235b11a..82ffbea 100644
--- a/src/gpu/GrResourceCache.h
+++ b/src/gpu/GrResourceCache.h
@@ -152,6 +152,7 @@
     SK_DECLARE_INTERNAL_LLIST_INTERFACE(GrResourceCacheEntry);
 
     friend class GrResourceCache;
+    friend class GrContext;
 };
 
 ///////////////////////////////////////////////////////////////////////////////