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

Unified Diff: ios/chrome/browser/snapshots/snapshot_cache_unittest.mm

Issue 2686213003: Fix memory leak in SaveToDisk. (Closed)
Patch Set: Created 3 years, 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/snapshots/snapshot_cache_unittest.mm
diff --git a/ios/chrome/browser/snapshots/snapshot_cache_unittest.mm b/ios/chrome/browser/snapshots/snapshot_cache_unittest.mm
index 4912f1b5b2320cc54163cd968059e723d62369c1..ad5468cc42f69003d33b31f18622549256bcb7fb 100644
--- a/ios/chrome/browser/snapshots/snapshot_cache_unittest.mm
+++ b/ios/chrome/browser/snapshots/snapshot_cache_unittest.mm
@@ -11,6 +11,7 @@
#include "base/format_macros.h"
#include "base/location.h"
#include "base/mac/bind_objc_block.h"
+#include "base/mac/scoped_cftyperef.h"
#include "base/mac/scoped_nsautorelease_pool.h"
#include "base/mac/scoped_nsobject.h"
#include "base/run_loop.h"
@@ -191,11 +192,6 @@ class SnapshotCacheTest : public PlatformTest {
}
}
- const char* GetPixelData(CGImageRef cgImage) {
- CFDataRef data = CGDataProviderCopyData(CGImageGetDataProvider(cgImage));
- return reinterpret_cast<const char*>(CFDataGetBytePtr(data));
- }
-
void TriggerMemoryWarning() {
// _performMemoryWarning is a private API and must not be compiled into
// official builds.
@@ -271,12 +267,18 @@ TEST_F(SnapshotCacheTest, SaveToDisk) {
UIImage* image =
[UIImage imageWithContentsOfFile:base::SysUTF8ToNSString(path.value())];
CGImageRef cgImage = [image CGImage];
- const char* pixels = GetPixelData(cgImage);
+ base::ScopedCFTypeRef<CFDataRef> pixelData(
+ CGDataProviderCopyData(CGImageGetDataProvider(cgImage)));
+ const char* pixels =
+ reinterpret_cast<const char*>(CFDataGetBytePtr(pixelData));
EXPECT_TRUE(pixels);
UIImage* referenceImage = [testImages_ objectAtIndex:i];
CGImageRef referenceCgImage = [referenceImage CGImage];
- const char* referencePixels = GetPixelData(referenceCgImage);
+ base::ScopedCFTypeRef<CFDataRef> referenceData(
+ CGDataProviderCopyData(CGImageGetDataProvider(referenceCgImage)));
+ const char* referencePixels =
+ reinterpret_cast<const char*>(CFDataGetBytePtr(referenceData));
EXPECT_TRUE(referencePixels);
if (pixels != nil && referencePixels != nil) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698